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:
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user