at v206 764 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{ fetchurl, patchutils }: 8{ stripLen ? 0, ... }@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 --clean "$out" > "$tmpfile" 20 mv "$tmpfile" "$out" 21 ${args.postFetch or ""} 22 ''; 23} // builtins.removeAttrs args ["stripLen"])