From 8f33b8cc93006c97a8f6b7ede20214992ed31fa8 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Sun, 6 Sep 2015 10:21:43 +0200 Subject: mass rewrite of find parameters to cross-platform style Fixes #9044, close #9667. Thanks to @taku0 for suggesting this solution. Now we have no modes starting with `/` or `+`. Rewrite the `-perm` parameters of find: - completely safe: rewrite `/0100` and `+100` to `-0100`, - slightly semantics-changing: rewrite `+111` to `-0100`. I cross-verified the `find` manual pages for Linux, Darwin, FreeBSD. --- pkgs/applications/networking/copy-com/default.nix | 2 +- pkgs/applications/networking/dropbox/default.nix | 4 ++-- pkgs/applications/science/logic/otter/default.nix | 6 +++--- pkgs/applications/science/math/content/default.nix | 2 +- pkgs/applications/science/math/mathematica/9.nix | 2 +- pkgs/applications/science/math/mathematica/default.nix | 2 +- pkgs/build-support/builder-defs/builder-defs.nix | 2 +- pkgs/build-support/setup-hooks/patch-shebangs.sh | 2 +- pkgs/development/compilers/ghc/6.10.2-binary.nix | 2 +- pkgs/development/compilers/ghc/7.0.4-binary.nix | 2 +- pkgs/development/compilers/ghc/7.4.2-binary.nix | 2 +- pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh | 2 +- pkgs/development/compilers/oraclejdk/jdk-linux-base.nix | 2 +- pkgs/development/interpreters/ruby/bundler-head.nix | 2 +- pkgs/development/interpreters/ruby/bundler.nix | 2 +- pkgs/development/libraries/ncbi/default.nix | 2 +- pkgs/development/libraries/wtk/builder.sh | 4 ++-- pkgs/development/mobile/androidenv/androidndk.nix | 2 +- pkgs/development/mobile/androidenv/androidndk_r8e.nix | 2 +- pkgs/development/python-modules/generic/wrap.sh | 2 +- pkgs/development/tools/misc/patchelf/setup-hook.sh | 2 +- pkgs/servers/plex/default.nix | 2 +- pkgs/tools/graphics/quirc/default.nix | 2 +- 23 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pkgs/applications/networking/copy-com/default.nix b/pkgs/applications/networking/copy-com/default.nix index 7dd2702325b2..968218309ed7 100644 --- a/pkgs/applications/networking/copy-com/default.nix +++ b/pkgs/applications/networking/copy-com/default.nix @@ -52,7 +52,7 @@ in stdenv.mkDerivation { RPATH=${libPaths}:$out/${appdir} echo "Updating rpaths to $RPATH in:" - find "$out/${appdir}" -type f -a -perm /0100 \ + find "$out/${appdir}" -type f -a -perm -0100 \ -print -exec patchelf --force-rpath --set-rpath "$RPATH" {} \; ''; diff --git a/pkgs/applications/networking/dropbox/default.nix b/pkgs/applications/networking/dropbox/default.nix index 3fa6fb51ee14..0af5dfba3f24 100644 --- a/pkgs/applications/networking/dropbox/default.nix +++ b/pkgs/applications/networking/dropbox/default.nix @@ -101,12 +101,12 @@ in stdenv.mkDerivation { rm "$out/${appdir}/qt.conf" rm -fr "$out/${appdir}/plugins" - find "$out/${appdir}" -type f -a -perm /0100 \ + find "$out/${appdir}" -type f -a -perm -0100 \ -print -exec patchelf --set-interpreter ${stdenv.glibc}/lib/${interpreter} {} \; RPATH=${ldpath}:${gcc.cc}/lib:$out/${appdir} echo "updating rpaths to: $RPATH" - find "$out/${appdir}" -type f -a -perm /0100 \ + find "$out/${appdir}" -type f -a -perm -0100 \ -print -exec patchelf --force-rpath --set-rpath "$RPATH" {} \; mkdir -p "$out/share/applications" diff --git a/pkgs/applications/science/logic/otter/default.nix b/pkgs/applications/science/logic/otter/default.nix index 653c5dad03f7..398f6c9a3e22 100644 --- a/pkgs/applications/science/logic/otter/default.nix +++ b/pkgs/applications/science/logic/otter/default.nix @@ -20,9 +20,9 @@ stdenv.mkDerivation { buildPhase = '' find . -name Makefile | xargs sed -i -e "s@/bin/rm@$(type -P rm)@g" find . -name Makefile | xargs sed -i -e "s@/bin/mv@$(type -P mv)@g" - find . -perm +111 -type f | xargs sed -i -e "s@/bin/csh@$(type -P csh)@g" - find . -perm +111 -type f | xargs sed -i -e "s@/bin/rm@$(type -P rm)@g" - find . -perm +111 -type f | xargs sed -i -e "s@/bin/mv@$(type -P mv)@g" + find . -perm -0100 -type f | xargs sed -i -e "s@/bin/csh@$(type -P csh)@g" + find . -perm -0100 -type f | xargs sed -i -e "s@/bin/rm@$(type -P rm)@g" + find . -perm -0100 -type f | xargs sed -i -e "s@/bin/mv@$(type -P mv)@g" sed -i -e "s/^XLIBS *=.*/XLIBS=-lXaw -lXt -lX11/" source/formed/Makefile diff --git a/pkgs/applications/science/math/content/default.nix b/pkgs/applications/science/math/content/default.nix index 177efd667a39..e843c5ea9d85 100644 --- a/pkgs/applications/science/math/content/default.nix +++ b/pkgs/applications/science/math/content/default.nix @@ -82,7 +82,7 @@ rec { find . -name '*.so' -exec cp '{}' $out/lib ';' find . -name '*.txt' -exec cp '{}' $out/share/${name}/doc ';' find . -name '*.hlp' -exec cp '{}' $out/share/${name}/doc ';' - find . -perm +111 -a ! -name '*.*' -exec cp '{}' $out/bin ';' + find . -perm -0100 -a ! -name '*.*' -exec cp '{}' $out/bin ';' cp -r . $out/share/${name}/build-snapshot '') ["buildContent" "defEnsureDir" "minInit"]; diff --git a/pkgs/applications/science/math/mathematica/9.nix b/pkgs/applications/science/math/mathematica/9.nix index c9357d7352f0..3c7f758d91bc 100644 --- a/pkgs/applications/science/math/mathematica/9.nix +++ b/pkgs/applications/science/math/mathematica/9.nix @@ -86,7 +86,7 @@ stdenv.mkDerivation rec { preFixup = '' echo "=== PatchElfing away ===" - find $out/libexec/Mathematica/SystemFiles -type f -perm +100 | while read f; do + find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/') if [ -z "$type" ]; then : diff --git a/pkgs/applications/science/math/mathematica/default.nix b/pkgs/applications/science/math/mathematica/default.nix index 5fc704178836..39f2409a987c 100644 --- a/pkgs/applications/science/math/mathematica/default.nix +++ b/pkgs/applications/science/math/mathematica/default.nix @@ -96,7 +96,7 @@ stdenv.mkDerivation rec { preFixup = '' echo "=== PatchElfing away ===" - find $out/libexec/Mathematica/SystemFiles -type f -perm +100 | while read f; do + find $out/libexec/Mathematica/SystemFiles -type f -perm -0100 | while read f; do type=$(readelf -h "$f" 2>/dev/null | grep 'Type:' | sed -e 's/ *Type: *\([A-Z]*\) (.*/\1/') if [ -z "$type" ]; then : diff --git a/pkgs/build-support/builder-defs/builder-defs.nix b/pkgs/build-support/builder-defs/builder-defs.nix index e7c64501614c..6ea4ec86c480 100644 --- a/pkgs/build-support/builder-defs/builder-defs.nix +++ b/pkgs/build-support/builder-defs/builder-defs.nix @@ -569,7 +569,7 @@ let inherit (builtins) head tail trace; in # Interpreters that are already in the store are left untouched. echo "patching script interpreter paths" local f - for f in $(find "${dir}" -xtype f -perm /0100); do + for f in $(find "${dir}" -xtype f -perm -0100); do local oldPath=$(sed -ne '1 s,^#![ ]*\([^ ]*\).*$,\1,p' "$f") if test -n "$oldPath" -a "''${oldPath:0:''${#NIX_STORE}}" != "$NIX_STORE"; then local newPath=$(type -P $(basename $oldPath) || true) diff --git a/pkgs/build-support/setup-hooks/patch-shebangs.sh b/pkgs/build-support/setup-hooks/patch-shebangs.sh index 44ebad0d593b..152755992f68 100644 --- a/pkgs/build-support/setup-hooks/patch-shebangs.sh +++ b/pkgs/build-support/setup-hooks/patch-shebangs.sh @@ -18,7 +18,7 @@ patchShebangs() { local oldInterpreterLine local newInterpreterLine - find "$dir" -type f -perm /0100 | while read f; do + find "$dir" -type f -perm -0100 | while read f; do if [ "$(head -1 "$f" | head -c +2)" != '#!' ]; then # missing shebang => not a script continue diff --git a/pkgs/development/compilers/ghc/6.10.2-binary.nix b/pkgs/development/compilers/ghc/6.10.2-binary.nix index 4e660853f200..96ec4e6c114a 100644 --- a/pkgs/development/compilers/ghc/6.10.2-binary.nix +++ b/pkgs/development/compilers/ghc/6.10.2-binary.nix @@ -38,7 +38,7 @@ stdenv.mkDerivation rec { # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. (if stdenv.isLinux then '' - find . -type f -perm +100 \ + find . -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "${libedit}/lib:${ncurses}/lib:${gmp}/lib" {} \; for prog in ld ar gcc strip ranlib; do diff --git a/pkgs/development/compilers/ghc/7.0.4-binary.nix b/pkgs/development/compilers/ghc/7.0.4-binary.nix index 7a6f1b78fa49..31df7f1fa355 100644 --- a/pkgs/development/compilers/ghc/7.0.4-binary.nix +++ b/pkgs/development/compilers/ghc/7.0.4-binary.nix @@ -60,7 +60,7 @@ stdenv.mkDerivation rec { # On Linux, use patchelf to modify the executables so that they can # find editline/gmp. stdenv.lib.optionalString stdenv.isLinux '' - find . -type f -perm +100 \ + find . -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "${ncurses}/lib:${gmp}/lib" {} \; sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 diff --git a/pkgs/development/compilers/ghc/7.4.2-binary.nix b/pkgs/development/compilers/ghc/7.4.2-binary.nix index 3d781e9d558f..03dd4dcd35bb 100644 --- a/pkgs/development/compilers/ghc/7.4.2-binary.nix +++ b/pkgs/development/compilers/ghc/7.4.2-binary.nix @@ -62,7 +62,7 @@ stdenv.mkDerivation rec { stdenv.lib.optionalString stdenv.isLinux '' mkdir -p "$out/lib" ln -sv "${ncurses}/lib/libncurses.so" "$out/lib/libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5" - find . -type f -perm +100 \ + find . -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "$out/lib:${gmp}/lib" {} \; sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 diff --git a/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh b/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh index 56669ae0f2f6..459bfce50988 100644 --- a/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh +++ b/pkgs/development/compilers/oraclejdk/dlj-bundle-builder.sh @@ -45,7 +45,7 @@ fi rpath=$rpath${rpath:+:}$jrePath/lib/$architecture/jli # set all the dynamic linkers -find $out -type f -perm +100 \ +find $out -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "$rpath" {} \; diff --git a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix index 35ee1a04a268..c5588787922a 100644 --- a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix +++ b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix @@ -142,7 +142,7 @@ let result = stdenv.mkDerivation rec { rpath=$rpath''${rpath:+:}$jrePath/lib/${architecture} # set all the dynamic linkers - find $out -type f -perm +100 \ + find $out -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "$rpath" {} \; diff --git a/pkgs/development/interpreters/ruby/bundler-head.nix b/pkgs/development/interpreters/ruby/bundler-head.nix index 0aa6e9f90ce1..a81f2f771bcb 100644 --- a/pkgs/development/interpreters/ruby/bundler-head.nix +++ b/pkgs/development/interpreters/ruby/bundler-head.nix @@ -10,7 +10,7 @@ buildRubyGem { }; dontPatchShebangs = true; postInstall = '' - find $out -type f -perm /0100 | while read f; do + find $out -type f -perm -0100 | while read f; do substituteInPlace $f \ --replace "/usr/bin/env" "${coreutils}/bin/env" done diff --git a/pkgs/development/interpreters/ruby/bundler.nix b/pkgs/development/interpreters/ruby/bundler.nix index 6dc01f9929c9..1bf9fd91e5b2 100644 --- a/pkgs/development/interpreters/ruby/bundler.nix +++ b/pkgs/development/interpreters/ruby/bundler.nix @@ -6,7 +6,7 @@ buildRubyGem { sha256 = "1zkxw6699bbmsamrij2lirscbh0j58p1p3bql22jsxvx34j6w5nc"; dontPatchShebangs = true; postInstall = '' - find $out -type f -perm /0100 | while read f; do + find $out -type f -perm -0100 | while read f; do substituteInPlace $f \ --replace "/usr/bin/env" "${coreutils}/bin/env" done diff --git a/pkgs/development/libraries/ncbi/default.nix b/pkgs/development/libraries/ncbi/default.nix index a74cd81854e1..5d3b6170a3a3 100644 --- a/pkgs/development/libraries/ncbi/default.nix +++ b/pkgs/development/libraries/ncbi/default.nix @@ -40,7 +40,7 @@ rec { cp ../make/makedis.csh $out/share/${name}/build-snapshot cp *.h $out/include cp *.c *.h $out/source - find . -perm +111 -a '(' '(' ! -name '*.*' ')' -o '(' -name '*.REAL' ')' ')' -exec cp '{}' $out/bin ';' + find . -perm -0100 -a '(' '(' ! -name '*.*' ')' -o '(' -name '*.REAL' ')' ')' -exec cp '{}' $out/bin ';' '') ["defEnsureDir" "build" "minInit"]; name = "NCBI-Toolbox-" + version; diff --git a/pkgs/development/libraries/wtk/builder.sh b/pkgs/development/libraries/wtk/builder.sh index ef0085da924c..86f2719537cd 100644 --- a/pkgs/development/libraries/wtk/builder.sh +++ b/pkgs/development/libraries/wtk/builder.sh @@ -21,7 +21,7 @@ rpath= for i in $libraries; do rpath=$rpath${rpath:+:}$i/lib done -find $out -type f -perm +100 \ +find $out -type f -perm -0100 \ -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \; -find $out -type f -perm +100 \ +find $out -type f -perm -0100 \ -exec patchelf --set-rpath "$rpath" {} \; diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix index 9f5393949ca7..cc1c28105245 100644 --- a/pkgs/development/mobile/androidenv/androidndk.nix +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -53,7 +53,7 @@ stdenv.mkDerivation rec { find $out \( \ \( -type f -a -name "*.so*" \) -o \ - \( -type f -a -perm /0100 \) \ + \( -type f -a -perm -0100 \) \ \) -exec patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-*so.? \ --set-rpath ${zlib}/lib:${ncurses}/lib {} \; # fix ineffective PROGDIR / MYNDKDIR determination diff --git a/pkgs/development/mobile/androidenv/androidndk_r8e.nix b/pkgs/development/mobile/androidenv/androidndk_r8e.nix index 5e04bbf0116d..90994ae708e5 100644 --- a/pkgs/development/mobile/androidenv/androidndk_r8e.nix +++ b/pkgs/development/mobile/androidenv/androidndk_r8e.nix @@ -53,7 +53,7 @@ stdenv.mkDerivation rec { find $out \( \ \( -type f -a -name "*.so*" \) -o \ - \( -type f -a -perm /0100 \) \ + \( -type f -a -perm -0100 \) \ \) -exec patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-*so.? \ --set-rpath ${zlib}/lib:${ncurses}/lib {} \; # fix ineffective PROGDIR / MYNDKDIR determination diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh index 6ad603e01384..557f79f865ec 100644 --- a/pkgs/development/python-modules/generic/wrap.sh +++ b/pkgs/development/python-modules/generic/wrap.sh @@ -26,7 +26,7 @@ wrapPythonProgramsIn() { done # Find all regular files in the output directory that are executable. - for f in $(find "$dir" -type f -perm /0100); do + for f in $(find "$dir" -type f -perm -0100); do # Rewrite "#! .../env python" to "#! /nix/store/.../python". if head -n1 "$f" | grep -q '#!.*/env.*\(python\|pypy\)'; then sed -i "$f" -e "1 s^.*/env[ ]*\(python\|pypy\)^#! $python^" diff --git a/pkgs/development/tools/misc/patchelf/setup-hook.sh b/pkgs/development/tools/misc/patchelf/setup-hook.sh index 944b418d1b47..a76fbfbd509c 100644 --- a/pkgs/development/tools/misc/patchelf/setup-hook.sh +++ b/pkgs/development/tools/misc/patchelf/setup-hook.sh @@ -9,7 +9,7 @@ patchELF() { if [ -e "$prefix" ]; then find "$prefix" \( \ \( -type f -a -name "*.so*" \) -o \ - \( -type f -a -perm /0100 \) \ + \( -type f -a -perm -0100 \) \ \) -print -exec patchelf --shrink-rpath '{}' \; fi stopNest diff --git a/pkgs/servers/plex/default.nix b/pkgs/servers/plex/default.nix index 1c7ff5c49df6..c0bfd42ce680 100644 --- a/pkgs/servers/plex/default.nix +++ b/pkgs/servers/plex/default.nix @@ -31,7 +31,7 @@ stdenv.mkDerivation rec { patchelf --set-rpath "$out/usr/lib/plexmediaserver" "$out/usr/lib/plexmediaserver/$bin" done - find $out/usr/lib/plexmediaserver/Resources -type f -a -perm /0100 \ + find $out/usr/lib/plexmediaserver/Resources -type f -a -perm -0100 \ -print -exec patchelf --set-interpreter "${glibc}/lib/ld-linux-x86-64.so.2" '{}' \; diff --git a/pkgs/tools/graphics/quirc/default.nix b/pkgs/tools/graphics/quirc/default.nix index cab02f6573d1..d84989d4372b 100644 --- a/pkgs/tools/graphics/quirc/default.nix +++ b/pkgs/tools/graphics/quirc/default.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation { ''; preInstall = '' mkdir -p "$out"/{bin,lib,include} - find . -maxdepth 1 -type f -perm +111 -exec cp '{}' "$out"/bin ';' + find . -maxdepth 1 -type f -perm -0100 -exec cp '{}' "$out"/bin ';' ''; makeFlags = "PREFIX=$(out)"; meta = { -- cgit 1.4.1