diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-07-02 14:58:42 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-03-11 21:39:29 +0000 |
commit | dd6e94f2c1ae61633c69c6416c9da9d9853015ca (patch) | |
tree | c70bf7bdc227b3f17cf5829ac7ab6e0856cb8144 /pkgs/build-support/fetchpatch/default.nix | |
parent | d4f33014402bcf61c030070e8c59fc5d0a2c1a8f (diff) |
fetchpatch: add "decode" argument for gerrit
(and gitiles) This allows fetching a patch from servers that return them base64-encoded, like this: fetchpatch { name = "gcc.patch"; url = "https://chromium.googlesource.com/aosp/platform/external/libchrome/+/f37ae3b1a873d74182a2ac31d96742ead9c1f523^!?format=TEXT"; decode = "base64 -d"; sha256 = "11j1bqz2p8xrfzgfrylgdvmqs45489c4ckl7l0ra1dpfgbqy94a8"; }
Diffstat (limited to 'pkgs/build-support/fetchpatch/default.nix')
-rw-r--r-- | pkgs/build-support/fetchpatch/default.nix | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix index d059715cedc1e..a3ca6685147d3 100644 --- a/pkgs/build-support/fetchpatch/default.nix +++ b/pkgs/build-support/fetchpatch/default.nix @@ -8,6 +8,7 @@ { relative ? null , stripLen ? 0 +, decode ? "cat" # custom command to decode patch e.g. base64 -d , extraPrefix ? null , excludes ? [] , includes ? [] @@ -36,6 +37,17 @@ fetchurl ({ exit 1 fi + set +e + ${decode} < "$out" > "$tmpfile" + if [ $? -ne 0 ] || [ ! -s "$tmpfile" ]; then + echo 'Failed to decode patch with command "'${lib.escapeShellArg decode}'"' >&2 + echo 'Fetched file was (limited to 128 bytes):' >&2 + od -A x -t x1z -v -N 128 "$out" >&2 + exit 1 + fi + set -e + mv "$tmpfile" "$out" + "${patchutils}/bin/lsdiff" \ ${lib.optionalString (relative != null) "-p1 -i ${lib.escapeShellArg relative}/'*'"} \ "$out" \ @@ -76,5 +88,6 @@ fetchurl ({ mv "$tmpfile" "$out" '' + postFetch; } // builtins.removeAttrs args [ - "relative" "stripLen" "extraPrefix" "excludes" "includes" "revert" "postFetch" + "relative" "stripLen" "decode" "extraPrefix" "excludes" "includes" "revert" + "postFetch" ]) |