mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
fetchFromGitHub: Use .tar.gz instead of .zip
Also clean up the name attribute of fetchzip derivations a bit.
This commit is contained in:
parent
0d50061b4f
commit
ea36f3b868
@ -160,6 +160,16 @@ rec {
|
|||||||
else
|
else
|
||||||
s;
|
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.
|
# Return true iff string v1 denotes a version older than v2.
|
||||||
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
|
versionOlder = v1: v2: builtins.compareVersions v2 v1 == 1;
|
||||||
|
|
||||||
|
@ -54,9 +54,6 @@ in
|
|||||||
# first element of `urls').
|
# first element of `urls').
|
||||||
name ? ""
|
name ? ""
|
||||||
|
|
||||||
, # A string to be appended to the name, if the name is derived from `url'.
|
|
||||||
nameSuffix ? ""
|
|
||||||
|
|
||||||
# Different ways of specifying the hash.
|
# Different ways of specifying the hash.
|
||||||
, outputHash ? ""
|
, outputHash ? ""
|
||||||
, outputHashAlgo ? ""
|
, outputHashAlgo ? ""
|
||||||
@ -97,7 +94,7 @@ stdenv.mkDerivation {
|
|||||||
name =
|
name =
|
||||||
if showURLs then "urls"
|
if showURLs then "urls"
|
||||||
else if name != "" then name
|
else if name != "" then name
|
||||||
else baseNameOf (toString (builtins.head urls_)) + nameSuffix;
|
else baseNameOf (toString (builtins.head urls_));
|
||||||
|
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
|
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
# This function downloads and unpacks a zip file. This is primarily
|
# This function downloads and unpacks an archive file, such as a zip
|
||||||
# useful for dynamically generated zip files, such as GitHub's
|
# or tar file. This is primarily useful for dynamically generated
|
||||||
# /archive URLs, where the unpacked content of the zip file doesn't
|
# archives, such as GitHub's /archive URLs, where the unpacked content
|
||||||
# change, but the zip file itself may (e.g. due to minor changes in
|
# of the zip file doesn't change, but the zip file itself may
|
||||||
# the compression algorithm, or changes in timestamps).
|
# (e.g. due to minor changes in the compression algorithm, or changes
|
||||||
|
# in timestamps).
|
||||||
|
|
||||||
{ lib, fetchurl, unzip }:
|
{ lib, fetchurl, unzip }:
|
||||||
|
|
||||||
{ # Optionally move the contents of the unpacked tree up one level.
|
{ # Optionally move the contents of the unpacked tree up one level.
|
||||||
stripRoot ? true
|
stripRoot ? true
|
||||||
|
, url
|
||||||
, ... } @ args:
|
, ... } @ args:
|
||||||
|
|
||||||
fetchurl (args // {
|
fetchurl ({
|
||||||
# Apply a suffix to the name. Otherwise, unpackPhase will get
|
# Remove the extension, because otherwise unpackPhase will get
|
||||||
# confused by the .zip extension.
|
# confused. FIXME: fix unpackPhase.
|
||||||
nameSuffix = "-unpacked";
|
name = args.name or lib.removeSuffix ".zip" (lib.removeSuffix ".tar.gz" (baseNameOf url));
|
||||||
|
|
||||||
recursiveHash = true;
|
recursiveHash = true;
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ fetchurl (args // {
|
|||||||
export PATH=${unzip}/bin:$PATH
|
export PATH=${unzip}/bin:$PATH
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cd $out
|
cd $out
|
||||||
renamed="$TMPDIR/''${name%-unpacked}"
|
renamed="$TMPDIR/${baseNameOf url}"
|
||||||
mv "$downloadedFile" "$renamed"
|
mv "$downloadedFile" "$renamed"
|
||||||
unpackFile "$renamed"
|
unpackFile "$renamed"
|
||||||
''
|
''
|
||||||
@ -39,4 +41,4 @@ fetchurl (args // {
|
|||||||
mv $out/$fn/* "$out/"
|
mv $out/$fn/* "$out/"
|
||||||
rmdir "$out/$fn"
|
rmdir "$out/$fn"
|
||||||
'';
|
'';
|
||||||
})
|
} // args)
|
||||||
|
@ -341,7 +341,8 @@ let
|
|||||||
fetchzip = import ../build-support/fetchzip { inherit lib fetchurl unzip; };
|
fetchzip = import ../build-support/fetchzip { inherit lib fetchurl unzip; };
|
||||||
|
|
||||||
fetchFromGitHub = { owner, repo, rev, sha256 }: fetchzip {
|
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;
|
inherit sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user