nixpkgs/pkgs/build-support/setup-hooks
Bruce Toll bbb2f93cee wrap-gapps-hook.sh: only wrap links when required
Unless dontWrapGapps is set, the wrap-gapps-hook.sh will currently
wrap all executables (and symbolic links to executables) found under
the target directories: bin and libexec.

As a result, if a symbolic link in a target directory points to an
executable in a target directory, both will get wrapped.  This
causes an extra shell/exec when following the symbolic link,
as well as increasing the size of the final executable's environment.

To avoid wrapping a link to an already wrapped executable, this
commit splits the determination of what gets wrapped into two phases:

1. All binaries under the target directories are wrapped and logged
   with "Wrapping program ..."

2. All links to executables under the target directories are
   identified and checked to see if they reference an executable
   under one of the target directories.

   If yes, the required wrapping has already been performed on
   the associated binary (in phase 1), so no wrapping is done
   and "Not wrapping link: ... (already wrapped)" is logged.

   If no, the link points at an executable that hasn't been
   wrapped, so the link is wrapped and "Wrapping link: ..." is logged.

As an example, the yelp package has a bin directory that contains
an executable "yelp" and a symbolic link "gnome-help" -> "yelp".

Prior to this commit, the bin directory would contain these files
after wrapping:

  gnome-help          -- wrapper to exec .gnome-help-wrapped
  .gnome-help-wrapped -- a symbolic link to yelp
  yelp                -- wrapper to exec .yelp-wrapped
  .yelp-wrapped       -- the original yelp binary

After this commit, the bin directory will instead contain:

  gnome-help          -- a symbolic link to yelp
  yelp                -- wrapper to exec .yelp-wrapped
  .yelp-wrapped       -- the original yelp binary

NOTE: The primary motivation for this commit is to avoid obscuring
the fact that two or more paths are simple aliases and expected to
behave identically. It also reduces the likelihood of hitting
limits related to environment variable size.

LIMITATION: The method used above is intended to be conservative
and will still wrap symbolic links to other symbolic links when
the ultimate target is outside of bin or libexec.
2019-01-31 20:14:30 -05:00
..
audit-tmpdir.sh audit-tmpdir hook: clean up whitespace 2018-12-02 11:45:34 +01:00
auto-patchelf.sh autoPatchelfHook: Skip on missing segment headers 2018-11-26 01:58:36 +01:00
autoreconf.sh autoreconfHook: Simplify by avoiding findInputs 2017-09-14 13:16:12 -04:00
breakpoint-hook.sh breakpointHook: add for debugging failing builds 2018-10-25 10:19:41 +01:00
compress-man-pages.sh compress-man-pages: skip compressed manpages 2017-02-27 20:03:45 +01:00
die.sh dieHook: Add die utility function 2017-08-08 00:17:56 -05:00
enable-coverage-instrumentation.sh Move generation of coverage reports from nixos/lib/testing to releaseTools 2014-03-03 13:57:08 +01:00
find-xml-catalogs.sh treewide: Don't use envHook anymore 2017-12-30 22:04:22 -05:00
fix-darwin-dylib-names.sh replace "Mac OS X" and "OS X" with "macOS" 2017-08-07 21:41:30 +02:00
gog-unpack.sh build-support gogUnpackHook: support for unpacking games from gog.com 2018-02-12 22:28:06 +08:00
keep-build-tree.sh Move generation of coverage reports from nixos/lib/testing to releaseTools 2014-03-03 13:57:08 +01:00
ld-is-cc-hook.sh ld-is-cc-hook: init 2017-12-19 01:45:42 +00:00
make-coverage-analysis-report.sh releaseTools.coverageAnalysis: Emit hydra-metrics 2015-07-30 18:06:33 +02:00
make-wrapper.sh make-wrapper should use runtimeShell, not bash, for cross-compilation 2018-11-11 10:25:05 -08:00
move-docs.sh WIP 2014-08-25 15:30:46 +02:00
move-lib64.sh stdenv lib64-moving: fail instead of overwriting 2014-11-17 11:27:38 +01:00
move-sbin.sh Automatically move stuff in lib64 to lib 2014-10-07 15:04:13 +02:00
multiple-outputs.sh Merge pull request #31987 from jtojnar/devhelp-devdoc 2017-11-25 23:14:47 +00:00
patch-shebangs.sh Revert "Revert "Revert "patch-shebangs: respect cross compilation""" 2018-11-14 23:37:32 +01:00
prune-libtool-files.sh pruneLibtoolFiles: check if prefix exists 2018-12-09 22:44:29 +00:00
role.bash treewide: Use pkgs/build-support/roles.bash to remove copy pasta 2018-05-07 15:10:37 -04:00
separate-debug-info.sh misc setup-hooks: Use env vars to refer to binutils programs 2017-12-13 16:08:18 -05:00
set-java-classpath.sh treewide: Don't use envHook anymore 2017-12-30 22:04:22 -05:00
set-source-date-epoch-to-latest.sh set-source-date-epoch-to-latest: fix warning 2018-11-29 09:49:08 +01:00
setup-debug-info-dirs.sh treewide: Don't use envHook anymore 2017-12-30 22:04:22 -05:00
strip.sh strip setup hook: Learn about only stripping host/target binaries alone 2017-12-30 22:04:22 -05:00
update-autotools-gnu-config-scripts.sh updateAutotoolsGnuConfigScriptsHook: Only fix files 2017-02-11 12:24:49 +02:00
use-old-cxx-abi.sh useOldCXXAbi: Change into a setup hook 2016-04-01 13:36:59 +02:00
win-dll-link.sh misc setup-hooks: Use env vars to refer to binutils programs 2017-12-13 16:08:18 -05:00
wrap-gapps-hook.sh wrap-gapps-hook.sh: only wrap links when required 2019-01-31 20:14:30 -05:00