diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-07-20 14:48:50 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-07-20 14:50:56 +0200 |
commit | c48be3c17d2754d396790fb30405d625a562d1a5 (patch) | |
tree | ac45d9b3fe666fd62db5c2727b4653147c8447d6 /maintainers/scripts | |
parent | 21b39527bfc5b718c798bb41df5b85b1f0de034c (diff) | |
download | nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.tar nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.tar.gz nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.tar.bz2 nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.tar.lz nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.tar.xz nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.tar.zst nixpkgs-c48be3c17d2754d396790fb30405d625a562d1a5.zip |
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.
Diffstat (limited to 'maintainers/scripts')
-rwxr-xr-x | maintainers/scripts/copy-tarballs.pl | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/maintainers/scripts/copy-tarballs.pl b/maintainers/scripts/copy-tarballs.pl index 59696a4432d..6a08eb88bf8 100755 --- a/maintainers/scripts/copy-tarballs.pl +++ b/maintainers/scripts/copy-tarballs.pl @@ -165,6 +165,20 @@ elsif (defined $expr) { 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; @@ -184,7 +198,7 @@ elsif (defined $expr) { my $storePath = makeFixedOutputPath(0, $algo, $hash, $name); - print STDERR "mirroring $url ($storePath)...\n"; + print STDERR "mirroring $url ($storePath, $algo, $hash)...\n"; if ($dryRun) { $mirrored++; |