From 76aedfaaeeae743c94efa6962bfadf0ec6919b48 Mon Sep 17 00:00:00 2001 From: nicoo Date: Wed, 30 Aug 2023 08:26:52 +0000 Subject: [PATCH] fetchDebianPatch: Handle the case of `lib*` packages --- pkgs/build-support/fetchdebianpatch/default.nix | 11 ++++++++--- pkgs/build-support/fetchdebianpatch/tests.nix | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchdebianpatch/default.nix b/pkgs/build-support/fetchdebianpatch/default.nix index ba6aa63a732b..c058b416d381 100644 --- a/pkgs/build-support/fetchdebianpatch/default.nix +++ b/pkgs/build-support/fetchdebianpatch/default.nix @@ -3,12 +3,17 @@ lib.makeOverridable ( { pname, version, debianRevision ? null, patch, hash, area ? "main", name ? "${patch}.patch" }: - let versionString = - if debianRevision == null then version else "${version}-${debianRevision}"; + let + inherit (lib.strings) hasPrefix substring; + prefix = + substring 0 (if hasPrefix "lib" pname then 4 else 1) pname; + versionString = + if debianRevision == null then version + else "${version}-${debianRevision}"; in fetchpatch { inherit name hash; url = - "https://sources.debian.org/data/${area}/${builtins.substring 0 1 pname}/" + "https://sources.debian.org/data/${area}/${prefix}/" + "${pname}/${versionString}/debian/patches/${patch}.patch"; } ) diff --git a/pkgs/build-support/fetchdebianpatch/tests.nix b/pkgs/build-support/fetchdebianpatch/tests.nix index 2146f66ce709..58f3b395d1fc 100644 --- a/pkgs/build-support/fetchdebianpatch/tests.nix +++ b/pkgs/build-support/fetchdebianpatch/tests.nix @@ -8,4 +8,12 @@ patch = "Add-quotes-to-SOAPAction-header-in-SoapClient"; hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0="; }; + + libPackage = testers.invalidateFetcherByDrvHash fetchDebianPatch { + pname = "libfile-pid-perl"; + version = "1.01"; + debianRevision = "2"; + patch = "missing-pidfile"; + hash = "sha256-VBsIYyCnjcZLYQ2Uq2MKPK3kF2wiMKvnq0m727DoavM="; + }; }