summary refs log tree commit diff
path: root/pkgs/build-support/fetchurl
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-07-23 16:04:10 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-07-23 16:04:10 +0000
commita7c209e474c6d63bc959890535747a34da10291d (patch)
tree538c1e55cf7392ec88a3d2ba6f1e722f4f5aacce /pkgs/build-support/fetchurl
parent839eb46cda51027abe9f667e3574263f607f36fb (diff)
downloadnixlib-a7c209e474c6d63bc959890535747a34da10291d.tar
nixlib-a7c209e474c6d63bc959890535747a34da10291d.tar.gz
nixlib-a7c209e474c6d63bc959890535747a34da10291d.tar.bz2
nixlib-a7c209e474c6d63bc959890535747a34da10291d.tar.lz
nixlib-a7c209e474c6d63bc959890535747a34da10291d.tar.xz
nixlib-a7c209e474c6d63bc959890535747a34da10291d.tar.zst
nixlib-a7c209e474c6d63bc959890535747a34da10291d.zip
* 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
Diffstat (limited to 'pkgs/build-support/fetchurl')
-rw-r--r--pkgs/build-support/fetchurl/builder.sh11
-rw-r--r--pkgs/build-support/fetchurl/default.nix11
2 files changed, 19 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchurl/builder.sh b/pkgs/build-support/fetchurl/builder.sh
index 53af63092f40..bfa57143b4b7 100644
--- a/pkgs/build-support/fetchurl/builder.sh
+++ b/pkgs/build-support/fetchurl/builder.sh
@@ -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
diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix
index f502b8890472..2643008e33fb 100644
--- a/pkgs/build-support/fetchurl/default.nix
+++ b/pkgs/build-support/fetchurl/default.nix
@@ -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.