diff options
author | Franz Pletz <fpletz@fnordicwalking.de> | 2016-07-29 03:54:31 +0200 |
---|---|---|
committer | Franz Pletz <fpletz@fnordicwalking.de> | 2016-07-29 12:03:08 +0200 |
commit | 7e8b3adb044e9ae03d0c70db4f303696329be44e (patch) | |
tree | 4251499bc9c3d37ae8d0b50e36462d6d73ce0c83 /pkgs/build-support/fetchpatch | |
parent | 1e806458dc4fbca4d2c67e93f0933d4193b5666b (diff) | |
download | nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.tar nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.tar.gz nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.tar.bz2 nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.tar.lz nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.tar.xz nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.tar.zst nixpkgs-7e8b3adb044e9ae03d0c70db4f303696329be44e.zip |
fetchpatch: add addPrefixes argument
Sometimes patches start without a leading prefix. We default to strip one prefix or path component from patches (-p1) in the patchPhase in stdenv. As all patches should therefore be in this format, fetchpatch should have an option to normalize patch paths. This commit introduces a new argument to fetchpatch called addPrefixes that adds one patch prefix to the old and new paths in a patch before putting it into the store.
Diffstat (limited to 'pkgs/build-support/fetchpatch')
-rw-r--r-- | pkgs/build-support/fetchpatch/default.nix | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix index 60785f42b54..a6ddf132cd5 100644 --- a/pkgs/build-support/fetchpatch/default.nix +++ b/pkgs/build-support/fetchpatch/default.nix @@ -4,8 +4,8 @@ # often change with updating of git or cgit. # stripLen acts as the -p parameter when applying a patch. -{ fetchurl, patchutils }: -{ stripLen ? 0, ... }@args: +{ lib, fetchurl, patchutils }: +{ stripLen ? 0, addPrefixes ? false, ... }@args: fetchurl ({ postFetch = '' @@ -16,8 +16,12 @@ fetchurl ({ "${patchutils}/bin/filterdiff" \ --include={} \ --strip=${toString stripLen} \ + ${lib.optionalString addPrefixes '' + --addoldprefix=a/ \ + --addnewprefix=b/ \ + ''} \ --clean "$out" > "$tmpfile" mv "$tmpfile" "$out" ${args.postFetch or ""} ''; -} // builtins.removeAttrs args ["stripLen"]) +} // builtins.removeAttrs args ["stripLen" "addPrefixes"]) |