1{
2 lib,
3 stdenv,
4 file,
5 fetchFromGitLab,
6 buildPerlPackage,
7 ArchiveZip,
8 ArchiveCpio,
9 SubOverride,
10 shortenPerlShebang,
11 gitUpdater,
12}:
13
14buildPerlPackage rec {
15 pname = "strip-nondeterminism";
16 version = "1.14.1";
17
18 outputs = [
19 "out"
20 "dev"
21 ]; # no "devdoc"
22
23 src = fetchFromGitLab {
24 owner = "reproducible-builds";
25 repo = "strip-nondeterminism";
26 domain = "salsa.debian.org";
27 rev = version;
28 sha256 = "C/812td9BX1YRqFpD9QYgBfzE+biZeAKgxoNcxpb6UU=";
29 };
30
31 strictDeps = true;
32 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ shortenPerlShebang ];
33 buildInputs = [
34 ArchiveZip
35 ArchiveCpio
36 SubOverride
37 ];
38
39 postPatch = ''
40 substituteInPlace lib/File/StripNondeterminism.pm \
41 --replace "exec('file'" "exec('${lib.getExe file}'"
42 '';
43
44 postBuild = ''
45 patchShebangs ./bin
46 '';
47
48 postInstall = ''
49 # we don’t need the debhelper script
50 rm $out/bin/dh_strip_nondeterminism
51 rm $out/share/man/man1/dh_strip_nondeterminism.1
52 ''
53 + lib.optionalString stdenv.hostPlatform.isDarwin ''
54 shortenPerlShebang $out/bin/strip-nondeterminism
55 '';
56
57 installCheckPhase = ''
58 runHook preInstallCheck
59 ($out/bin/strip-nondeterminism --help 2>&1 | grep -q "verbose") || (echo "'$out/bin/strip-nondeterminism --help' failed" && exit 1)
60 runHook postInstallCheck
61 '';
62
63 # running shortenPerlShebang in postBuild results in non-functioning binary 'exec format error'
64 doCheck = !stdenv.hostPlatform.isDarwin;
65 doInstallCheck = true;
66
67 passthru = {
68 updateScript = gitUpdater { };
69 };
70
71 meta = with lib; {
72 description = "Perl module for stripping bits of non-deterministic information";
73 mainProgram = "strip-nondeterminism";
74 homepage = "https://reproducible-builds.org/";
75 license = licenses.gpl3Only;
76 maintainers = with maintainers; [
77 pSub
78 artturin
79 ];
80 };
81}