Unverified Commit 18b00682 authored by Artturin's avatar Artturin Committed by GitHub
Browse files

Merge pull request #323824 from tie/fetchpatch-build-inputs

fetchpatch: add patchutils to nativeBuildInputs
parents ae784887 6ed79156
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
, includes ? []
, revert ? false
, postFetch ? ""
, nativeBuildInputs ? []
, ...
}@args:
let
@@ -29,6 +30,7 @@ in
lib.throwIfNot (excludes == [] || includes == [])
  "fetchpatch: cannot use excludes and includes simultaneously"
fetchurl ({
  nativeBuildInputs = [ patchutils ] ++ nativeBuildInputs;
  postFetch = ''
    tmpfile="$TMPDIR/patch"

@@ -48,12 +50,12 @@ fetchurl ({
    set -e
    mv "$tmpfile" "$out"

    "${patchutils}/bin/lsdiff" \
    lsdiff \
      ${lib.optionalString (relative != null) "-p1 -i ${lib.escapeShellArg relative}/'*'"} \
      "$out" \
    | sort -u | sed -e 's/[*?]/\\&/g' \
    | xargs -I{} \
      "${patchutils}/bin/filterdiff" \
      filterdiff \
      --include={} \
      --strip=${toString stripLen} \
      ${lib.optionalString (extraPrefix != null) ''
@@ -70,7 +72,7 @@ fetchurl ({
      exit 1
    fi

    ${patchutils}/bin/filterdiff \
    filterdiff \
      -p1 \
      ${builtins.toString (builtins.map (x: "-x ${lib.escapeShellArg x}") excludes)} \
      ${builtins.toString (builtins.map (x: "-i ${lib.escapeShellArg x}") includes)} \
@@ -84,10 +86,10 @@ fetchurl ({
      exit 1
    fi
  '' + lib.optionalString revert ''
    ${patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile"
    interdiff "$out" /dev/null > "$tmpfile"
    mv "$tmpfile" "$out"
  '' + postFetch;
} // builtins.removeAttrs args [
  "relative" "stripLen" "decode" "extraPrefix" "excludes" "includes" "revert"
  "postFetch"
  "postFetch" "nativeBuildInputs"
])
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ in
{
  simple = testers.invalidateFetcherByDrvHash fetchpatch {
    url = "https://github.com/facebook/zstd/pull/2724/commits/e1f85dbca3a0ed5ef06c8396912a0914db8dea6a.patch";
    sha256 = if isFetchpatch2 then "sha256-01BrkHLye4KOdqCw3tv7AJzIF6578pl2fl270TJFTmw=" else "sha256-PuYAqnJWAE+L9bsroOnnBGJhERW8LHrGSLtIEkKU9vg=";
    sha256 = if isFetchpatch2 then "sha256-w4yU0wt64d0WkuBQPeGf8vn5TH6qSBJvNIgka9QK+/Q=" else "sha256-PuYAqnJWAE+L9bsroOnnBGJhERW8LHrGSLtIEkKU9vg=";
  };

  relative = testers.invalidateFetcherByDrvHash fetchpatch {
+2 −2
Original line number Diff line number Diff line
@@ -1075,14 +1075,14 @@ with pkgs;
  fetchpatch = callPackage ../build-support/fetchpatch {
    # 0.3.4 would change hashes: https://github.com/NixOS/nixpkgs/issues/25154
    patchutils = buildPackages.patchutils_0_3_3;
    patchutils = __splicedPackages.patchutils_0_3_3;
  } // {
    tests = pkgs.tests.fetchpatch;
    version = 1;
  };
  fetchpatch2 = callPackage ../build-support/fetchpatch {
    patchutils = buildPackages.patchutils_0_4_2;
    patchutils = __splicedPackages.patchutils_0_4_2;
  } // {
    tests = pkgs.tests.fetchpatch2;
    version = 2;