3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #204692 from Artturin/relative-links-fix-error

make-symlinks-relative: fix no such file or directory if output is cr…
This commit is contained in:
Artturi 2022-12-09 19:27:41 +02:00 committed by GitHub
commit 91d19a6e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View file

@ -1,4 +1,4 @@
fixupOutputHooks+=(_makeSymlinksRelative)
postFixupHooks+=(_makeSymlinksRelative)
# For every symlink in $output that refers to another file in $output
# ensure that the symlink is relative. This removes references to the output

View file

@ -26,6 +26,8 @@ with pkgs;
haskell = callPackage ./haskell { };
hooks = callPackage ./hooks { };
cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };

View file

@ -0,0 +1,28 @@
# To run these tests:
# nix-build -A tests.hooks
{ stdenv, pkgs, lib }:
{
# this attrset is for hooks in `stdenv.defaultNativeBuildInputs`
default-stdenv-hooks = lib.recurseIntoAttrs {
make-symlinks-relative = stdenv.mkDerivation {
name = "test-make-symlinks-relative";
passAsFile = [ "buildCommand" ];
buildCommand = ''
mkdir -p $out/{bar,baz}
source1="$out/bar/foo"
destination1="$out/baz/foo"
echo foo > $source1
ln -s $source1 $destination1
echo "symlink before patching: $(readlink $destination1)"
_makeSymlinksRelative
echo "symlink after patching: $(readlink $destination1)"
([[ -e $destination1 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
([[ $(readlink $destination1) == "../bar/foo" ]] && echo "absolute symlink was made relative") || (echo "symlink was not made relative" && exit 1)
'';
};
};
}