fetchpatch: Add support for an arbitrary extra prefix

We still ensure the old and new ones start, respectfully, with `a/` and
`b/`. Use with `stripLen` to ensure tha the old `a/` and `/b` are gone
if a new prefix is added.
This commit is contained in:
John Ericson
2018-01-04 14:55:19 -05:00
parent 4dff3ee959
commit 9bd437d4b4
3 changed files with 10 additions and 10 deletions

View File

@@ -5,7 +5,7 @@
# stripLen acts as the -p parameter when applying a patch.
{ lib, fetchurl, patchutils }:
{ stripLen ? 0, addPrefixes ? false, excludes ? [], ... }@args:
{ stripLen ? 0, extraPrefix ? null, excludes ? [], ... }@args:
fetchurl ({
postFetch = ''
@@ -16,9 +16,9 @@ fetchurl ({
"${patchutils}/bin/filterdiff" \
--include={} \
--strip=${toString stripLen} \
${lib.optionalString addPrefixes ''
--addoldprefix=a/ \
--addnewprefix=b/ \
${lib.optionalString (extraPrefix != null) ''
--addoldprefix=a/${extraPrefix} \
--addnewprefix=b/${extraPrefix} \
''} \
--clean "$out" > "$tmpfile"
${patchutils}/bin/filterdiff \
@@ -27,4 +27,4 @@ fetchurl ({
"$tmpfile" > "$out"
${args.postFetch or ""}
'';
} // builtins.removeAttrs args ["stripLen" "addPrefixes" "excludes" "postFetch"])
} // builtins.removeAttrs args ["stripLen" "extraPrefix" "excludes" "postFetch"])