git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #83408 from NixOS/revert-79581-feature/fetcher-whitespace-clean

Revert "fetchzip, fetchgit: cleanup handling of optional features and whitespace"

commit33f0805fe086ab309f9d3bebc31522fc13881825 authorBenjamin Hipple <bhipple@protonmail.com> dateThu 26 Mar 2020, 00:37 (7 years ago) parenta0c0ae3259f3b3
3 files changed+43−41
pkgs/build-support/fetchgit/default.nix+1−1 pkgs/build-support/fetchgit/nix-prefetch-git+13−12 pkgs/build-support/fetchzip/default.nix+29−28
pkgs/build-support/fetchgit/default.nix+1−1
@@ -1,4 +1,4 @@
1−{ stdenvNoCC, git, cacert }: let
1+{stdenvNoCC, git, cacert}: let
22 urlToName = url: rev: let
33 inherit (stdenvNoCC.lib) removeSuffix splitString last;
44 base = last (splitString ":" (baseNameOf (removeSuffix "/" url)));
pkgs/build-support/fetchgit/nix-prefetch-git+13−12
@@ -1,5 +1,6 @@
1−#!/usr/bin/env bash
2−set -eo pipefail
1+#! /usr/bin/env bash
2+
3+set -e -o pipefail
34
45url=
56rev=
@@ -37,17 +38,17 @@ usage(){
3738 echo >&2 "syntax: nix-prefetch-git [options] [URL [REVISION [EXPECTED-HASH]]]
3839
3940Options:
40− --out path Path where the output would be stored.
41− --url url Any url understood by 'git clone'.
42− --rev ref Any sha1 or references (such as refs/heads/master).
43− --hash h Expected hash.
44− --branch-name Branch name to check out into.
45− --deepClone Clone the entire repository.
46− --no-deepClone Make a shallow clone of just the required ref.
47− --leave-dotGit Keep the .git directories.
41+ --out path Path where the output would be stored.
42+ --url url Any url understood by 'git clone'.
43+ --rev ref Any sha1 or references (such as refs/heads/master)
44+ --hash h Expected hash.
45+ --branch-name Branch name to check out into
46+ --deepClone Clone the entire repository.
47+ --no-deepClone Make a shallow clone of just the required ref.
48+ --leave-dotGit Keep the .git directories.
4849 --fetch-submodules Fetch submodules.
49− --builder Clone as fetchgit does, but url, rev, and out option are mandatory.
50− --quiet Only print the final json summary.
50+ --builder Clone as fetchgit does, but url, rev, and out option are mandatory.
51+ --quiet Only print the final json summary.
5152"
5253 exit 1
5354}
pkgs/build-support/fetchzip/default.nix+29−28
@@ -5,46 +5,47 @@
55# (e.g. due to minor changes in the compression algorithm, or changes
66# in timestamps).
77
8−{ lib, fetchurl, unzip }:
8+{ fetchurl, unzip }:
99
10−{ name ? "source"
10+{ # Optionally move the contents of the unpacked tree up one level.
11+ stripRoot ? true
1112, url
12− # Optionally move the contents of the unpacked tree up one level.
13−, stripRoot ? true
1413, extraPostFetch ? ""
14+, name ? "source"
1515, ... } @ args:
1616
1717(fetchurl ({
1818 inherit name;
1919
2020 recursiveHash = true;
21− downloadToTemp = true;
2221
23− postFetch = ''
24− unpackDir="$TMPDIR/unpack"
25− mkdir "$unpackDir"
26− cd "$unpackDir"
22+ downloadToTemp = true;
2723
28− renamed="$TMPDIR/${baseNameOf url}"
29− mv "$downloadedFile" "$renamed"
30− unpackFile "$renamed"
31− result=$unpackDir
32− ''
33− # Most src disted tarballs have a parent directory like foo-1.2.3/ to strip
34− + lib.optionalString stripRoot ''
35− if [ $(ls "$unpackDir" | wc -l) != 1 ]; then
36− echo "error: zip file must contain a single file or directory."
37− echo "hint: Pass stripRoot=false; to fetchzip to assume flat list of files."
38− exit 1
39− fi
40− fn=$(cd "$unpackDir" && echo *)
41− result="$unpackDir/$fn"
42− '' + ''
43− mkdir $out
44− mv "$result" "$out"
45− ''
46− + extraPostFetch;
24+ postFetch =
25+ ''
26+ unpackDir="$TMPDIR/unpack"
27+ mkdir "$unpackDir"
28+ cd "$unpackDir"
4729
30+ renamed="$TMPDIR/${baseNameOf url}"
31+ mv "$downloadedFile" "$renamed"
32+ unpackFile "$renamed"
33+ ''
34+ + (if stripRoot then ''
35+ if [ $(ls "$unpackDir" | wc -l) != 1 ]; then
36+ echo "error: zip file must contain a single file or directory."
37+ echo "hint: Pass stripRoot=false; to fetchzip to assume flat list of files."
38+ exit 1
39+ fi
40+ fn=$(cd "$unpackDir" && echo *)
41+ if [ -f "$unpackDir/$fn" ]; then
42+ mkdir $out
43+ fi
44+ mv "$unpackDir/$fn" "$out"
45+ '' else ''
46+ mv "$unpackDir" "$out"
47+ '') #*/
48+ + extraPostFetch;
4849} // removeAttrs args [ "stripRoot" "extraPostFetch" ])).overrideAttrs (x: {
4950 # Hackety-hack: we actually need unzip hooks, too
5051 nativeBuildInputs = x.nativeBuildInputs ++ [ unzip ];