3
0
Fork 0
forked from mirrors/nixpkgs

fetchFromGitHub: Use .tar.gz instead of .zip

Also clean up the name attribute of fetchzip derivations a bit.
This commit is contained in:
Eelco Dolstra 2014-05-09 15:50:40 +02:00
parent 0d50061b4f
commit ea36f3b868
4 changed files with 26 additions and 16 deletions

View file

@ -160,6 +160,16 @@ rec {
else
s;
removeSuffix = suf: s:
let
sufLen = stringLength suf;
sLen = stringLength s;
in
if sufLen <= sLen && suf == substring (sLen - sufLen) sufLen s then
substring 0 (sLen - sufLen) s
else
s;
# Return true iff string v1 denotes a version older than v2.
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;

View file

@ -54,9 +54,6 @@ in
# first element of `urls').
name ? ""
, # A string to be appended to the name, if the name is derived from `url'.
nameSuffix ? ""
# Different ways of specifying the hash.
, outputHash ? ""
, outputHashAlgo ? ""
@ -97,7 +94,7 @@ stdenv.mkDerivation {
name =
if showURLs then "urls"
else if name != "" then name
else baseNameOf (toString (builtins.head urls_)) + nameSuffix;
else baseNameOf (toString (builtins.head urls_));
builder = ./builder.sh;

View file

@ -1,19 +1,21 @@
# This function downloads and unpacks a zip file. This is primarily
# useful for dynamically generated zip files, such as GitHub's
# /archive URLs, where the unpacked content of the zip file doesn't
# change, but the zip file itself may (e.g. due to minor changes in
# the compression algorithm, or changes in timestamps).
# This function downloads and unpacks an archive file, such as a zip
# or tar file. This is primarily useful for dynamically generated
# archives, such as GitHub's /archive URLs, where the unpacked content
# of the zip file doesn't change, but the zip file itself may
# (e.g. due to minor changes in the compression algorithm, or changes
# in timestamps).
{ lib, fetchurl, unzip }:
{ # Optionally move the contents of the unpacked tree up one level.
stripRoot ? true
, url
, ... } @ args:
fetchurl (args // {
# Apply a suffix to the name. Otherwise, unpackPhase will get
# confused by the .zip extension.
nameSuffix = "-unpacked";
fetchurl ({
# Remove the extension, because otherwise unpackPhase will get
# confused. FIXME: fix unpackPhase.
name = args.name or lib.removeSuffix ".zip" (lib.removeSuffix ".tar.gz" (baseNameOf url));
recursiveHash = true;
@ -24,7 +26,7 @@ fetchurl (args // {
export PATH=${unzip}/bin:$PATH
mkdir $out
cd $out
renamed="$TMPDIR/''${name%-unpacked}"
renamed="$TMPDIR/${baseNameOf url}"
mv "$downloadedFile" "$renamed"
unpackFile "$renamed"
''
@ -39,4 +41,4 @@ fetchurl (args // {
mv $out/$fn/* "$out/"
rmdir "$out/$fn"
'';
})
} // args)

View file

@ -341,7 +341,8 @@ let
fetchzip = import ../build-support/fetchzip { inherit lib fetchurl unzip; };
fetchFromGitHub = { owner, repo, rev, sha256 }: fetchzip {
url = "https://github.com/${owner}/${repo}/archive/${rev}.zip";
name = "${repo}-${rev}-src";
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
inherit sha256;
};