mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 06:45:16 +01:00
* 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
3 changed files with 24 additions and 3 deletions
|
@ -1,6 +1,9 @@
|
|||
source $stdenv/setup
|
||||
|
||||
header "downloading file $name with $outputHashAlgo hash $outputHash..."
|
||||
if test -n "$showURLs"; then
|
||||
header "downloading file $name with $outputHashAlgo hash $outputHash..."
|
||||
fi
|
||||
|
||||
|
||||
# Curl flags to handle redirects, not use EPSV, handle cookies for
|
||||
# servers to need them during redirects, and work on SSL without a
|
||||
|
@ -98,6 +101,12 @@ done
|
|||
urls="$urls2"
|
||||
|
||||
|
||||
if test -n "$showURLs"; then
|
||||
echo "$urls" > $out
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
if test -n "$preferHashedMirrors"; then
|
||||
tryHashedMirrors
|
||||
fi
|
||||
|
|
|
@ -20,12 +20,16 @@
|
|||
, md5 ? ""
|
||||
, sha1 ? ""
|
||||
, 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 url != "" -> urls == [];
|
||||
|
||||
assert (outputHash != "" && outputHashAlgo != "")
|
||||
assert showURLs || (outputHash != "" && outputHashAlgo != "")
|
||||
|| md5 != "" || sha1 != "" || sha256 != "";
|
||||
|
||||
let
|
||||
|
@ -45,7 +49,8 @@ in
|
|||
|
||||
stdenv.mkDerivation ({
|
||||
name =
|
||||
if name != "" then name
|
||||
if showURLs then "urls"
|
||||
else if name != "" then name
|
||||
else baseNameOf (toString (builtins.head urls_));
|
||||
builder = ./builder.sh;
|
||||
buildInputs = [curl];
|
||||
|
@ -76,6 +81,8 @@ stdenv.mkDerivation ({
|
|||
# command-line.
|
||||
"NIX_HASHED_MIRRORS"
|
||||
] ++ (map (site: "NIX_MIRRORS_${site}") sites);
|
||||
|
||||
inherit showURLs;
|
||||
}
|
||||
|
||||
# Pass the mirror locations to the builder.
|
||||
|
|
|
@ -337,6 +337,11 @@ let pkgs = rec {
|
|||
# linked curl in the case of stdenv-linux).
|
||||
fetchurlBoot = stdenv.fetchurlBoot;
|
||||
|
||||
resolveMirrorURLs = {url}: fetchurl {
|
||||
showURLs = true;
|
||||
inherit url;
|
||||
};
|
||||
|
||||
makeInitrd = {contents}: import ../build-support/kernel/make-initrd.nix {
|
||||
inherit stdenv perl cpio contents;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue