From 5748bfdd76e2c5c85f0d7f5f5d0cf65605c7bdb0 Mon Sep 17 00:00:00 2001 From: annalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:13:44 +0000 Subject: freshBootstrapTools.{build,test}: allow exes with libs unpack --- pkgs/stdenv/darwin/make-bootstrap-tools.nix | 50 ++++++++++------------------- 1 file changed, 17 insertions(+), 33 deletions(-) (limited to 'pkgs/stdenv/darwin') diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix index 3476748a8fd25..3064e7f762604 100644 --- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix +++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix @@ -49,14 +49,6 @@ rec { scpSupport = false; }); - gnutar_ = (gnutar.override { libintl = null; }).overrideAttrs (old: { - configureFlags = [ - "--disable-nls" - ] ++ old.configureFlags or []; - }); - - xz_ = xz.override { enableStatic = true; }; - unpackScript = writeText "bootstrap-tools-unpack.sh" '' set -euo pipefail @@ -102,7 +94,7 @@ rec { in '' - mkdir -p $out/bin $out/lib $out/lib/system $out/lib/darwin + mkdir -p $out/bin $out/lib $out/lib/darwin ${lib.optionalString stdenv.targetPlatform.isx86_64 '' # Copy libSystem's .o files for various low-level boot stuff. @@ -192,15 +184,15 @@ rec { cp -d ${getLib darwin.libtapi}/lib/libtapi* $out/lib - # tools needed to unpack bootstrap archive. they should not contain any - # external references. we will process them like the other tools but - # perform some additional checks and will not pack them into the archive. - mkdir -p unpack/bin - cp ${getBin bash}/bin/bash unpack/bin - ln -s bash unpack/bin/sh + # tools needed to unpack bootstrap archive + mkdir -p unpack/bin unpack/lib + cp -d ${getBin bash}/bin/{bash,sh} unpack/bin cp ${getBin coreutils_}/bin/mkdir unpack/bin - cp ${getBin gnutar_}/bin/tar unpack/bin - cp ${getBin xz_}/bin/xz unpack/bin + cp ${getBin gnutar}/bin/tar unpack/bin + cp ${getBin xz}/bin/xz unpack/bin + cp -d ${getLib gettext}/lib/libintl*.dylib unpack/lib + cp -d ${getLib libiconv}/lib/lib*.dylib unpack/lib + cp -d ${getLib xz}/lib/liblzma*.dylib unpack/lib cp ${unpackScript} unpack/bootstrap-tools-unpack.sh # @@ -245,45 +237,37 @@ rec { fi } - # check that linked library paths exist in $out/lib + # check that linked library paths exist in lib # must be run after rpathify is performed checkDeps() { local deps=$(${stdenv.cc.targetPrefix}otool -l "$1"| grep -o '@rpath/[^ ]*' || true) local lib + shopt -s extglob for lib in $deps; do - if [[ ! -e $out/''${lib/@rpath/lib} ]]; then + local root="''${1/\/@(lib|bin)\/*}" + if [[ ! -e $root/''${lib/@rpath/lib} ]]; then echo "error: $1 missing lib for $lib" >&2 exit 1 fi done + shopt -u extglob } - for i in $out/bin/* unpack/bin/* $out/lib{,/darwin}/*.dylib; do + for i in {unpack,$out}/bin/* {unpack,$out}/lib{,/darwin}/*.dylib; do if [[ ! -L $i ]] && isMachO "$i"; then rpathify "$i" checkDeps "$i" fi done - nuke-refs $out/bin/* - nuke-refs $out/lib/* + nuke-refs {unpack,$out}/bin/* + nuke-refs {unpack,$out}/lib/* nuke-refs $out/lib/darwin/* - nuke-refs $out/lib/system/* - nuke-refs unpack/bin/* mkdir $out/.pack mv $out/* $out/.pack mv $out/.pack $out/pack - # validate that tools contain no references into the archive - for tool in unpack/bin/*; do - deps=$(${stdenv.cc.targetPrefix}otool -l "$tool"| grep '@rpath/' || true) - if [[ -n "$deps" ]]; then - printf "error: $tool is not self contained\n$deps\n" >&2 - exit 1 - fi - done - mkdir $out/on-server cp -r unpack $out -- cgit 1.4.1