mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
* Cleanups.
This commit is contained in:
parent
9488ae7357
commit
07cec27848
1 changed files with 12 additions and 19 deletions
|
@ -2,23 +2,23 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
{ my $ofh = select STDOUT;
|
#{ my $ofh = select STDOUT;
|
||||||
$| = 1;
|
# $| = 1;
|
||||||
select $ofh;
|
# select $ofh;
|
||||||
}
|
#}
|
||||||
|
|
||||||
|
#my @paths = ("/nix/store/d49mc94xwwd7wf1xzfh4ch4cypn0ajjr-glibc-2.3.6", "/nix/store/1mgfgy3ga4m9z60747s0yzxl0g6w5kxz-glibc-2.3.6");
|
||||||
my @paths = ("/nix/store");
|
my @paths = ("/nix/store");
|
||||||
|
|
||||||
my $tmpfile = "/tmp/nix-optimise-hash-list";
|
my $hashList = "/tmp/nix-optimise-hash-list";
|
||||||
#my $tmpfile = "/data/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";
|
or die "cannot hash store files";
|
||||||
|
|
||||||
system("sort $tmpfile > $tmpfile.sorted") == 0
|
system("sort $hashList > $hashList.sorted") == 0
|
||||||
or die "cannot sort list";
|
or die "cannot sort list";
|
||||||
|
|
||||||
open LIST, "<$tmpfile.sorted" or die;
|
open LIST, "<$hashList.sorted" or die;
|
||||||
|
|
||||||
my $prevFile;
|
my $prevFile;
|
||||||
my $prevHash;
|
my $prevHash;
|
||||||
|
@ -29,20 +29,16 @@ my $savedSpace = 0;
|
||||||
my $files = 0;
|
my $files = 0;
|
||||||
|
|
||||||
while (<LIST>) {
|
while (<LIST>) {
|
||||||
# print "D";
|
|
||||||
/^([0-9a-f]*)\s+(.*)$/ or die;
|
/^([0-9a-f]*)\s+(.*)$/ or die;
|
||||||
my $curFile = $2;
|
my $curFile = $2;
|
||||||
my $curHash = $1;
|
my $curHash = $1;
|
||||||
|
|
||||||
# print "A";
|
|
||||||
my $fileSize = (stat $curFile)[7];
|
my $fileSize = (stat $curFile)[7];
|
||||||
# print "B";
|
|
||||||
# my $fileSize = 1;
|
|
||||||
$totalSpace += $fileSize;
|
$totalSpace += $fileSize;
|
||||||
|
|
||||||
if (defined $prevHash && $curHash eq $prevHash) {
|
if (defined $prevHash && $curHash eq $prevHash) {
|
||||||
|
|
||||||
# print "$curFile = $prevFile\n";
|
print "$curFile = $prevFile\n";
|
||||||
|
|
||||||
$savedSpace += $fileSize;
|
$savedSpace += $fileSize;
|
||||||
|
|
||||||
|
@ -51,13 +47,10 @@ while (<LIST>) {
|
||||||
$prevHash = $curHash;
|
$prevHash = $curHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "." if ($files++ % 100 == 0);
|
# print "." if ($files++ % 100 == 0);
|
||||||
#print ".";
|
|
||||||
|
|
||||||
# print "C";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n";
|
#print "\n";
|
||||||
|
|
||||||
print "total space = $totalSpace\n";
|
print "total space = $totalSpace\n";
|
||||||
print "saved space = $savedSpace\n";
|
print "saved space = $savedSpace\n";
|
||||||
|
|
Loading…
Reference in a new issue