copy-tarballs.pl: Use substituters to obtain tarballs
This commit is contained in:
parent
be8fc33164
commit
35bd7708d5
@ -22,6 +22,9 @@ use JSON;
|
|||||||
use Net::Amazon::S3;
|
use Net::Amazon::S3;
|
||||||
use Nix::Store;
|
use Nix::Store;
|
||||||
|
|
||||||
|
isValidPath("/nix/store/foo"); # FIXME: forces Nix::Store initialisation
|
||||||
|
|
||||||
|
|
||||||
# S3 setup.
|
# S3 setup.
|
||||||
my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die;
|
my $aws_access_key_id = $ENV{'AWS_ACCESS_KEY_ID'} or die;
|
||||||
my $aws_secret_access_key = $ENV{'AWS_SECRET_ACCESS_KEY'} 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 $url = $fetch->{url};
|
||||||
my $algo = $fetch->{type};
|
my $algo = $fetch->{type};
|
||||||
my $hash = $fetch->{hash};
|
my $hash = $fetch->{hash};
|
||||||
|
my $name = $fetch->{name};
|
||||||
|
|
||||||
if (defined $ENV{DEBUG}) {
|
if (defined $ENV{DEBUG}) {
|
||||||
print "$url $algo $hash\n";
|
print "$url $algo $hash\n";
|
||||||
@ -143,11 +147,19 @@ elsif ($op eq "--expr") {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
print STDERR "mirroring $url...\n";
|
my $storePath = makeFixedOutputPath(0, $algo, $hash, $name);
|
||||||
|
|
||||||
|
print STDERR "mirroring $url ($storePath)...\n";
|
||||||
|
|
||||||
next if $ENV{DRY_RUN};
|
next if $ENV{DRY_RUN};
|
||||||
|
|
||||||
# Download the file using nix-prefetch-url.
|
# 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{QUIET} = 1;
|
||||||
$ENV{PRINT_PATH} = 1;
|
$ENV{PRINT_PATH} = 1;
|
||||||
my $fh;
|
my $fh;
|
||||||
@ -157,7 +169,12 @@ elsif ($op eq "--expr") {
|
|||||||
print STDERR "failed to fetch $url: $?\n";
|
print STDERR "failed to fetch $url: $?\n";
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
<$fh>; my $storePath = <$fh>; chomp $storePath;
|
<$fh>; my $storePath2 = <$fh>; chomp $storePath2;
|
||||||
|
if ($storePath ne $storePath2) {
|
||||||
|
warn "strange: $storePath != $storePath2\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uploadFile($storePath, $url);
|
uploadFile($storePath, $url);
|
||||||
$mirrored++;
|
$mirrored++;
|
||||||
|
@ -14,7 +14,7 @@ let
|
|||||||
operator = const [ ];
|
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 =
|
fetchurlDependencies =
|
||||||
filter
|
filter
|
||||||
|
Loading…
Reference in New Issue
Block a user