python312Packages.vdf: avoid using pname for src.repo
[NixPkgs.git] / pkgs / stdenv / freebsd / unpack-bootstrap-files.sh
blobdfbf860ac8c95dcba6abec2c81511536df1df171
1 $src/libexec/ld-elf.so.1 $src/bin/mkdir $out
2 $src/libexec/ld-elf.so.1 $src/bin/tar -I "$src/libexec/ld-elf.so.1 $src/bin/xz" -C $out -xf $bootstrapTools
3 export LD_LIBRARY_PATH=$out/lib
5 BADLIST=ld-elf.so.1
7 oobpatch() {
8 $out/libexec/ld-elf.so.1 $src/bin/cp $1 ./tmp
9 $out/libexec/ld-elf.so.1 $out/bin/patchelf --set-rpath $out/lib --set-interpreter $out/libexec/ld-elf.so.1 ./tmp
10 $out/libexec/ld-elf.so.1 $src/bin/mv ./tmp $1
11 BADLIST="$BADLIST|${1##*/}"
14 oobpatch $out/bin/patchelf
15 oobpatch $out/lib/libthr.so.3
16 oobpatch $out/lib/libc.so.7
18 for f in $($out/libexec/ld-elf.so.1 $out/bin/find $out/lib -type f); do
19 $out/libexec/ld-elf.so.1 $out/bin/grep -E "$BADLIST" <<<"$f" && continue
20 $out/libexec/ld-elf.so.1 $out/bin/patchelf --set-rpath $out/lib $f
21 done
22 for f in $out/bin/* $out/bin/.*; do
23 $out/libexec/ld-elf.so.1 $out/bin/grep -E "$BADLIST" <<<"$f" &>/dev/null && continue
24 $out/libexec/ld-elf.so.1 $out/bin/patchelf --set-rpath $out/lib --set-interpreter $out/libexec/ld-elf.so.1 $f
25 done
27 unset LD_LIBRARY_PATH
28 export PATH=$out/bin
30 # sanity check
31 $out/bin/true || exit 1
33 # meticulously replace every nix store path with the right one
34 # to work with binaries, make sure the path remains the same length by prefixing pathsep chars
35 for f in $(find $out -type f); do
36 while true; do
37 BADMAN="$(strings $f | grep -o '/nix/store/.*' | grep -v "$out" | head -n1)"
38 if [ -z "$BADMAN" ]; then
39 break
41 echo scorch $f
42 BADMAN="$(echo "$BADMAN" | cut -d/ -f-4)"
43 GOODMAN="$out"
44 if [ ${#GOODMAN} -gt ${#BADMAN} ]; then
45 echo "Can't patch $f: $BADMAN too short"
46 break
48 while ! [ ${#GOODMAN} -eq ${#BADMAN} ]; do
49 GOODMAN="/$GOODMAN"
50 done
51 if ! sed -E -i -e "s@$BADMAN@$GOODMAN@g" $f; then
52 echo "Can't patch $f: sed failed"
53 break
55 done
56 done
57 echo $out