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

View File

@ -21,13 +21,13 @@ stdenv.mkDerivation rec {
name = "siginfo.patch"; name = "siginfo.patch";
url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/siginfo.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa"; url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/siginfo.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
sha256 = "15zldbm33yba293dgrgsbv3j332hkc3iqpyc8fa7zl42mh9qk22j"; sha256 = "15zldbm33yba293dgrgsbv3j332hkc3iqpyc8fa7zl42mh9qk22j";
addPrefixes = true; extraPrefix = "";
}) })
(fetchpatch { (fetchpatch {
name = "gcc-3.4.3-no_multilib_amd64.patch"; name = "gcc-3.4.3-no_multilib_amd64.patch";
url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/gcc-3.4.3-no_multilib_amd64.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa"; url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/gcc-3.4.3-no_multilib_amd64.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
sha256 = "11m5lc51b0addhc4yq4rz0dwpv6k73rrj73wya3lqdk8rly6cjpm"; sha256 = "11m5lc51b0addhc4yq4rz0dwpv6k73rrj73wya3lqdk8rly6cjpm";
addPrefixes = true; extraPrefix = "";
}) })
# Required because of glibc 2.26 # Required because of glibc 2.26
./struct-ucontext.patch ./struct-ucontext.patch

View File

@ -20,21 +20,21 @@ stdenv.mkDerivation rec {
url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_ucd.c?view=patch&r1=316&r2=670&sortby=date"; url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_ucd.c?view=patch&r1=316&r2=670&sortby=date";
sha256 = "10yzglvbn7h06hg7zffr5zh378i5jihvx7d5gggkynws79vgwvfr"; sha256 = "10yzglvbn7h06hg7zffr5zh378i5jihvx7d5gggkynws79vgwvfr";
stripLen = 2; stripLen = 2;
addPrefixes = true; extraPrefix = "";
}) })
(fetchpatch { (fetchpatch {
name = "CVE-2017-7186-part2.patch"; name = "CVE-2017-7186-part2.patch";
url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_internal.h?view=patch&r1=600&r2=670&sortby=date"; url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2_internal.h?view=patch&r1=600&r2=670&sortby=date";
sha256 = "1bggk7vd5hg0bjg96lj4h1lacmr6grq68dm6iz1n7vg3zf7virjn"; sha256 = "1bggk7vd5hg0bjg96lj4h1lacmr6grq68dm6iz1n7vg3zf7virjn";
stripLen = 2; stripLen = 2;
addPrefixes = true; extraPrefix = "";
}) })
(fetchpatch { (fetchpatch {
name = "CVE-2017-8786.patch"; name = "CVE-2017-8786.patch";
url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2test.c?r1=692&r2=697&view=patch"; url = "https://vcs.pcre.org/pcre2/code/trunk/src/pcre2test.c?r1=692&r2=697&view=patch";
sha256 = "1c629nzrk4il2rfclwyc1a373q58m4q9ys9wr91zhl4skfk7x19b"; sha256 = "1c629nzrk4il2rfclwyc1a373q58m4q9ys9wr91zhl4skfk7x19b";
stripLen = 2; stripLen = 2;
addPrefixes = true; extraPrefix = "";
}) })
]; ];