summary refs log tree commit diff
path: root/maintainers
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-18 15:17:13 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-18 15:18:25 +0200
commit35bd7708d5144036d350ece1342b3a104f9c8bdf (patch)
tree22ad186d21b3b391952f258c12729cac0b764f28 /maintainers
parentbe8fc33164301af4c96d964192931dca3f6d6be7 (diff)
downloadnixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.tar
nixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.tar.gz
nixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.tar.bz2
nixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.tar.lz
nixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.tar.xz
nixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.tar.zst
nixpkgs-35bd7708d5144036d350ece1342b3a104f9c8bdf.zip
copy-tarballs.pl: Use substituters to obtain tarballs
Diffstat (limited to 'maintainers')
-rwxr-xr-xmaintainers/scripts/copy-tarballs.pl39
-rw-r--r--maintainers/scripts/find-tarballs.nix2
2 files changed, 29 insertions, 12 deletions
diff --git a/maintainers/scripts/copy-tarballs.pl b/maintainers/scripts/copy-tarballs.pl
index b1233827ad8..db0cea3e670 100755
--- a/maintainers/scripts/copy-tarballs.pl
+++ b/maintainers/scripts/copy-tarballs.pl
@@ -22,6 +22,9 @@ use JSON;
 use Net::Amazon::S3;
 use Nix::Store;
 
+isValidPath("/nix/store/foo"); # FIXME: forces Nix::Store initialisation
+
+
 # S3 setup.
 my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die;
 my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'} or die;
@@ -127,6 +130,7 @@ elsif ($op eq "--expr") {
         my $url = $fetch->{url};
         my $algo = $fetch->{type};
         my $hash = $fetch->{hash};
+        my $name = $fetch->{name};
 
         if (defined $ENV{DEBUG}) {
             print "$url $algo $hash\n";
@@ -143,21 +147,34 @@ elsif ($op eq "--expr") {
             next;
         }
 
-        print STDERR "mirroring $url...\n";
+        my $storePath = makeFixedOutputPath(0, $algo, $hash, $name);
+
+        print STDERR "mirroring $url ($storePath)...\n";
 
         next if $ENV{DRY_RUN};
 
-        # Download the file using nix-prefetch-url.
-        $ENV{QUIET} = 1;
-        $ENV{PRINT_PATH} = 1;
-        my $fh;
-        my $pid = open($fh, "-|", "nix-prefetch-url", "--type", $algo, $url, $hash) or die;
-        waitpid($pid, 0) or die;
-        if ($? != 0) {
-            print STDERR "failed to fetch $url: $?\n";
-            next;
+        # Substitute the output.
+        if (!isValidPath($storePath)) {
+            system("nix-store", "-r", $storePath);
+        }
+
+        # Otherwise download the file using nix-prefetch-url.
+        if (!isValidPath($storePath)) {
+            $ENV{QUIET} = 1;
+            $ENV{PRINT_PATH} = 1;
+            my $fh;
+            my $pid = open($fh, "-|", "nix-prefetch-url", "--type", $algo, $url, $hash) or die;
+            waitpid($pid, 0) or die;
+            if ($? != 0) {
+                print STDERR "failed to fetch $url: $?\n";
+                next;
+            }
+            <$fh>; my $storePath2 = <$fh>; chomp $storePath2;
+            if ($storePath ne $storePath2) {
+                warn "strange: $storePath != $storePath2\n";
+                next;
+            }
         }
-        <$fh>; my $storePath = <$fh>; chomp $storePath;
 
         uploadFile($storePath, $url);
         $mirrored++;
diff --git a/maintainers/scripts/find-tarballs.nix b/maintainers/scripts/find-tarballs.nix
index ad79af90901..bd6afda900c 100644
--- a/maintainers/scripts/find-tarballs.nix
+++ b/maintainers/scripts/find-tarballs.nix
@@ -14,7 +14,7 @@ let
     operator = const [ ];
   });
 
-  urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; }) fetchurlDependencies;
+  urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; name = drv.name; }) fetchurlDependencies;
 
   fetchurlDependencies =
     filter