diff options
author | Artturi <Artturin@artturin.com> | 2023-08-04 01:21:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 01:21:07 +0300 |
commit | c0731df13c4e4895904249923033d5b886aad021 (patch) | |
tree | 1253e57ca5a6311659d58452317a844ba1277052 /pkgs/build-support | |
parent | 5f0e7501326b11755b78c300b5cab4c65345749e (diff) | |
parent | ebd4619053711ffb317a36dca4b118ae33f17828 (diff) | |
download | nixlib-c0731df13c4e4895904249923033d5b886aad021.tar nixlib-c0731df13c4e4895904249923033d5b886aad021.tar.gz nixlib-c0731df13c4e4895904249923033d5b886aad021.tar.bz2 nixlib-c0731df13c4e4895904249923033d5b886aad021.tar.lz nixlib-c0731df13c4e4895904249923033d5b886aad021.tar.xz nixlib-c0731df13c4e4895904249923033d5b886aad021.tar.zst nixlib-c0731df13c4e4895904249923033d5b886aad021.zip |
Merge pull request #238525 from tie/patch-shebang-update-store-paths
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/setup-hooks/patch-shebangs.sh | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index 9a48440debec..e6872db1acd7 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -11,11 +11,12 @@ fixupOutputHooks+=(patchShebangsAuto) # Run patch shebangs on a directory or file. # Can take multiple paths as arguments. -# patchShebangs [--build | --host] PATH... +# patchShebangs [--build | --host | --update] [--] PATH... # Flags: # --build : Lookup commands available at build-time # --host : Lookup commands available at runtime +# --update : Update shebang paths that are in Nix store # Example use cases, # $ patchShebangs --host /nix/store/...-hello-1.0/bin @@ -23,14 +24,35 @@ fixupOutputHooks+=(patchShebangsAuto) patchShebangs() { local pathName - - if [[ "$1" == "--host" ]]; then - pathName=HOST_PATH - shift - elif [[ "$1" == "--build" ]]; then - pathName=PATH - shift - fi + local update + + while [[ $# -gt 0 ]]; do + case "$1" in + --host) + pathName=HOST_PATH + shift + ;; + --build) + pathName=PATH + shift + ;; + --update) + update=true + shift + ;; + --) + shift + break + ;; + -*|--*) + echo "Unknown option $1 supplied to patchShebangs" >&2 + return 1 + ;; + *) + break + ;; + esac + done echo "patching script interpreter paths in $@" local f @@ -93,7 +115,7 @@ patchShebangs() { newInterpreterLine="$newPath $args" newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}} - if [[ -n "$oldPath" && "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]]; then + if [[ -n "$oldPath" && ( "$update" == true || "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ) ]]; then if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\"" # escape the escape chars so that sed doesn't interpret them |