* Interface to support mirror:// in nix-prefetch-url. The function
resolveMirrorURLs produces a file containing the URLs to which a mirror:// URL resolves. svn path=/nixpkgs/trunk/; revision=12410
This commit is contained in:
parent
839eb46cda
commit
a7c209e474
@ -1,6 +1,9 @@
|
|||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
|
|
||||||
|
if test -n "$showURLs"; then
|
||||||
header "downloading file $name with $outputHashAlgo hash $outputHash..."
|
header "downloading file $name with $outputHashAlgo hash $outputHash..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Curl flags to handle redirects, not use EPSV, handle cookies for
|
# Curl flags to handle redirects, not use EPSV, handle cookies for
|
||||||
# servers to need them during redirects, and work on SSL without a
|
# servers to need them during redirects, and work on SSL without a
|
||||||
@ -98,6 +101,12 @@ done
|
|||||||
urls="$urls2"
|
urls="$urls2"
|
||||||
|
|
||||||
|
|
||||||
|
if test -n "$showURLs"; then
|
||||||
|
echo "$urls" > $out
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if test -n "$preferHashedMirrors"; then
|
if test -n "$preferHashedMirrors"; then
|
||||||
tryHashedMirrors
|
tryHashedMirrors
|
||||||
fi
|
fi
|
||||||
|
@ -20,12 +20,16 @@
|
|||||||
, md5 ? ""
|
, md5 ? ""
|
||||||
, sha1 ? ""
|
, sha1 ? ""
|
||||||
, sha256 ? ""
|
, sha256 ? ""
|
||||||
|
|
||||||
|
, # If set, don't download the file, but write a list of all possible
|
||||||
|
# URLs (resulting from resolving mirror:// URLs) to $out.
|
||||||
|
showURLs ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert urls != [] -> url == "";
|
assert urls != [] -> url == "";
|
||||||
assert url != "" -> urls == [];
|
assert url != "" -> urls == [];
|
||||||
|
|
||||||
assert (outputHash != "" && outputHashAlgo != "")
|
assert showURLs || (outputHash != "" && outputHashAlgo != "")
|
||||||
|| md5 != "" || sha1 != "" || sha256 != "";
|
|| md5 != "" || sha1 != "" || sha256 != "";
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -45,7 +49,8 @@ in
|
|||||||
|
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
name =
|
name =
|
||||||
if name != "" then name
|
if showURLs then "urls"
|
||||||
|
else if name != "" then name
|
||||||
else baseNameOf (toString (builtins.head urls_));
|
else baseNameOf (toString (builtins.head urls_));
|
||||||
builder = ./builder.sh;
|
builder = ./builder.sh;
|
||||||
buildInputs = [curl];
|
buildInputs = [curl];
|
||||||
@ -76,6 +81,8 @@ stdenv.mkDerivation ({
|
|||||||
# command-line.
|
# command-line.
|
||||||
"NIX_HASHED_MIRRORS"
|
"NIX_HASHED_MIRRORS"
|
||||||
] ++ (map (site: "NIX_MIRRORS_${site}") sites);
|
] ++ (map (site: "NIX_MIRRORS_${site}") sites);
|
||||||
|
|
||||||
|
inherit showURLs;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pass the mirror locations to the builder.
|
# Pass the mirror locations to the builder.
|
||||||
|
@ -337,6 +337,11 @@ let pkgs = rec {
|
|||||||
# linked curl in the case of stdenv-linux).
|
# linked curl in the case of stdenv-linux).
|
||||||
fetchurlBoot = stdenv.fetchurlBoot;
|
fetchurlBoot = stdenv.fetchurlBoot;
|
||||||
|
|
||||||
|
resolveMirrorURLs = {url}: fetchurl {
|
||||||
|
showURLs = true;
|
||||||
|
inherit url;
|
||||||
|
};
|
||||||
|
|
||||||
makeInitrd = {contents}: import ../build-support/kernel/make-initrd.nix {
|
makeInitrd = {contents}: import ../build-support/kernel/make-initrd.nix {
|
||||||
inherit stdenv perl cpio contents;
|
inherit stdenv perl cpio contents;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user