diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2014-05-17 07:27:29 +0200 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2014-05-17 07:31:03 +0200 |
commit | 137eae0b55949bcfd6a2f4ba12964db8bdfae954 (patch) | |
tree | 66dd96bbf6ea56cd007e9900b1cacf39a18743cb /pkgs/build-support/fetchpatch | |
parent | 4ac818601e5b38c2be4add23a2932810f977210b (diff) | |
download | nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.tar nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.tar.gz nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.tar.bz2 nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.tar.lz nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.tar.xz nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.tar.zst nixpkgs-137eae0b55949bcfd6a2f4ba12964db8bdfae954.zip |
Merge #2630: add and use fetchpatch
fetchpatch is fetchurl that determinizes the patch. Some parts of generated patches change from time to time, e.g. see #1983 and http://comments.gmane.org/gmane.linux.distributions.nixos/12815 Using fetchpatch should prevent the hash from changing. Conflicts (auto-solved): pkgs/development/libraries/haskell/gitit/default.nix
Diffstat (limited to 'pkgs/build-support/fetchpatch')
-rw-r--r-- | pkgs/build-support/fetchpatch/default.nix | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix new file mode 100644 index 00000000000..768d173934d --- /dev/null +++ b/pkgs/build-support/fetchpatch/default.nix @@ -0,0 +1,22 @@ +# This function downloads and normalizes a patch/diff file. +# This is primarily useful for dynamically generated patches, +# such as GitHub's or cgit's, where the non-significant content parts +# often change with updating of git or cgit. +# stripLen acts as the -p parameter when applying a patch. + +{ fetchurl, patchutils }: +{ stripLen ? 0, ... }@args: + +fetchurl ({ + postFetch = '' + tmpfile="$TMPDIR/${args.sha256}" + "${patchutils}/bin/lsdiff" "$out" \ + | sort -u | sed -e 's/[*?]/\\&/g' \ + | xargs -I{} \ + "${patchutils}/bin/filterdiff" \ + --include={} \ + --strip=${toString stripLen} \ + --clean "$out" > "$tmpfile" + mv "$tmpfile" "$out" + ''; +} // args) |