2023-01-17 02:20:36 +00:00
|
|
|
{ stdenv, pkgs, lib }:
|
2022-12-11 11:31:50 +00:00
|
|
|
|
|
|
|
# ordering should match defaultNativeBuildInputs
|
|
|
|
|
|
|
|
{
|
2022-12-12 23:10:52 +00:00
|
|
|
# TODO: add audit-tmpdir
|
2022-12-11 12:44:10 +00:00
|
|
|
compress-man-pages =
|
|
|
|
let
|
|
|
|
manFile = pkgs.writeText "small-man" ''
|
|
|
|
.TH HELLO "1" "May 2022" "hello 2.12.1" "User Commands"
|
|
|
|
.SH NAME
|
|
|
|
hello - friendly greeting program
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "test-compress-man-pages";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/share/man
|
|
|
|
cp ${manFile} $out/share/man/small-man.1
|
|
|
|
compressManPages $out
|
|
|
|
[[ -e $out/share/man/small-man.1.gz ]]
|
|
|
|
'';
|
|
|
|
};
|
2022-12-12 23:10:52 +00:00
|
|
|
make-symlinks-relative = stdenv.mkDerivation {
|
|
|
|
name = "test-make-symlinks-relative";
|
2023-01-23 18:11:02 +00:00
|
|
|
outputs = [ "out" "man" ];
|
2022-12-12 23:10:52 +00:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/{bar,baz}
|
2023-01-23 18:11:02 +00:00
|
|
|
mkdir -p $man/share/{x,y}
|
2022-12-12 23:10:52 +00:00
|
|
|
source1="$out/bar/foo"
|
|
|
|
destination1="$out/baz/foo"
|
2023-01-23 18:11:02 +00:00
|
|
|
source2="$man/share/x/file1"
|
|
|
|
destination2="$man/share/y/file2"
|
2022-12-12 23:10:52 +00:00
|
|
|
echo foo > $source1
|
2023-01-23 18:11:02 +00:00
|
|
|
echo foo > $source2
|
2022-12-12 23:10:52 +00:00
|
|
|
ln -s $source1 $destination1
|
2023-01-23 18:11:02 +00:00
|
|
|
ln -s $source2 $destination2
|
2022-12-12 23:10:52 +00:00
|
|
|
echo "symlink before patching: $(readlink $destination1)"
|
2023-01-23 18:11:02 +00:00
|
|
|
echo "symlink before patching: $(readlink $destination2)"
|
2022-12-11 12:44:10 +00:00
|
|
|
|
2023-01-23 18:11:02 +00:00
|
|
|
_makeSymlinksRelativeInAllOutputs
|
2022-12-12 23:10:52 +00:00
|
|
|
|
|
|
|
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)
|
2023-01-23 18:11:02 +00:00
|
|
|
echo "symlink after patching: $(readlink $destination2)"
|
|
|
|
([[ -e $destination2 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
|
|
|
|
([[ $(readlink $destination2) == "../x/file1" ]] && echo "absolute symlink was made relative") || (echo "symlink was not made relative" && exit 1)
|
2022-12-12 23:10:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
move-docs = stdenv.mkDerivation {
|
|
|
|
name = "test-move-docs";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/{man,doc,info}
|
|
|
|
touch $out/{man,doc,info}/foo
|
|
|
|
cat $out/{man,doc,info}/foo
|
|
|
|
|
|
|
|
_moveToShare
|
|
|
|
|
|
|
|
(cat $out/share/{man,doc,info}/foo 2>/dev/null && echo "man,doc,info were moved") || (echo "man,doc,info were not moved" && exit 1)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
move-lib64 = stdenv.mkDerivation {
|
|
|
|
name = "test-move-lib64";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/lib64
|
|
|
|
touch $out/lib64/foo
|
|
|
|
cat $out/lib64/foo
|
|
|
|
|
|
|
|
_moveLib64
|
|
|
|
|
|
|
|
# check symlink
|
|
|
|
[[ -h $out/lib64 ]]
|
|
|
|
([[ -e $out/lib64 ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
|
|
|
|
[[ -e $out/lib/foo ]]
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
move-sbin = stdenv.mkDerivation {
|
|
|
|
name = "test-move-sbin";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/sbin
|
|
|
|
touch $out/sbin/foo
|
|
|
|
cat $out/sbin/foo
|
|
|
|
|
|
|
|
_moveSbin
|
|
|
|
|
|
|
|
# check symlink
|
|
|
|
[[ -h $out/sbin ]]
|
|
|
|
([[ -e $out/sbin ]] && echo "symlink isn't broken") || (echo "symlink is broken" && exit 1)
|
|
|
|
[[ -e $out/bin/foo ]]
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
# TODO: add multiple-outputs
|
2023-01-17 02:20:36 +00:00
|
|
|
patch-shebangs = import ./patch-shebangs.nix { inherit stdenv lib pkgs; };
|
2022-12-11 12:44:10 +00:00
|
|
|
prune-libtool-files =
|
|
|
|
let
|
|
|
|
libFoo = pkgs.writeText "libFoo" ''
|
|
|
|
# Generated by libtool (GNU libtool) 2.4.6
|
|
|
|
old_library='''
|
|
|
|
dependency_libs=' -Lbar.la -Lbaz.la'
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "test-prune-libtool-files";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
cp ${libFoo} $out/lib/libFoo.la
|
|
|
|
_pruneLibtoolFiles
|
|
|
|
grep "^dependency_libs=''' #pruned" $out/lib/libFoo.la
|
|
|
|
# confirm file doesn't only contain the above
|
|
|
|
grep "^old_library='''" $out/lib/libFoo.la
|
|
|
|
'';
|
|
|
|
};
|
2022-12-12 23:10:52 +00:00
|
|
|
reproducible-builds = stdenv.mkDerivation {
|
|
|
|
name = "test-reproducible-builds";
|
2022-12-11 12:44:10 +00:00
|
|
|
buildCommand = ''
|
2022-12-12 23:10:52 +00:00
|
|
|
# can't be tested more precisely because the value of random-seed changes depending on the output
|
2023-02-19 19:23:32 +00:00
|
|
|
[[ $env.NIX_CFLAGS_COMPILE =~ "-frandom-seed=" ]]
|
2022-12-12 23:10:52 +00:00
|
|
|
touch $out
|
2022-12-11 12:44:10 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
set-source-date-epoch-to-latest = stdenv.mkDerivation {
|
|
|
|
name = "test-set-source-date-epoch-to-latest";
|
|
|
|
buildCommand = ''
|
|
|
|
sourceRoot=$NIX_BUILD_TOP/source
|
|
|
|
mkdir -p $sourceRoot
|
|
|
|
touch --date=1/1/2015 $sourceRoot/foo
|
|
|
|
|
|
|
|
_updateSourceDateEpochFromSourceRoot
|
|
|
|
|
|
|
|
[[ $SOURCE_DATE_EPOCH == "1420070400" ]]
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
};
|
2022-12-12 23:10:52 +00:00
|
|
|
# TODO: add strip
|
2022-12-11 11:31:50 +00:00
|
|
|
}
|