Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

copy-tarballs.pl: Use substituters to obtain tarballs

(cherry picked from commit 35bd7708d5144036d350ece1342b3a104f9c8bdf)

+29 -12
+28 -11
maintainers/scripts/copy-tarballs.pl
··· 22 use Net::Amazon::S3; 23 use Nix::Store; 24 25 # S3 setup. 26 my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die; 27 my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'} or die; ··· 127 my $url = $fetch->{url}; 128 my $algo = $fetch->{type}; 129 my $hash = $fetch->{hash}; 130 131 if (defined $ENV{DEBUG}) { 132 print "$url $algo $hash\n"; ··· 143 next; 144 } 145 146 - print STDERR "mirroring $url...\n"; 147 148 next if $ENV{DRY_RUN}; 149 150 - # Download the file using nix-prefetch-url. 151 - $ENV{QUIET} = 1; 152 - $ENV{PRINT_PATH} = 1; 153 - my $fh; 154 - my $pid = open($fh, "-|", "nix-prefetch-url", "--type", $algo, $url, $hash) or die; 155 - waitpid($pid, 0) or die; 156 - if ($? != 0) { 157 - print STDERR "failed to fetch $url: $?\n"; 158 - next; 159 } 160 - <$fh>; my $storePath = <$fh>; chomp $storePath; 161 162 uploadFile($storePath, $url); 163 $mirrored++;
··· 22 use Net::Amazon::S3; 23 use Nix::Store; 24 25 + isValidPath("/nix/store/foo"); # FIXME: forces Nix::Store initialisation 26 + 27 + 28 # S3 setup. 29 my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die; 30 my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'} or die; ··· 130 my $url = $fetch->{url}; 131 my $algo = $fetch->{type}; 132 my $hash = $fetch->{hash}; 133 + my $name = $fetch->{name}; 134 135 if (defined $ENV{DEBUG}) { 136 print "$url $algo $hash\n"; ··· 147 next; 148 } 149 150 + my $storePath = makeFixedOutputPath(0, $algo, $hash, $name); 151 + 152 + print STDERR "mirroring $url ($storePath)...\n"; 153 154 next if $ENV{DRY_RUN}; 155 156 + # Substitute the output. 157 + if (!isValidPath($storePath)) { 158 + system("nix-store", "-r", $storePath); 159 } 160 + 161 + # Otherwise download the file using nix-prefetch-url. 162 + if (!isValidPath($storePath)) { 163 + $ENV{QUIET} = 1; 164 + $ENV{PRINT_PATH} = 1; 165 + my $fh; 166 + my $pid = open($fh, "-|", "nix-prefetch-url", "--type", $algo, $url, $hash) or die; 167 + waitpid($pid, 0) or die; 168 + if ($? != 0) { 169 + print STDERR "failed to fetch $url: $?\n"; 170 + next; 171 + } 172 + <$fh>; my $storePath2 = <$fh>; chomp $storePath2; 173 + if ($storePath ne $storePath2) { 174 + warn "strange: $storePath != $storePath2\n"; 175 + next; 176 + } 177 + } 178 179 uploadFile($storePath, $url); 180 $mirrored++;
+1 -1
maintainers/scripts/find-tarballs.nix
··· 14 operator = const [ ]; 15 }); 16 17 - urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; }) fetchurlDependencies; 18 19 fetchurlDependencies = 20 filter
··· 14 operator = const [ ]; 15 }); 16 17 + urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; type = drv.outputHashAlgo; name = drv.name; }) fetchurlDependencies; 18 19 fetchurlDependencies = 20 filter