2006-11-03 14:33:24 +01:00
|
|
|
source $stdenv/setup
|
|
|
|
|
2012-01-18 21:16:00 +01:00
|
|
|
mkdir -p $out/bin
|
2006-11-03 14:33:24 +01:00
|
|
|
cat > $out/bin/nuke-refs <<EOF
|
|
|
|
#! $SHELL -e
|
2015-10-18 16:53:29 +02:00
|
|
|
|
|
|
|
excludes=""
|
|
|
|
while getopts e: o; do
|
|
|
|
case "\$o" in
|
2019-05-03 18:56:44 +02:00
|
|
|
e) storeId=\$(echo "\$OPTARG" | $perl/bin/perl -ne "print \"\\\$1\" if m|^\Q$NIX_STORE\E/([a-z0-9]{32})-.*|")
|
2015-10-18 16:53:29 +02:00
|
|
|
if [ -z "\$storeId" ]; then
|
|
|
|
echo "-e argument must be a Nix store path"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
excludes="\$excludes(?!\$storeId)"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift \$((\$OPTIND-1))
|
|
|
|
|
|
|
|
for i in "\$@"; do
|
|
|
|
if test ! -L "\$i" -a -f "\$i"; then
|
2019-05-03 18:56:44 +02:00
|
|
|
cat "\$i" | $perl/bin/perl -pe "s|\Q$NIX_STORE\E/\$excludes[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" > "\$i.tmp"
|
2015-10-18 16:53:29 +02:00
|
|
|
if test -x "\$i"; then chmod +x "\$i.tmp"; fi
|
|
|
|
mv "\$i.tmp" "\$i"
|
2009-01-16 18:13:14 +01:00
|
|
|
fi
|
2006-11-03 14:33:24 +01:00
|
|
|
done
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/nuke-refs
|