diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-06-26 14:45:40 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-06-26 14:45:40 +0000 |
commit | 1008ed6541b9b58d97239303db8312f37dc3e87e (patch) | |
tree | 557a2db05d9bed5754dad87b1ad15f328c86e0b0 /usr.sbin/pkg_add/pkg_merge | |
parent | 0f167b7410125b5d3b53080a77c78a7e87ab6556 (diff) |
some useful statistics about shared files and size gains.
Diffstat (limited to 'usr.sbin/pkg_add/pkg_merge')
-rw-r--r-- | usr.sbin/pkg_add/pkg_merge | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/pkg_merge b/usr.sbin/pkg_add/pkg_merge index 608803efb6e..fcae7ea505f 100644 --- a/usr.sbin/pkg_add/pkg_merge +++ b/usr.sbin/pkg_add/pkg_merge @@ -112,12 +112,12 @@ sub occurs_first } -set_usage('pkg_merge -o result pkg pkg2 ...'); +set_usage('pkg_merge [-v] -o result pkg pkg2 ...'); -our ($opt_o); +our ($opt_o, $opt_v); try { - getopts('o:'); + getopts('o:v'); } catchall { Usage($_); }; @@ -156,6 +156,9 @@ for my $pkgname (@ARGV) { $prefix++; } +my $total_files = 0; +my $total_size = 0; + # For now, we assume packing-lists contain the same items. while(1) { # kill empty lists @@ -178,18 +181,14 @@ while(1) { # second case: a name that occurs first in some lists, # and not in the others if (!defined $name) { - print "(first)"; $name = occurs_first(\@tomerge); } # else, try random if (!defined $name) { - print "(random)"; $name = $tomerge[0]->{tocopy}->[0]->{name}; } - print $name, "\n"; - my $allprefix=''; my $ref; my @mergeable = (); @@ -200,9 +199,11 @@ while(1) { } } + my $all_copies = 0; while (@mergeable > 0) { my $pkg = shift @mergeable; my $ref = shift @{$pkg->{tocopy}}; + my $copies = 0; my $currentprefix = $pkg->{prefix}; my @todo = (); for my $cmp (@mergeable) { @@ -210,12 +211,24 @@ while(1) { my $i = shift @{$cmp->{tocopy}}; $i->copy_over(undef, undef, $cmp); $currentprefix .= $cmp->{prefix}; + $copies++; } else { push(@todo, $cmp); } } + $total_files += $copies; + $total_size += $ref->{size} * $copies; $ref->copy_over($wrarc, $currentprefix, $pkg); @mergeable = @todo; + $all_copies += $copies; + } + if ($opt_v) { + if ($all_copies) { + print "$name (shared: $all_copies)\n"; + } else { + print $name, "\n"; + } } } $wrarc->close(); +print "Shared $total_files files for $total_size bytes\n" if $opt_v; |