dpkg: fix build on case-insensitive file systems; add install check

Changed files
+41 -19
pkgs
by-name
dp
+41 -19
pkgs/by-name/dp/dpkg/package.nix
···
autoreconfHook,
pkg-config,
diffutils,
+
versionCheckHook,
glibc ? !stdenv.hostPlatform.isDarwin,
}:
-
stdenv.mkDerivation rec {
+
stdenv.mkDerivation (finalAttrs: {
pname = "dpkg";
version = "1.22.21";
src = fetchgit {
url = "https://git.launchpad.net/ubuntu/+source/dpkg";
-
rev = "applied/${version}";
-
hash = "sha256-UiXZfwvgsgyXR6olNzKelt/3Fgtp7KU8UbTRRkDl8wY=";
+
tag = "applied/${finalAttrs.version}";
+
leaveDotGit = true;
+
# Fix filename conflict on case-insensitive filesystems
+
postFetch = ''
+
pushd $out
+
git checkout HEAD -- scripts/t/Dpkg_BuildTree.t
+
mv scripts/t/Dpkg_BuildTree.t scripts/t/Dpkg_BuildTreeC.t
+
substituteInPlace scripts/Makefile.am --replace-fail t/Dpkg_BuildTree.t t/Dpkg_BuildTreeC.t
+
substituteInPlace scripts/Makefile.in --replace-fail t/Dpkg_BuildTree.t t/Dpkg_BuildTreeC.t
+
git checkout HEAD -- scripts/t/dpkg_buildtree.t
+
rm -rf .git
+
popd
+
'';
+
hash = "sha256-LK6nOPewjRyKyHdwJgmLILoZ6sEfJzRtC7pIeWz01lA=";
};
configureFlags = [
···
PATH=$TMPDIR:$PATH
for i in $(find . -name Makefile.in); do
-
substituteInPlace $i --replace "install-data-local:" "disabled:" ;
+
substituteInPlace $i --replace-quiet "install-data-local:" "disabled:" ;
done
# Skip check broken when cross-compiling.
···
# Dpkg commands sometimes calls out to shell commands
substituteInPlace lib/dpkg/dpkg.h \
-
--replace '"dpkg-deb"' \"$out/bin/dpkg-deb\" \
-
--replace '"dpkg-split"' \"$out/bin/dpkg-split\" \
-
--replace '"dpkg-query"' \"$out/bin/dpkg-query\" \
-
--replace '"dpkg-divert"' \"$out/bin/dpkg-divert\" \
-
--replace '"dpkg-statoverride"' \"$out/bin/dpkg-statoverride\" \
-
--replace '"dpkg-trigger"' \"$out/bin/dpkg-trigger\" \
-
--replace '"dpkg"' \"$out/bin/dpkg\" \
-
--replace '"debsig-verify"' \"$out/bin/debsig-verify\" \
-
--replace '"rm"' \"${coreutils}/bin/rm\" \
-
--replace '"cat"' \"${coreutils}/bin/cat\" \
-
--replace '"diff"' \"${diffutils}/bin/diff\"
+
--replace-fail '"dpkg-deb"' \"$out/bin/dpkg-deb\" \
+
--replace-fail '"dpkg-split"' \"$out/bin/dpkg-split\" \
+
--replace-fail '"dpkg-query"' \"$out/bin/dpkg-query\" \
+
--replace-fail '"dpkg-divert"' \"$out/bin/dpkg-divert\" \
+
--replace-fail '"dpkg-statoverride"' \"$out/bin/dpkg-statoverride\" \
+
--replace-fail '"dpkg-trigger"' \"$out/bin/dpkg-trigger\" \
+
--replace-fail '"dpkg"' \"$out/bin/dpkg\" \
+
--replace-fail '"debsig-verify"' \"$out/bin/debsig-verify\" \
+
--replace-fail '"rm"' \"${coreutils}/bin/rm\" \
+
--replace-fail '"cat"' \"${coreutils}/bin/cat\" \
+
--replace-fail '"diff"' \"${diffutils}/bin/diff\"
+
''
+
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
+
# realpath("/var/lib/dpkg", NULL) gives EPERM on sandboxed darwin instead of the expected ENOENT,
+
# which makes some tests fail.
+
sed -i '/opts normalize/a AT_SKIP_IF([true])' src/at/chdir.at
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
substituteInPlace src/main/help.c \
-
--replace '"ldconfig"' \"${glibc.bin}/bin/ldconfig\"
+
--replace-fail '"ldconfig"' \"${glibc.bin}/bin/ldconfig\"
'';
buildInputs = [
···
postInstall = ''
for i in $out/bin/*; do
if head -n 1 $i | grep -q perl; then
-
substituteInPlace $i --replace \
+
substituteInPlace $i --replace-fail \
"${perl}/bin/perl" "${perl}/bin/perl -I $out/${perl.libPrefix}"
fi
done
···
cp -r scripts/t/origins $out/etc/dpkg
'';
+
doInstallCheck = true;
+
nativeInstallCheckInputs = [ versionCheckHook ];
+
versionCheckProgramArg = "--version";
+
setupHook = ./setup-hook.sh;
meta = with lib; {
···
homepage = "https://wiki.debian.org/Teams/Dpkg";
license = licenses.gpl2Plus;
platforms = platforms.unix;
-
broken = stdenv.hostPlatform.isDarwin;
maintainers = with maintainers; [ siriobalmelli ];
+
mainProgram = "dpkg";
};
-
}
+
})