1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 fetchpatch,
6 xz,
7 dpkg,
8 libxslt,
9 docbook_xsl,
10 makeWrapper,
11 writeShellScript,
12 python3Packages,
13 perlPackages,
14 curl,
15 gnupg,
16 diffutils,
17 nano,
18 pkg-config,
19 bash-completion,
20 help2man,
21 nix-update-script,
22 sendmailPath ? "/run/wrappers/bin/sendmail",
23}:
24
25let
26 inherit (python3Packages) python setuptools;
27 sensible-editor = writeShellScript "sensible-editor" ''
28 exec ''${EDITOR-${nano}/bin/nano} "$@"
29 '';
30in
31stdenv.mkDerivation (finalAttrs: {
32 pname = "debian-devscripts";
33 version = "2.25.15+deb13u1";
34
35 src = fetchFromGitLab {
36 domain = "salsa.debian.org";
37 owner = "debian";
38 repo = "devscripts";
39 tag = "v${finalAttrs.version}";
40 hash = "sha256-szyVLpeIQozPXwBgL4nIYog4znUzweIt8q7nczo5q+g=";
41 };
42
43 patches = [
44 (fetchpatch {
45 name = "hardening-check-obey-binutils-env-vars.patch";
46 url = "https://github.com/Debian/devscripts/pull/2/commits/c6a018e0ef50a1b0cb4962a2f96dae7c6f21f1d4.patch";
47 hash = "sha256-UpS239JiAM1IYxNuJLdILq2h0xlR5t0Tzhj47xiMHww=";
48 })
49 ];
50
51 postPatch = ''
52 substituteInPlace scripts/debrebuild.pl \
53 --replace-fail "/usr/bin/perl" "${perlPackages.perl}/bin/perl"
54 patchShebangs scripts
55 ''
56 +
57 # Remove man7 target to avoid missing *.7 file error
58 ''
59 substituteInPlace doc/Makefile \
60 --replace-fail " install_man7" ""
61 '';
62
63 nativeBuildInputs = [
64 makeWrapper
65 pkg-config
66 ];
67
68 buildInputs = [
69 xz
70 dpkg
71 libxslt
72 python
73 setuptools
74 curl
75 gnupg
76 diffutils
77 bash-completion
78 help2man
79 ]
80 ++ (with perlPackages; [
81 perl
82 CryptSSLeay
83 LWP
84 TimeDate
85 DBFile
86 FileDesktopEntry
87 ParseDebControl
88 LWPProtocolHttps
89 Moo
90 FileHomeDir
91 IPCRun
92 FileDirList
93 FileTouch
94 IOString
95 ]);
96
97 preConfigure = ''
98 export PERL5LIB="$PERL5LIB''${PERL5LIB:+:}${dpkg}";
99 tgtpy="$out/${python.sitePackages}"
100 mkdir -p "$tgtpy"
101 export PYTHONPATH="$PYTHONPATH''${PYTHONPATH:+:}$tgtpy"
102 find lib po4a scripts -type f -exec sed -r \
103 -e "s@/usr/bin/gpg(2|)@${lib.getExe' gnupg "gpg"}@g" \
104 -e "s@/usr/(s|)bin/sendmail@${sendmailPath}@g" \
105 -e "s@/usr/bin/diff@${lib.getExe' diffutils "diff"}@g" \
106 -e "s@/usr/bin/gpgv(2|)@${lib.getExe' gnupg "gpgv"}@g" \
107 -e "s@(command -v|/usr/bin/)curl@${lib.getExe curl}@g" \
108 -e "s@sensible-editor@${sensible-editor}@g" \
109 -e "s@(^|\W)/bin/bash@\1${stdenv.shell}@g" \
110 -i {} +
111 sed -e "s@/usr/share/sgml/[^ ]*/manpages/docbook.xsl@${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl@" -i scripts/Makefile
112 sed -r \
113 -e "s@/usr( |$|/)@$out\\1@g" \
114 -e "s@/etc( |$|/)@$out/etc\\1@g" \
115 -e 's/ translated_manpages//; s/--install-layout=deb//; s@--root="[^ ]*"@--prefix="'"$out"'"@' \
116 -i Makefile* */Makefile*
117 '';
118
119 makeFlags = [
120 "DESTDIR=$(out)"
121 "PREFIX="
122 "COMPL_DIR=/share/bash-completion/completions"
123 "PERLMOD_DIR=/share/devscripts"
124 ];
125
126 postInstall = ''
127 sed -re 's@(^|[ !`"])/bin/bash@\1${stdenv.shell}@g' -i "$out/bin"/*
128 for i in "$out/bin"/*; do
129 wrapProgram "$i" \
130 --prefix PERL5LIB : "$PERL5LIB" \
131 --prefix PERL5LIB : "$out/share/devscripts" \
132 --prefix PYTHONPATH : "$out/${python.sitePackages}" \
133 --prefix PATH : "${dpkg}/bin"
134 done
135 ln -s debchange $out/bin/dch
136 ln -s pts-subscribe $out/bin/pts-unsubscribe
137 '';
138
139 passthru.updateScript = nix-update-script { };
140
141 meta = {
142 description = "Debian package maintenance scripts";
143 license = lib.licenses.free; # Mix of public domain, Artistic+GPL, GPL1+, GPL2+, GPL3+, and GPL2-only... TODO
144 maintainers = with lib.maintainers; [ raskin ];
145 platforms = lib.platforms.unix;
146 };
147})