diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-12-28T21·12+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2004-12-28T21·12+0000 |
commit | 9022cf9adfd3504e40d52fa2891663bf33fa2f9d (patch) | |
tree | 77204708371762b4d36aa0962ab3e084654e426b | |
parent | 4bf58d53795d53331094e5cc83187602d8d37730 (diff) |
* A small utility to add the Size and NarHash fields to old manifests.
-rwxr-xr-x | scripts/update-manifest.pl | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/update-manifest.pl b/scripts/update-manifest.pl new file mode 100755 index 000000000000..bd76f37ad635 --- /dev/null +++ b/scripts/update-manifest.pl @@ -0,0 +1,53 @@ +#! /usr/bin/perl -w -I. + +use strict; +use readmanifest; + +die unless scalar @ARGV == 2; + +my $cache = $ARGV[0]; +my $manifest = $ARGV[1]; +my %narFiles; +my %patches; +my %successors; + +readManifest $manifest, \%narFiles, \%patches, \%successors; + +foreach my $storePath (keys %narFiles) { + my $narFileList = $narFiles{$storePath}; + + foreach my $narFile (@{$narFileList}) { + if (!defined $narFile->{size} or + !defined $narFile->{narHash}) + { + $narFile->{url} =~ /\/([^\/]+)$/; + die unless defined $1; + my $fn = "$cache/$1"; + + my @info = stat $fn or die; + $narFile->{size} = $info[7]; + + my $narHash; + my $hashFile = "$fn.NARHASH"; + if (-e $hashFile) { + open HASH, "<$hashFile" or die; + $narHash = <HASH>; + close HASH; + } else { + print "$fn\n"; + $narHash = `bunzip2 < '$fn' | nix-hash --flat /dev/stdin` or die; + open HASH, ">$hashFile" or die; + print HASH $narHash; + close HASH; + } + chomp $narHash; + $narFile->{narHash} = $narHash; + } + } +} + +if (! -e "$manifest.backup") { + system "mv --reply=no '$manifest' '$manifest.backup'"; +} + +writeManifest $manifest, \%narFiles, \%patches, \%successors; |