@@ -162,13 +162,18 @@ sub uploadFile {
162
162
# Check every fetchurl call discovered by find-tarballs.nix.
163
163
my $mirrored = 0;
164
164
my $have = 0;
165
- foreach my $fetch (sort { $a -> {url } cmp $b -> {url } } @{$fetches }) {
166
- my $url = $fetch -> {url };
165
+ foreach my $fetch (sort { $a -> {urls } -> [0] cmp $b -> {urls } -> [0] } @{$fetches }) {
166
+ my $urls = $fetch -> {urls };
167
167
my $algo = $fetch -> {type };
168
168
my $hash = $fetch -> {hash };
169
169
my $name = $fetch -> {name };
170
170
my $isPatch = $fetch -> {isPatch };
171
171
172
+ if ($isPatch ) {
173
+ print STDERR " skipping $urls ->[0] (support for patches is missing)\n " ;
174
+ next ;
175
+ }
176
+
172
177
if ($hash =~ / ^([a-z0-9]+)-([A-Za-z0-9+\/ =]+)$ / ) {
173
178
$algo = $1 ;
174
179
$hash = ` nix hash to-base16 $hash ` or die ;
@@ -183,62 +188,60 @@ sub uploadFile {
183
188
chomp $hash ;
184
189
}
185
190
186
- if (defined $ENV {DEBUG }) {
187
- print " $url $algo $hash \n " ;
188
- next ;
189
- }
190
-
191
- if ($url !~ / ^http:/ && $url !~ / ^https:/ && $url !~ / ^ftp:/ && $url !~ / ^mirror:/ ) {
192
- print STDERR " skipping $url (unsupported scheme)\n " ;
193
- next ;
194
- }
195
-
196
- if ($isPatch ) {
197
- print STDERR " skipping $url (support for patches is missing)\n " ;
198
- next ;
199
- }
191
+ my $storePath = makeFixedOutputPath(0, $algo , $hash , $name );
200
192
201
- next if defined $exclude && $url =~ / $exclude / ;
193
+ for my $url (@$urls ) {
194
+ if (defined $ENV {DEBUG }) {
195
+ print " $url $algo $hash \n " ;
196
+ next ;
197
+ }
202
198
203
- if (alreadyMirrored( $algo , $hash ) ) {
204
- $have ++ ;
205
- next ;
206
- }
199
+ if ($url !~ / ^http: / && $url !~ / ^https: / && $url !~ / ^ftp: / && $url !~ / ^mirror: / ) {
200
+ print STDERR " skipping $url (unsupported scheme) \n " ;
201
+ next ;
202
+ }
207
203
208
- my $storePath = makeFixedOutputPath(0, $algo , $hash , $name ) ;
204
+ next if defined $exclude && $url =~ / $exclude / ;
209
205
210
- print STDERR " mirroring $url ($storePath , $algo , $hash )...\n " ;
206
+ if (alreadyMirrored($algo , $hash )) {
207
+ $have ++;
208
+ last ;
209
+ }
211
210
212
- if ($dryRun ) {
213
- $mirrored ++;
214
- next ;
215
- }
211
+ print STDERR " mirroring $url ($storePath , $algo , $hash )...\n " ;
216
212
217
- # Substitute the output.
218
- if (!isValidPath( $storePath )) {
219
- system ( " nix-store " , " -r " , $storePath ) ;
220
- }
213
+ if ( $dryRun ) {
214
+ $mirrored ++;
215
+ last ;
216
+ }
221
217
222
- # Otherwise download the file using nix-prefetch-url.
223
- if (!isValidPath($storePath )) {
224
- $ENV {QUIET } = 1;
225
- $ENV {PRINT_PATH } = 1;
226
- my $fh ;
227
- my $pid = open ($fh , " -|" , " nix-prefetch-url" , " --type" , $algo , $url , $hash ) or die ;
228
- waitpid ($pid , 0) or die ;
229
- if ($? != 0) {
230
- print STDERR " failed to fetch $url : $? \n " ;
231
- next ;
218
+ # Substitute the output.
219
+ if (!isValidPath($storePath )) {
220
+ system (" nix-store" , " -r" , $storePath );
232
221
}
233
- <$fh >; my $storePath2 = <$fh >; chomp $storePath2 ;
234
- if ($storePath ne $storePath2 ) {
235
- warn " strange: $storePath != $storePath2 \n " ;
236
- next ;
222
+
223
+ # Otherwise download the file using nix-prefetch-url.
224
+ if (!isValidPath($storePath )) {
225
+ $ENV {QUIET } = 1;
226
+ $ENV {PRINT_PATH } = 1;
227
+ my $fh ;
228
+ my $pid = open ($fh , " -|" , " nix-prefetch-url" , " --type" , $algo , $url , $hash ) or die ;
229
+ waitpid ($pid , 0) or die ;
230
+ if ($? != 0) {
231
+ print STDERR " failed to fetch $url : $? \n " ;
232
+ next ;
233
+ }
234
+ <$fh >; my $storePath2 = <$fh >; chomp $storePath2 ;
235
+ if ($storePath ne $storePath2 ) {
236
+ warn " strange: $storePath != $storePath2 \n " ;
237
+ next ;
238
+ }
237
239
}
238
- }
239
240
240
- uploadFile($storePath , $url );
241
- $mirrored ++;
241
+ uploadFile($storePath , $url );
242
+ $mirrored ++;
243
+ last ;
244
+ }
242
245
}
243
246
244
247
print STDERR " mirrored $mirrored files, already have $have files\n " ;
0 commit comments