copy-tarballs.pl: Handle SRI hashes

This should fix

Jul 20 07:16:12 bastion mirror-tarballs-start[21663]: Use of uninitialized value $algo in concatenation (.) or string at ./maintainers/scripts/copy-tarballs.pl line 80.
Jul 20 07:16:12 bastion mirror-tarballs-start[21663]: Use of uninitialized value in subroutine entry at ./maintainers/scripts/copy-tarballs.pl line 185.
Jul 20 07:16:13 bastion mirror-tarballs-start[21663]: error: unknown hash algorithm '' at ./maintainers/scripts/copy-tarballs.pl line 185.

Changed files
+15 -1
maintainers
+15 -1
maintainers/scripts/copy-tarballs.pl
···
my $hash = $fetch->{hash};
my $name = $fetch->{name};
+
if ($hash =~ /^([a-z0-9]+)-([A-Za-z0-9+\/=]+)$/) {
+
$algo = $1;
+
$hash = `nix hash to-base16 $hash` or die;
+
chomp $hash;
+
}
+
+
next unless $algo =~ /^[a-z0-9]+$/;
+
+
# Convert non-SRI base-64 to base-16.
+
if ($hash =~ /^[A-Za-z0-9+\/=]+$/) {
+
$hash = `nix hash to-base16 --type '$algo' $hash` or die;
+
chomp $hash;
+
}
+
if (defined $ENV{DEBUG}) {
print "$url $algo $hash\n";
next;
···
my $storePath = makeFixedOutputPath(0, $algo, $hash, $name);
-
print STDERR "mirroring $url ($storePath)...\n";
+
print STDERR "mirroring $url ($storePath, $algo, $hash)...\n";
if ($dryRun) {
$mirrored++;