Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f55f45f273ea
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d42ef371c9b1
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Feb 1, 2019

  1. 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.
    tollb committed Feb 1, 2019
    Copy the full SHA
    bbb2f93 View commit details
  2. Merge pull request #54909 from tollb/fix/wrap-gapps-hook_unnecessary_…

    …symlink_wrap
    
    wrap-gapps-hook.sh: only wrap links when required
    jtojnar authored Feb 1, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d42ef37 View commit details
Showing with 26 additions and 2 deletions.
  1. +26 −2 pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
28 changes: 26 additions & 2 deletions pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
Original file line number Diff line number Diff line change
@@ -36,16 +36,40 @@ wrapGAppsHook() {
done

if [[ -z "$dontWrapGApps" ]]; then
targetDirsThatExist=()
targetDirsRealPath=()

# wrap binaries
targetDirs=( "${prefix}/bin" "${prefix}/libexec" )
for targetDir in "${targetDirs[@]}"; do
if [[ -d "${targetDir}" ]]; then
find -L "${targetDir}" -type f -executable -print0 \
targetDirsThatExist+=("${targetDir}")
targetDirsRealPath+=("$(realpath "${targetDir}")/")
find "${targetDir}" -type f -executable -print0 \
| while IFS= read -r -d '' file; do
echo "Wrapping program ${file}"
echo "Wrapping program '${file}'"
wrapProgram "${file}" "${gappsWrapperArgs[@]}"
done
fi
done

# wrap links to binaries that point outside targetDirs
# Note: links to binaries within targetDirs do not need
# to be wrapped as the binaries have already been wrapped
if [[ ${#targetDirsThatExist[@]} -ne 0 ]]; then
find "${targetDirsThatExist[@]}" -type l -xtype f -executable -print0 \
| while IFS= read -r -d '' linkPath; do
linkPathReal=$(realpath "${linkPath}")
for targetPath in "${targetDirsRealPath[@]}"; do
if [[ "$linkPathReal" == "$targetPath"* ]]; then
echo "Not wrapping link: '$linkPath' (already wrapped)"
continue 2
fi
done
echo "Wrapping link: '$linkPath'"
wrapProgram "${linkPath}" "${gappsWrapperArgs[@]}"
done
fi
fi
}