nuke-references: support -e option
This commit is contained in:
parent
c81fb457c9
commit
3c7871a1c0
@ -3,11 +3,26 @@ source $stdenv/setup
|
||||
mkdir -p $out/bin
|
||||
cat > $out/bin/nuke-refs <<EOF
|
||||
#! $SHELL -e
|
||||
for i in \$*; do
|
||||
if test ! -L \$i -a -f \$i; then
|
||||
cat \$i | sed "s|$NIX_STORE/[a-z0-9]*-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" > \$i.tmp
|
||||
if test -x \$i; then chmod +x \$i.tmp; fi
|
||||
mv \$i.tmp \$i
|
||||
|
||||
excludes=""
|
||||
while getopts e: o; do
|
||||
case "\$o" in
|
||||
e) storeId=\$(echo "\$OPTARG" | sed -n "s|^$NIX_STORE/\\([a-z0-9]\{32\}\\)-.*|\1|p")
|
||||
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
|
||||
cat "\$i" | $perl/bin/perl -pe "s|$NIX_STORE/\$excludes[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" > "\$i.tmp"
|
||||
if test -x "\$i"; then chmod +x "\$i.tmp"; fi
|
||||
mv "\$i.tmp" "\$i"
|
||||
fi
|
||||
done
|
||||
EOF
|
||||
|
@ -3,9 +3,10 @@
|
||||
# path (/nix/store/eeee...). This is useful for getting rid of
|
||||
# dependencies that you know are not actually needed at runtime.
|
||||
|
||||
{stdenv}:
|
||||
{ stdenv, perl }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "nuke-references";
|
||||
builder = ./builder.sh;
|
||||
}
|
||||
inherit perl;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user