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
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
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
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
37 BADMAN
="$(strings $f | grep -o '/nix/store/.*' | grep -v "$out" | head -n1)"
38 if [ -z "$BADMAN" ]; then
42 BADMAN
="$(echo "$BADMAN" | cut -d/ -f-4)"
44 if [ ${#GOODMAN} -gt ${#BADMAN} ]; then
45 echo "Can't patch $f: $BADMAN too short"
48 while ! [ ${#GOODMAN} -eq ${#BADMAN} ]; do
51 if ! sed -E -i -e "s@$BADMAN@$GOODMAN@g" $f; then
52 echo "Can't patch $f: sed failed"