Merge pull request #252225 from nbraud/fetchDebianPatch

authored by

Maciej Krüger and committed by
GitHub
edfb1866 50ac3d55

+110 -23
+47
doc/builders/fetchers.chapter.md
··· 82 82 83 83 Most other fetchers return a directory rather than a single file. 84 84 85 + 86 + ## `fetchDebianPatch` {#fetchdebianpatch} 87 + 88 + A wrapper around `fetchpatch`, which takes: 89 + - `patch` and `hash`: the patch's filename without the `.patch` suffix, 90 + and its hash after normalization by `fetchpatch` ; 91 + - `pname`: the Debian source package's name ; 92 + - `version`: the upstream version number ; 93 + - `debianRevision`: the [Debian revision number] if applicable ; 94 + - the `area` of the Debian archive: `main` (default), `contrib`, or `non-free`. 95 + 96 + Here is an example of `fetchDebianPatch` in action: 97 + 98 + ```nix 99 + { lib 100 + , fetchDebianPatch 101 + , buildPythonPackage 102 + }: 103 + 104 + buildPythonPackage rec { 105 + pname = "pysimplesoap"; 106 + version = "1.16.2"; 107 + src = ...; 108 + 109 + patches = [ 110 + (fetchDebianPatch { 111 + inherit pname version; 112 + debianRevision = "5"; 113 + name = "Add-quotes-to-SOAPAction-header-in-SoapClient"; 114 + hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0="; 115 + }) 116 + ]; 117 + 118 + ... 119 + } 120 + ``` 121 + 122 + Patches are fetched from `sources.debian.org`, and so must come from a 123 + package version that was uploaded to the Debian archive. Packages may 124 + be removed from there once that specific version isn't in any suite 125 + anymore (stable, testing, unstable, etc.), so maintainers should use 126 + `copy-tarballs.pl` to archive the patch if it needs to be available 127 + longer-term. 128 + 129 + [Debian revision number]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version 130 + 131 + 85 132 ## `fetchsvn` {#fetchsvn} 86 133 87 134 Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `hash`.
+19
pkgs/build-support/fetchdebianpatch/default.nix
··· 1 + { lib, fetchpatch }: 2 + 3 + lib.makeOverridable ( 4 + { pname, version, debianRevision ? null, patch, hash, 5 + area ? "main", name ? "${patch}.patch" }: 6 + let 7 + inherit (lib.strings) hasPrefix substring; 8 + prefix = 9 + substring 0 (if hasPrefix "lib" pname then 4 else 1) pname; 10 + versionString = 11 + if debianRevision == null then version 12 + else "${version}-${debianRevision}"; 13 + in fetchpatch { 14 + inherit name hash; 15 + url = 16 + "https://sources.debian.org/data/${area}/${prefix}/" 17 + + "${pname}/${versionString}/debian/patches/${patch}.patch"; 18 + } 19 + )
+19
pkgs/build-support/fetchdebianpatch/tests.nix
··· 1 + { testers, fetchDebianPatch, ... }: 2 + 3 + { 4 + simple = testers.invalidateFetcherByDrvHash fetchDebianPatch { 5 + pname = "pysimplesoap"; 6 + version = "1.16.2"; 7 + debianRevision = "5"; 8 + patch = "Add-quotes-to-SOAPAction-header-in-SoapClient"; 9 + hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0="; 10 + }; 11 + 12 + libPackage = testers.invalidateFetcherByDrvHash fetchDebianPatch { 13 + pname = "libfile-pid-perl"; 14 + version = "1.01"; 15 + debianRevision = "2"; 16 + patch = "missing-pidfile"; 17 + hash = "sha256-VBsIYyCnjcZLYQ2Uq2MKPK3kF2wiMKvnq0m727DoavM="; 18 + }; 19 + }
+19 -23
pkgs/development/python-modules/pysimplesoap/default.nix
··· 1 1 { lib 2 - , fetchpatch 2 + , fetchDebianPatch 3 3 , fetchPypi 4 4 , buildPythonPackage 5 5 , m2crypto ··· 20 20 m2crypto 21 21 ]; 22 22 23 - patches = 24 - let 25 - debianRevision = "5"; # The Debian package revision we get patches from 26 - fetchDebianPatch = { name, hash }: fetchpatch { 27 - url = "https://salsa.debian.org/python-team/packages/pysimplesoap/-/raw/debian/${version}-${debianRevision}/debian/patches/${name}.patch"; 28 - inherit hash; 29 - }; 30 - in map fetchDebianPatch [ 31 - # Merged upstream: f5f96210e1483f81cb5c582a6619e3ec4b473027 32 - { name = "Add-quotes-to-SOAPAction-header-in-SoapClient"; 33 - hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0="; } 34 - # Merged upstream: ad03a21cafab982eed321553c4bfcda1755182eb 35 - { name = "fix-httplib2-version-check"; 36 - hash = "sha256-zUeF3v0N/eMyRVRH3tQLfuUfMKOD/B/aqEwFh/7HxH4="; } 37 - { name = "reorder-type-check-to-avoid-a-TypeError"; 38 - hash = "sha256-2p5Cqvh0SPfJ8B38wb/xq7jWGYgpI9pavA6qkMUb6hA="; } 39 - # Merged upstream: 033e5899e131a2c1bdf7db5852f816f42aac9227 40 - { name = "Support-integer-values-in-maxOccurs-attribute"; 41 - hash = "sha256-IZ0DP7io+ihcnB5547cR53FAdnpRLR6z4J5KsNrkfaI="; } 42 - { name = "PR204"; 43 - hash = "sha256-JlxeTnKDFxvEMFBthZsaYRbNOoBvLJhBnXCRoiL/nVw="; } 44 - ] ++ [ ./stringIO.patch ]; 23 + patches = map (args: fetchDebianPatch ({ 24 + inherit pname version; 25 + debianRevision = "5"; 26 + } // args)) [ 27 + # Merged upstream: f5f96210e1483f81cb5c582a6619e3ec4b473027 28 + { patch = "Add-quotes-to-SOAPAction-header-in-SoapClient"; 29 + hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0="; } 30 + # Merged upstream: ad03a21cafab982eed321553c4bfcda1755182eb 31 + { patch = "fix-httplib2-version-check"; 32 + hash = "sha256-zUeF3v0N/eMyRVRH3tQLfuUfMKOD/B/aqEwFh/7HxH4="; } 33 + { patch = "reorder-type-check-to-avoid-a-TypeError"; 34 + hash = "sha256-2p5Cqvh0SPfJ8B38wb/xq7jWGYgpI9pavA6qkMUb6hA="; } 35 + # Merged upstream: 033e5899e131a2c1bdf7db5852f816f42aac9227 36 + { patch = "Support-integer-values-in-maxOccurs-attribute"; 37 + hash = "sha256-IZ0DP7io+ihcnB5547cR53FAdnpRLR6z4J5KsNrkfaI="; } 38 + { patch = "PR204"; 39 + hash = "sha256-JlxeTnKDFxvEMFBthZsaYRbNOoBvLJhBnXCRoiL/nVw="; } 40 + ] ++ [ ./stringIO.patch ]; 45 41 46 42 meta = with lib; { 47 43 description = "Python simple and lightweight SOAP Library";
+1
pkgs/test/default.nix
··· 35 35 fetchurl = callPackages ../build-support/fetchurl/tests.nix { }; 36 36 fetchpatch = callPackages ../build-support/fetchpatch/tests.nix { }; 37 37 fetchpatch2 = callPackages ../build-support/fetchpatch/tests.nix { fetchpatch = fetchpatch2; }; 38 + fetchDebianPatch = callPackages ../build-support/fetchdebianpatch/tests.nix { }; 38 39 fetchzip = callPackages ../build-support/fetchzip/tests.nix { }; 39 40 fetchgit = callPackages ../build-support/fetchgit/tests.nix { }; 40 41 fetchFirefoxAddon = callPackages ../build-support/fetchfirefoxaddon/tests.nix { };
+5
pkgs/top-level/all-packages.nix
··· 1175 1175 tests = pkgs.tests.fetchzip; 1176 1176 }; 1177 1177 1178 + fetchDebianPatch = callPackage ../build-support/fetchdebianpatch { } 1179 + // { 1180 + tests = pkgs.tests.fetchDebianPatch; 1181 + }; 1182 + 1178 1183 fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { }; 1179 1184 1180 1185 fetchFromGitea = callPackage ../build-support/fetchgitea { };