Unverified Commit edfb1866 authored by Maciej Krüger's avatar Maciej Krüger Committed by GitHub
Browse files

Merge pull request #252225 from nbraud/fetchDebianPatch

parents 50ac3d55 76aedfaa
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -82,6 +82,53 @@ Note that because the checksum is computed after applying these effects, using o

Most other fetchers return a directory rather than a single file.


## `fetchDebianPatch` {#fetchdebianpatch}

A wrapper around `fetchpatch`, which takes:
- `patch` and `hash`: the patch's filename without the `.patch` suffix,
  and its hash after normalization by `fetchpatch` ;
- `pname`: the Debian source package's name ;
- `version`: the upstream version number ;
- `debianRevision`: the [Debian revision number] if applicable ;
- the `area` of the Debian archive: `main` (default), `contrib`, or `non-free`.

Here is an example of `fetchDebianPatch` in action:

```nix
{ lib
, fetchDebianPatch
, buildPythonPackage
}:

buildPythonPackage rec {
  pname = "pysimplesoap";
  version = "1.16.2";
  src = ...;

  patches = [
    (fetchDebianPatch {
      inherit pname version;
      debianRevision = "5";
      name = "Add-quotes-to-SOAPAction-header-in-SoapClient";
      hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0=";
    })
  ];

  ...
}
```

Patches are fetched from `sources.debian.org`, and so must come from a
package version that was uploaded to the Debian archive.  Packages may
be removed from there once that specific version isn't in any suite
anymore (stable, testing, unstable, etc.), so maintainers should use
`copy-tarballs.pl` to archive the patch if it needs to be available
longer-term.

[Debian revision number]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version


## `fetchsvn` {#fetchsvn}

Used with Subversion. Expects `url` to a Subversion directory, `rev`, and `hash`.
+19 −0
Original line number Diff line number Diff line
{ lib, fetchpatch }:

lib.makeOverridable (
  { pname, version, debianRevision ? null, patch, hash,
    area ? "main", name ? "${patch}.patch" }:
  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}/${prefix}/"
      + "${pname}/${versionString}/debian/patches/${patch}.patch";
  }
)
+19 −0
Original line number Diff line number Diff line
{ testers, fetchDebianPatch, ... }:

{
  simple = testers.invalidateFetcherByDrvHash fetchDebianPatch {
    pname = "pysimplesoap";
    version = "1.16.2";
    debianRevision = "5";
    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=";
  };
}
+19 −23
Original line number Diff line number Diff line
{ lib
, fetchpatch
, fetchDebianPatch
, fetchPypi
, buildPythonPackage
, m2crypto
@@ -20,26 +20,22 @@ buildPythonPackage rec {
    m2crypto
  ];

  patches =
    let
      debianRevision = "5";  # The Debian package revision we get patches from
      fetchDebianPatch = { name, hash }: fetchpatch {
        url = "https://salsa.debian.org/python-team/packages/pysimplesoap/-/raw/debian/${version}-${debianRevision}/debian/patches/${name}.patch";
        inherit hash;
      };
    in map fetchDebianPatch [
  patches = map (args: fetchDebianPatch ({
    inherit pname version;
    debianRevision = "5";
  } // args)) [
    # Merged upstream: f5f96210e1483f81cb5c582a6619e3ec4b473027
      { name = "Add-quotes-to-SOAPAction-header-in-SoapClient";
    { patch = "Add-quotes-to-SOAPAction-header-in-SoapClient";
      hash = "sha256-xA8Wnrpr31H8wy3zHSNfezFNjUJt1HbSXn3qUMzeKc0="; }
    # Merged upstream: ad03a21cafab982eed321553c4bfcda1755182eb
      { name = "fix-httplib2-version-check";
    { patch = "fix-httplib2-version-check";
      hash = "sha256-zUeF3v0N/eMyRVRH3tQLfuUfMKOD/B/aqEwFh/7HxH4="; }
      { name = "reorder-type-check-to-avoid-a-TypeError";
    { patch = "reorder-type-check-to-avoid-a-TypeError";
      hash = "sha256-2p5Cqvh0SPfJ8B38wb/xq7jWGYgpI9pavA6qkMUb6hA="; }
    # Merged upstream: 033e5899e131a2c1bdf7db5852f816f42aac9227
      { name = "Support-integer-values-in-maxOccurs-attribute";
    { patch = "Support-integer-values-in-maxOccurs-attribute";
      hash = "sha256-IZ0DP7io+ihcnB5547cR53FAdnpRLR6z4J5KsNrkfaI="; }
      { name = "PR204";
    { patch = "PR204";
      hash = "sha256-JlxeTnKDFxvEMFBthZsaYRbNOoBvLJhBnXCRoiL/nVw="; }
  ] ++ [ ./stringIO.patch ];

+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ with pkgs;
  fetchurl = callPackages ../build-support/fetchurl/tests.nix { };
  fetchpatch = callPackages ../build-support/fetchpatch/tests.nix { };
  fetchpatch2 = callPackages ../build-support/fetchpatch/tests.nix { fetchpatch = fetchpatch2; };
  fetchDebianPatch = callPackages ../build-support/fetchdebianpatch/tests.nix { };
  fetchzip = callPackages ../build-support/fetchzip/tests.nix { };
  fetchgit = callPackages ../build-support/fetchgit/tests.nix { };
  fetchFirefoxAddon = callPackages ../build-support/fetchfirefoxaddon/tests.nix { };
Loading