Merge pull request #223261 from xworld21/copy-tarballs-use-all-urls
copy-tarballs: use all the urls of each file
This commit is contained in:
commit
0374d7897c
2 changed files with 60 additions and 57 deletions
|
@ -162,13 +162,18 @@ elsif (defined $expr) {
|
|||
# Check every fetchurl call discovered by find-tarballs.nix.
|
||||
my $mirrored = 0;
|
||||
my $have = 0;
|
||||
foreach my $fetch (sort { $a->{url} cmp $b->{url} } @{$fetches}) {
|
||||
my $url = $fetch->{url};
|
||||
foreach my $fetch (sort { $a->{urls}->[0] cmp $b->{urls}->[0] } @{$fetches}) {
|
||||
my $urls = $fetch->{urls};
|
||||
my $algo = $fetch->{type};
|
||||
my $hash = $fetch->{hash};
|
||||
my $name = $fetch->{name};
|
||||
my $isPatch = $fetch->{isPatch};
|
||||
|
||||
if ($isPatch) {
|
||||
print STDERR "skipping $urls->[0] (support for patches is missing)\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($hash =~ /^([a-z0-9]+)-([A-Za-z0-9+\/=]+)$/) {
|
||||
$algo = $1;
|
||||
$hash = `nix hash to-base16 $hash` or die;
|
||||
|
@ -183,6 +188,9 @@ elsif (defined $expr) {
|
|||
chomp $hash;
|
||||
}
|
||||
|
||||
my $storePath = makeFixedOutputPath(0, $algo, $hash, $name);
|
||||
|
||||
for my $url (@$urls) {
|
||||
if (defined $ENV{DEBUG}) {
|
||||
print "$url $algo $hash\n";
|
||||
next;
|
||||
|
@ -193,25 +201,18 @@ elsif (defined $expr) {
|
|||
next;
|
||||
}
|
||||
|
||||
if ($isPatch) {
|
||||
print STDERR "skipping $url (support for patches is missing)\n";
|
||||
next;
|
||||
}
|
||||
|
||||
next if defined $exclude && $url =~ /$exclude/;
|
||||
|
||||
if (alreadyMirrored($algo, $hash)) {
|
||||
$have++;
|
||||
next;
|
||||
last;
|
||||
}
|
||||
|
||||
my $storePath = makeFixedOutputPath(0, $algo, $hash, $name);
|
||||
|
||||
print STDERR "mirroring $url ($storePath, $algo, $hash)...\n";
|
||||
|
||||
if ($dryRun) {
|
||||
$mirrored++;
|
||||
next;
|
||||
last;
|
||||
}
|
||||
|
||||
# Substitute the output.
|
||||
|
@ -239,6 +240,8 @@ elsif (defined $expr) {
|
|||
|
||||
uploadFile($storePath, $url);
|
||||
$mirrored++;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
print STDERR "mirrored $mirrored files, already have $have files\n";
|
||||
|
|
|
@ -9,12 +9,12 @@ let
|
|||
|
||||
root = expr;
|
||||
|
||||
uniqueUrls = map (x: x.file) (genericClosure {
|
||||
startSet = map (file: { key = file.url; inherit file; }) urls;
|
||||
uniqueFiles = map (x: x.file) (genericClosure {
|
||||
startSet = map (file: { key = with file; (if type == null then "" else type + "+") + hash; inherit file; }) files;
|
||||
operator = const [ ];
|
||||
});
|
||||
|
||||
urls = map (drv: { url = head (drv.urls or [ drv.url ]); hash = drv.outputHash; isPatch = (drv?postFetch && drv.postFetch != ""); type = drv.outputHashAlgo; name = drv.name; }) fetchurlDependencies;
|
||||
files = map (drv: { urls = drv.urls or [ drv.url ]; hash = drv.outputHash; isPatch = (drv?postFetch && drv.postFetch != ""); type = drv.outputHashAlgo; name = drv.name; }) fetchurlDependencies;
|
||||
|
||||
fetchurlDependencies =
|
||||
filter
|
||||
|
@ -47,4 +47,4 @@ let
|
|||
|
||||
canEval = val: (builtins.tryEval val).success;
|
||||
|
||||
in uniqueUrls
|
||||
in uniqueFiles
|
||||
|
|
Loading…
Reference in a new issue