about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorannalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>2024-03-18 12:56:20 +0000
committerannalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>2024-03-19 17:28:32 +0000
commit3cdd8d05f0fc175358e720b6af929ba1a528d803 (patch)
tree0dba59a2df0e94a518839b4b16376bc2e1d823ef /pkgs/stdenv
parentb31083035992f8090f20b6f321420c1caa08c1b6 (diff)
stdenv.darwin.make-boostrap-tools: include unpack script in the archive
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/darwin/make-bootstrap-tools.nix53
-rw-r--r--pkgs/stdenv/darwin/patch-bootstrap-tools.sh37
2 files changed, 51 insertions, 39 deletions
diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
index 7725665ae4368..836a938b84ae8 100644
--- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
@@ -56,6 +56,47 @@ rec {
       });
 
       xz_ = xz.override { enableStatic = true; };
+
+      unpackScript = writeText "bootstrap-tools-unpack.sh" ''
+        set -euo pipefail
+
+        echo Unpacking the bootstrap tools... >&2
+        mkdir $out
+        tar xf "$1" -C $out
+
+        updateInstallName() {
+          local path="$1"
+
+          cp "$path" "$path.new"
+          install_name_tool -id "$path" "$path.new"
+          codesign -f -i "$(basename "$path")" -s - "$path.new"
+          mv -f "$path.new" "$path"
+        }
+
+        find $out/lib -type f -name '*.dylib' -print0 | while IFS= read -r -d $'\0' lib; do
+          updateInstallName "$lib"
+        done
+
+        # Provide a gunzip script.
+        cat > $out/bin/gunzip <<EOF
+        #!$out/bin/sh
+        exec $out/bin/gzip -d "\$@"
+        EOF
+        chmod +x $out/bin/gunzip
+
+        # Provide fgrep/egrep.
+        echo "#! $out/bin/sh" > $out/bin/egrep
+        echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
+        echo "#! $out/bin/sh" > $out/bin/fgrep
+        echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
+
+        cat >$out/bin/dsymutil << EOF
+        #!$out/bin/sh
+        EOF
+
+        chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil
+    '';
+
     in
     ''
       mkdir -p $out/bin $out/lib $out/lib/system $out/lib/darwin
@@ -157,6 +198,7 @@ rec {
       cp ${getBin coreutils_}/bin/mkdir unpack/bin
       cp ${getBin gnutar_}/bin/tar unpack/bin
       cp ${getBin xz_}/bin/xz unpack/bin
+      cp ${unpackScript} unpack/bootstrap-tools-unpack.sh
 
       #
       # All files copied. Perform processing to update references to point into
@@ -273,8 +315,15 @@ rec {
     name = "bootstrap-tools";
     builder = "${bootstrapFiles.unpack}/bin/bash";
 
-    args = [ ./patch-bootstrap-tools.sh bootstrapFiles.bootstrapTools ];
-    PATH = lib.makeBinPath [ (placeholder "out") bootstrapFiles.unpack ];
+    args = [
+      "${bootstrapFiles.unpack}/bootstrap-tools-unpack.sh"
+        bootstrapFiles.bootstrapTools
+    ];
+
+    PATH = lib.makeBinPath [
+      (placeholder "out")
+      bootstrapFiles.unpack
+    ];
 
     allowedReferences = [ "out" ];
   };
diff --git a/pkgs/stdenv/darwin/patch-bootstrap-tools.sh b/pkgs/stdenv/darwin/patch-bootstrap-tools.sh
deleted file mode 100644
index 555c340a7e752..0000000000000
--- a/pkgs/stdenv/darwin/patch-bootstrap-tools.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-set -euo pipefail
-
-echo Unpacking the bootstrap tools... >&2
-mkdir $out
-tar xf "$1" -C $out
-
-updateInstallName() {
-  local path="$1"
-
-  cp "$path" "$path.new"
-  install_name_tool -id "$path" "$path.new"
-  codesign -f -i "$(basename "$path")" -s - "$path.new"
-  mv -f "$path.new" "$path"
-}
-
-find $out/lib -type f -name '*.dylib' -print0 | while IFS= read -r -d $'\0' lib; do
-  updateInstallName "$lib"
-done
-
-# Provide a gunzip script.
-cat > $out/bin/gunzip <<EOF
-#!$out/bin/sh
-exec $out/bin/gzip -d "\$@"
-EOF
-chmod +x $out/bin/gunzip
-
-# Provide fgrep/egrep.
-echo "#! $out/bin/sh" > $out/bin/egrep
-echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep
-echo "#! $out/bin/sh" > $out/bin/fgrep
-echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep
-
-cat >$out/bin/dsymutil << EOF
-#!$out/bin/sh
-EOF
-
-chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil