vimPlugins.blink-cmp: 0.7.3 -> 0.7.6 (#364100)
[NixPkgs.git] / pkgs / build-support / setup-hooks / make-symlinks-relative.sh
blobb07b0c5ae804c330ac6734ecf849474a026c85d3
1 # symlinks are often created in postFixup
2 # don't use fixupOutputHooks, it is before postFixup
3 postFixupHooks+=(_makeSymlinksRelativeInAllOutputs)
5 # For every symlink in $output that refers to another file in $output
6 # ensure that the symlink is relative. This removes references to the output
7 # has from the resulting store paths and thus the NAR files.
8 _makeSymlinksRelative() {
9 local symlinkTarget
11 if [ "${dontRewriteSymlinks-}" ] || [ ! -e "$prefix" ]; then
12 return
15 while IFS= read -r -d $'\0' f; do
16 symlinkTarget=$(readlink "$f")
17 if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then
18 # skip this symlink as it doesn't point to $prefix
19 continue
22 if [ ! -e "$symlinkTarget" ]; then
23 echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"
26 echo "rewriting symlink $f to be relative to $prefix"
27 ln -snrf "$symlinkTarget" "$f"
29 done < <(find $prefix -type l -print0)
32 _makeSymlinksRelativeInAllOutputs() {
33 local output
34 for output in $(getAllOutputNames); do
35 prefix="${!output}" _makeSymlinksRelative
36 done