biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / tools / misc / debian-devscripts / default.nix
blobd70994753dbdff69a34e162c1b2fb170ea4797b4
1 {lib, stdenv, fetchurl, fetchpatch, xz, dpkg
2 , libxslt, docbook_xsl, makeWrapper, writeShellScript
3 , python3Packages
4 , perlPackages, curl, gnupg, diffutils, nano, pkg-config, bash-completion, help2man
5 , sendmailPath ? "/run/wrappers/bin/sendmail"
6 }:
8 let
9   inherit (python3Packages) python setuptools;
10   sensible-editor = writeShellScript "sensible-editor" ''
11     exec ''${EDITOR-${nano}/bin/nano} "$@"
12   '';
13 in stdenv.mkDerivation rec {
14   version = "2.23.5";
15   pname = "debian-devscripts";
17   src = fetchurl {
18     url = "mirror://debian/pool/main/d/devscripts/devscripts_${version}.tar.xz";
19     hash = "sha256-j0fUVTS/lPKFdgeMhksiJz2+E5koB07IK2uEj55EWG0=";
20   };
22   patches = [
23     (fetchpatch {
24       name = "hardening-check-obey-binutils-env-vars.patch";
25       url = "https://github.com/Debian/devscripts/pull/2/commits/c6a018e0ef50a1b0cb4962a2f96dae7c6f21f1d4.patch";
26       hash = "sha256-UpS239JiAM1IYxNuJLdILq2h0xlR5t0Tzhj47xiMHww=";
27     })
28   ];
30   postPatch = ''
31     substituteInPlace scripts/Makefile --replace /usr/share/dpkg ${dpkg}/share/dpkg
32     substituteInPlace scripts/debrebuild.pl --replace /usr/bin/perl ${perlPackages.perl}/bin/perl
33     patchShebangs scripts
34   '';
36   nativeBuildInputs = [ makeWrapper pkg-config ];
37   buildInputs = [ xz dpkg libxslt python setuptools curl gnupg diffutils bash-completion help2man ] ++
38     (with perlPackages; [ perl CryptSSLeay LWP TimeDate DBFile FileDesktopEntry ParseDebControl LWPProtocolHttps Moo FileHomeDir IPCRun FileDirList FileTouch ]);
40   preConfigure = ''
41     export PERL5LIB="$PERL5LIB''${PERL5LIB:+:}${dpkg}";
42     tgtpy="$out/${python.sitePackages}"
43     mkdir -p "$tgtpy"
44     export PYTHONPATH="$PYTHONPATH''${PYTHONPATH:+:}$tgtpy"
45     find lib po4a scripts -type f -exec sed -r \
46       -e "s@/usr/bin/gpg(2|)@${gnupg}/bin/gpg@g" \
47       -e "s@/usr/(s|)bin/sendmail@${sendmailPath}@g" \
48       -e "s@/usr/bin/diff@${diffutils}/bin/diff@g" \
49       -e "s@/usr/bin/gpgv(2|)@${gnupg}/bin/gpgv@g" \
50       -e "s@(command -v|/usr/bin/)curl@${curl.bin}/bin/curl@g" \
51       -e "s@sensible-editor@${sensible-editor}@g" \
52       -e "s@(^|\W)/bin/bash@\1${stdenv.shell}@g" \
53       -i {} +
54     sed -e "s@/usr/share/sgml/[^ ]*/manpages/docbook.xsl@${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl@" -i scripts/Makefile
55     sed -r \
56       -e "s@/usr( |$|/)@$out\\1@g" \
57       -e "s@/etc( |$|/)@$out/etc\\1@g" \
58       -e 's/ translated_manpages//; s/--install-layout=deb//; s@--root="[^ ]*"@--prefix="'"$out"'"@' \
59       -i Makefile* */Makefile*
60   '';
62   makeFlags = [
63     "DESTDIR=$(out)"
64     "PREFIX="
65     "COMPL_DIR=/share/bash-completion/completions"
66     "PERLMOD_DIR=/share/devscripts"
67   ];
69   postInstall = ''
70     sed -re 's@(^|[ !`"])/bin/bash@\1${stdenv.shell}@g' -i "$out/bin"/*
71     for i in "$out/bin"/*; do
72       wrapProgram "$i" \
73         --prefix PERL5LIB : "$PERL5LIB" \
74         --prefix PERL5LIB : "$out/share/devscripts" \
75         --prefix PYTHONPATH : "$out/${python.sitePackages}" \
76         --prefix PATH : "${dpkg}/bin"
77     done
78     ln -s cvs-debi $out/bin/cvs-debc
79     ln -s debchange $out/bin/dch
80     ln -s pts-subscribe $out/bin/pts-unsubscribe
81   '';
83   meta = with lib; {
84     description = "Debian package maintenance scripts";
85     license = licenses.free; # Mix of public domain, Artistic+GPL, GPL1+, GPL2+, GPL3+, and GPL2-only... TODO
86     maintainers = with maintainers; [raskin];
87     platforms = platforms.unix;
88   };