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.
This commit is contained in:
parent
1e806458dc
commit
7e8b3adb04
@ -4,8 +4,8 @@
|
|||||||
# often change with updating of git or cgit.
|
# often change with updating of git or cgit.
|
||||||
# stripLen acts as the -p parameter when applying a patch.
|
# stripLen acts as the -p parameter when applying a patch.
|
||||||
|
|
||||||
{ fetchurl, patchutils }:
|
{ lib, fetchurl, patchutils }:
|
||||||
{ stripLen ? 0, ... }@args:
|
{ stripLen ? 0, addPrefixes ? false, ... }@args:
|
||||||
|
|
||||||
fetchurl ({
|
fetchurl ({
|
||||||
postFetch = ''
|
postFetch = ''
|
||||||
@ -16,8 +16,12 @@ fetchurl ({
|
|||||||
"${patchutils}/bin/filterdiff" \
|
"${patchutils}/bin/filterdiff" \
|
||||||
--include={} \
|
--include={} \
|
||||||
--strip=${toString stripLen} \
|
--strip=${toString stripLen} \
|
||||||
|
${lib.optionalString addPrefixes ''
|
||||||
|
--addoldprefix=a/ \
|
||||||
|
--addnewprefix=b/ \
|
||||||
|
''} \
|
||||||
--clean "$out" > "$tmpfile"
|
--clean "$out" > "$tmpfile"
|
||||||
mv "$tmpfile" "$out"
|
mv "$tmpfile" "$out"
|
||||||
${args.postFetch or ""}
|
${args.postFetch or ""}
|
||||||
'';
|
'';
|
||||||
} // builtins.removeAttrs args ["stripLen"])
|
} // builtins.removeAttrs args ["stripLen" "addPrefixes"])
|
||||||
|
Loading…
Reference in New Issue
Block a user