diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-19 14:27:28 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-09-19 14:27:28 +0000 |
commit | 07cec27848014244c8f62985c5c0eb045bc86634 (patch) | |
tree | 86d8017486e25fd0968b4b015380f08d55232219 /scripts | |
parent | 9488ae7357b718e09362c22f075cc5553c758214 (diff) |
* Cleanups.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/optimise-store.pl | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/scripts/optimise-store.pl b/scripts/optimise-store.pl index e4b8678d5..7bad1d5e5 100755 --- a/scripts/optimise-store.pl +++ b/scripts/optimise-store.pl @@ -2,23 +2,23 @@ use strict; -{ my $ofh = select STDOUT; - $| = 1; - select $ofh; -} +#{ my $ofh = select STDOUT; +# $| = 1; +# select $ofh; +#} +#my @paths = ("/nix/store/d49mc94xwwd7wf1xzfh4ch4cypn0ajjr-glibc-2.3.6", "/nix/store/1mgfgy3ga4m9z60747s0yzxl0g6w5kxz-glibc-2.3.6"); my @paths = ("/nix/store"); -my $tmpfile = "/tmp/nix-optimise-hash-list"; -#my $tmpfile = "/data/nix-optimise-hash-list"; +my $hashList = "/tmp/nix-optimise-hash-list"; -system("find @paths -type f -print0 | xargs -0 md5sum -- > $tmpfile") == 0 +system("find @paths -type f -print0 | xargs -0 md5sum -- > $hashList") == 0 or die "cannot hash store files"; -system("sort $tmpfile > $tmpfile.sorted") == 0 +system("sort $hashList > $hashList.sorted") == 0 or die "cannot sort list"; -open LIST, "<$tmpfile.sorted" or die; +open LIST, "<$hashList.sorted" or die; my $prevFile; my $prevHash; @@ -29,20 +29,16 @@ my $savedSpace = 0; my $files = 0; while (<LIST>) { -# print "D"; /^([0-9a-f]*)\s+(.*)$/ or die; my $curFile = $2; my $curHash = $1; -# print "A"; my $fileSize = (stat $curFile)[7]; -# print "B"; -# my $fileSize = 1; $totalSpace += $fileSize; if (defined $prevHash && $curHash eq $prevHash) { -# print "$curFile = $prevFile\n"; + print "$curFile = $prevFile\n"; $savedSpace += $fileSize; @@ -51,13 +47,10 @@ while (<LIST>) { $prevHash = $curHash; } - print "." if ($files++ % 100 == 0); - #print "."; - -# print "C"; +# print "." if ($files++ % 100 == 0); } -print "\n"; +#print "\n"; print "total space = $totalSpace\n"; print "saved space = $savedSpace\n"; |