pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / build-support / remove-references-to / remove-references-to.sh
bloba4d068eb591ee135074e9f075ce67d71624b2c9a
1 #! @shell@ -e
3 fixupHooks=()
5 if [ -e @out@/nix-support/setup-hooks.sh ]; then
6 source @out@/nix-support/setup-hooks.sh
7 fi
9 # References to remove
10 targets=()
11 while getopts t: o; do
12 case "$o" in
13 t) storeId=$(echo "$OPTARG" | sed -n "s|^@storeDir@/\\([a-z0-9]\{32\}\\)-.*|\1|p")
14 if [ -z "$storeId" ]; then
15 echo "-t argument must be a Nix store path"
16 exit 1
18 targets+=("$storeId")
19 esac
20 done
21 shift $(($OPTIND-1))
23 # Files to remove the references from
24 regions=()
25 for i in "$@"; do
26 test ! -L "$i" -a -f "$i" && regions+=("$i")
27 done
29 for target in "${targets[@]}" ; do
30 sed -i -e "s|$target|eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee|g" "${regions[@]}"
31 done
33 for region in "${regions[@]}"; do
34 for hook in "${fixupHooks[@]}"; do
35 eval "$hook" "$region"
36 done
37 done