at 16.09-beta 27 lines 924 B view raw
1# This function downloads and normalizes a patch/diff file. 2# This is primarily useful for dynamically generated patches, 3# such as GitHub's or cgit's, where the non-significant content parts 4# often change with updating of git or cgit. 5# stripLen acts as the -p parameter when applying a patch. 6 7{ lib, fetchurl, patchutils }: 8{ stripLen ? 0, addPrefixes ? false, ... }@args: 9 10fetchurl ({ 11 postFetch = '' 12 tmpfile="$TMPDIR/${args.sha256}" 13 "${patchutils}/bin/lsdiff" "$out" \ 14 | sort -u | sed -e 's/[*?]/\\&/g' \ 15 | xargs -I{} \ 16 "${patchutils}/bin/filterdiff" \ 17 --include={} \ 18 --strip=${toString stripLen} \ 19 ${lib.optionalString addPrefixes '' 20 --addoldprefix=a/ \ 21 --addnewprefix=b/ \ 22 ''} \ 23 --clean "$out" > "$tmpfile" 24 mv "$tmpfile" "$out" 25 ${args.postFetch or ""} 26 ''; 27} // builtins.removeAttrs args ["stripLen" "addPrefixes"])