The main goal of this commit is to replace the rather fragile passing of multiple arrays which could break in cases like #130935. While I could have just added proper shell escaping to the variables being passed, I opted for the more painful approach of replacing the fragile and somewhat strange construct with the 5 bash lists. While there are currently no more problems present with the current approach (at least none that I know of), the new approach seems more solid and might get around problems that could arise in the future stemming from either the multiple-lists situation or from the absence of proper shell quoting all over the script.launchpad/nixpkgs/master
parent
6337261453
commit
eb7120dc79
@ -1,45 +0,0 @@ |
||||
source $stdenv/setup |
||||
|
||||
mkdir -p $out/etc |
||||
|
||||
set -f |
||||
sources_=($sources) |
||||
targets_=($targets) |
||||
modes_=($modes) |
||||
users_=($users) |
||||
groups_=($groups) |
||||
set +f |
||||
|
||||
for ((i = 0; i < ${#targets_[@]}; i++)); do |
||||
source="${sources_[$i]}" |
||||
target="${targets_[$i]}" |
||||
|
||||
if [[ "$source" =~ '*' ]]; then |
||||
|
||||
# If the source name contains '*', perform globbing. |
||||
mkdir -p $out/etc/$target |
||||
for fn in $source; do |
||||
ln -s "$fn" $out/etc/$target/ |
||||
done |
||||
|
||||
else |
||||
|
||||
mkdir -p $out/etc/$(dirname $target) |
||||
if ! [ -e $out/etc/$target ]; then |
||||
ln -s $source $out/etc/$target |
||||
else |
||||
echo "duplicate entry $target -> $source" |
||||
if test "$(readlink $out/etc/$target)" != "$source"; then |
||||
echo "mismatched duplicate entry $(readlink $out/etc/$target) <-> $source" |
||||
exit 1 |
||||
fi |
||||
fi |
||||
|
||||
if test "${modes_[$i]}" != symlink; then |
||||
echo "${modes_[$i]}" > $out/etc/$target.mode |
||||
echo "${users_[$i]}" > $out/etc/$target.uid |
||||
echo "${groups_[$i]}" > $out/etc/$target.gid |
||||
fi |
||||
|
||||
fi |
||||
done |
Loading…
Reference in new issue