From c408149f82d93f0eeebf3d84377c5f1924ac38fb Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 9 May 2013 18:45:54 +0000 Subject: tlpsizes: new utility script to examine collection/scheme/package sizes; doc tweaks in TLPDB.pm git-svn-id: svn://tug.org/texlive/trunk@30347 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/bin/tlpsizes | 146 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100755 Master/tlpkg/bin/tlpsizes (limited to 'Master/tlpkg/bin') diff --git a/Master/tlpkg/bin/tlpsizes b/Master/tlpkg/bin/tlpsizes new file mode 100755 index 00000000000..1ee7f83a8ae --- /dev/null +++ b/Master/tlpkg/bin/tlpsizes @@ -0,0 +1,146 @@ +#!/usr/bin/env perl +# $Id: tlpfiles 14621 2009-08-12 00:49:01Z karl $ +# Copyright 2013 Karl Berry. +# This file is licensed under the GNU General Public License version 2 +# or any later version. +# +# Return sizes for TL schemes, collections, and/or packages. + +our $mydir; + +BEGIN { + $^W = 1; + ($mydir = $0) =~ s,/[^/]*$,,; + unshift (@INC, "$mydir/.."); +} + +use strict; + +use TeXLive::TLPDB; +use Pod::Usage; +use Getopt::Long; + +my $opt_schemes = 0; +my $opt_help = 0; + +TeXLive::TLUtils::process_logging_options (); +GetOptions ("schemes!" => \$opt_schemes, + "help|?" => \$opt_help) or pod2usage (2); +pod2usage ("-exitstatus" => 0, "-verbose" => 2) if $opt_help; + +exit (&main ()); + + +sub main { + chomp (my $Master = `cd $mydir/../.. && pwd`); + + my $tlpdb = TeXLive::TLPDB->new ("root" => $Master); + die "no tlpdb in $Master, goodbye" if ! $tlpdb; + + if (@ARGV) { + warn "$0: -schemes ignored, since explicit names given (@ARGV).\n" + if $opt_schemes; + } else { + # default to reporting on collections. + @ARGV = $opt_schemes ? $tlpdb->schemes : $tlpdb->collections; + } + + my (%c_size, %c_pkgs); + my $longest_name = 0; + for my $name (@ARGV) { + # we want to get only the packages in the collection, + # not include other collections; hence -no-collections. + my @pkgs = $tlpdb->expand_dependencies ("-no-collections", $tlpdb, $name); + + # get sizes of those packages. + # args say: include src, include doc, (no) platforms, just our pkgs. + my $pkg_sizes = $tlpdb->sizes_of_packages (1, 1, undef, @pkgs); + + $c_size{$name} = $pkg_sizes->{__TOTAL__}; + delete $pkg_sizes->{"__TOTAL__"}; # don't need that any more + delete $pkg_sizes->{$name}; # always includes itself, with zero size + + $c_pkgs{$name} = &pkgs_by_size (%$pkg_sizes); + + $longest_name = length ($name) if length ($name) > $longest_name; + } + + for my $c (sort { $c_size{$b} <=> $c_size{$a} } + keys %c_size) { + printf "%4d %-${longest_name}s %s\n", + $c_size{$c}/1024/1024, $c, $c_pkgs{$c}; + } + + return 0; +} + + +# Return nicely-formatted single-string representation of packages and +# their sizes (in kb), as comprised in PKG_SIZES, sorted biggest first. +# +sub pkgs_by_size { + my (%pkg_sizes) = @_; + my $ret =""; + + for my $p (sort { $pkg_sizes{$b} <=> $pkg_sizes{$a} } + keys %pkg_sizes) { + $ret .= " "; + $ret .= $pkg_sizes{$p} / 1024; + $ret .= "/$p"; + } + + return $ret; +} + +__END__ + +=head1 NAME + +tlpsizes - list sizes of TeX Live schemes, collections, or packages + +=head1 SYNOPSIS + + tlpsizes [I