texlive[44289] Master: support display of accumulated size

commits+preining at tug.org commits+preining at tug.org
Thu May 11 04:41:34 CEST 2017


Revision: 44289
          http://tug.org/svn/texlive?view=revision&revision=44289
Author:   preining
Date:     2017-05-11 04:41:34 +0200 (Thu, 11 May 2017)
Log Message:
-----------
support display of accumulated size information for schemes/collections

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
    trunk/Master/tlpkg/TeXLive/TLPDB.pm

Modified: trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-05-11 00:06:34 UTC (rev 44288)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-05-11 02:41:34 UTC (rev 44289)
@@ -1529,46 +1529,56 @@
     print "longdesc:    ", $tlp->longdesc, "\n" if ($tlp->longdesc);
     print "installed:   ", ($installed ? "Yes" : "No"), "\n";
     print "revision:    ", $tlp->revision, "\n" if ($installed);
-    # print out sizes
+    #
+    # size computation: for normal packages give src/run/doc/bin sizes
+    # for scheme/collection accumulated (including deps) sizes
     my $sizestr = "";
-    my $srcsize = $tlp->srcsize * $TeXLive::TLConfig::BlockSize;
-    $sizestr = sprintf("%ssrc: %dk", $sizestr, int($srcsize / 1024) + 1) 
-      if ($srcsize > 0);
-    my $docsize = $tlp->docsize * $TeXLive::TLConfig::BlockSize;
-    $sizestr .= sprintf("%sdoc: %dk", 
-      ($sizestr ? ", " : ""), int($docsize / 1024) + 1)
-        if ($docsize > 0);
-    my $runsize = $tlp->runsize * $TeXLive::TLConfig::BlockSize;
-    $sizestr .= sprintf("%srun: %dk", 
-      ($sizestr ? ", " : ""), int($runsize / 1024) + 1)
-        if ($runsize > 0);
-    # check for .ARCH expansions
-    my $do_archs = 0;
-    for my $d ($tlp->depends) {
-      if ($d =~ m/^(.*)\.ARCH$/) {
-        $do_archs = 1;
-        last;
+    if ($tlp->category ne "Collection" && $tlp->category ne "Scheme") {
+      my $srcsize = $tlp->srcsize * $TeXLive::TLConfig::BlockSize;
+      $sizestr = sprintf("%ssrc: %dk", $sizestr, int($srcsize / 1024) + 1) 
+        if ($srcsize > 0);
+      my $docsize = $tlp->docsize * $TeXLive::TLConfig::BlockSize;
+      $sizestr .= sprintf("%sdoc: %dk", 
+        ($sizestr ? ", " : ""), int($docsize / 1024) + 1)
+          if ($docsize > 0);
+      my $runsize = $tlp->runsize * $TeXLive::TLConfig::BlockSize;
+      $sizestr .= sprintf("%srun: %dk", 
+        ($sizestr ? ", " : ""), int($runsize / 1024) + 1)
+          if ($runsize > 0);
+      # check for .ARCH expansions
+      my $do_archs = 0;
+      for my $d ($tlp->depends) {
+        if ($d =~ m/^(.*)\.ARCH$/) {
+          $do_archs = 1;
+          last;
+        }
       }
-    }
-    if ($do_archs) {
-      my @a = $localtlpdb->available_architectures;
-      my %binsz = %{$tlp->binsize};
-      my $binsize = 0;
-      for my $a (@a) {
-        $binsize += $binsz{$a} if defined($binsz{$a});
-        my $atlp = $tlpdb->get_package($tlp->name . ".$a");
-        if (!$atlp) {
-          tlwarn("$prg: cannot find depending package" . $tlp->name . ".$a\n");
-          $ret |= $F_WARNING;
-          next;
+      if ($do_archs) {
+        my @a = $localtlpdb->available_architectures;
+        my %binsz = %{$tlp->binsize};
+        my $binsize = 0;
+        for my $a (@a) {
+          $binsize += $binsz{$a} if defined($binsz{$a});
+          my $atlp = $tlpdb->get_package($tlp->name . ".$a");
+          if (!$atlp) {
+            tlwarn("$prg: cannot find depending package" . $tlp->name . ".$a\n");
+            $ret |= $F_WARNING;
+            next;
+          }
+          my %abinsz = %{$atlp->binsize};
+          $binsize += $abinsz{$a} if defined($abinsz{$a});
         }
-        my %abinsz = %{$atlp->binsize};
-        $binsize += $abinsz{$a} if defined($abinsz{$a});
+        $binsize *= $TeXLive::TLConfig::BlockSize;
+        $sizestr .= sprintf("%sbin: %dk",
+          ($sizestr ? ", " : ""), int($binsize / 1024) + 1)
+            if ($binsize > 0);
       }
-      $binsize *= $TeXLive::TLConfig::BlockSize;
-      $sizestr .= sprintf("%sbin: %dk",
-        ($sizestr ? ", " : ""), int($binsize / 1024) + 1)
-          if ($binsize > 0);
+    } else {
+      # case of collection or scheme
+      my $foo = $tlpdb->sizes_of_packages_with_deps ( 1, 1, undef, $pkg);
+      if (defined($foo->{$pkg})) {
+        $sizestr = sprintf("%dk", int($foo->{$pkg} / 1024) + 1);
+      }
     }
     print "sizes:       ", $sizestr, "\n";
     print "relocatable: ", ($tlp->relocated ? "Yes" : "No"), "\n";
@@ -7367,10 +7377,14 @@
 the request type instead of all packages.
 
 With any other arguments, display information about I<pkg>: the name,
-category, short and long description, installation status, and TeX Live
+category, short and long description, sizes, installation status, and TeX Live
 revision number.  If I<pkg> is not locally installed, searches in the
 remote installation source.
 
+For normal packages (not collections or schemes), the sizes of the
+four groups of files (run/src/doc/bin files) are shown. For collections
+and schemes the B<accumulated> size including depending packages.
+
 If I<pkg> is not found locally or remotely, the search action is used
 and lists matching packages and files.
 

Modified: trunk/Master/tlpkg/TeXLive/TLPDB.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLPDB.pm	2017-05-11 00:06:34 UTC (rev 44288)
+++ trunk/Master/tlpkg/TeXLive/TLPDB.pm	2017-05-11 02:41:34 UTC (rev 44289)
@@ -66,6 +66,7 @@
   $tlpdb->setting($key, [$value]);
   $tlpdb->setting([-clear], $key, [$value]);
   $tlpdb->sizes_of_packages($opt_src, $opt_doc, $ref_arch_list [, @packs ]);
+  $tlpdb->sizes_of_packages_with_deps($opt_src, $opt_doc, $ref_arch_list [, @packs ]);
   $tlpdb->install_package($pkg, $dest_tlpdb);
   $tlpdb->remove_package($pkg, %options);
   $tlpdb->install_package_files($file [, $file ]);
@@ -1362,19 +1363,23 @@
   return "";
 }
 
-
 =pod
 
+=item C<< $tlpdb->sizes_of_packages_with_deps ( $opt_src, $opt_doc, $ref_arch_list, [ @packs ] ) >>
+
 =item C<< $tlpdb->sizes_of_packages ( $opt_src, $opt_doc, $ref_arch_list, [ @packs ] ) >>
 
-This function returns a reference to a hash with package names as keys
+These functions return a reference to a hash with package names as keys
 and the sizes in bytes as values. The sizes are computed for the list of
 package names given as the fourth argument, or all packages if not
-specified.
+specified. The difference between the two functions is that the C<_with_deps>
+gives the size of packages including the size of all depending sizes.
 
 If anything has been computed one additional key is synthesized,
 C<__TOTAL__>, which contains the total size of all packages under
-consideration.
+consideration. In the case of <_with_deps> this total computation
+does B<not> count packages multiple times, even if they appear
+multiple times as dependencies.
 
 If the third argument is a reference to a list of architectures, then
 only the sizes for the binary packages for these architectures are used,
@@ -1384,7 +1389,25 @@
 
 sub sizes_of_packages {
   my ($self, $opt_src, $opt_doc, $arch_list_ref, @packs) = @_;
+  return $self->_sizes_of_packages(0, $opt_src, $opt_doc, $arch_list_ref, @packs);
+}
+
+sub sizes_of_packages_with_deps {
+  my ($self, $opt_src, $opt_doc, $arch_list_ref, @packs) = @_;
+  return $self->_sizes_of_packages(1, $opt_src, $opt_doc, $arch_list_ref, @packs);
+}
+
+
+sub _sizes_of_packages {
+  my ($self, $with_deps, $opt_src, $opt_doc, $arch_list_ref, @packs) = @_;
   @packs || ( @packs = $self->list_packages() );
+  my @expacks;
+  if ($with_deps) {
+    # don't expand collection->collection dependencies
+    @exppacks = $self->expand_dependencies('-no-collections', $self, @packs);
+  } else {
+    @exppacks = @packs;
+  }
   my @archs;
   if ($arch_list_ref) {
     @archs = @$arch_list_ref;
@@ -1395,7 +1418,7 @@
   my %tlpsizes;
   my %tlpobjs;
   my $totalsize;
-  foreach my $p (@packs) {
+  foreach my $p (@exppacks) {
     $tlpobjs{$p} = $self->get_package($p);
     my $media = $self->media_of_package($p);
     if (!defined($tlpobjs{$p})) {
@@ -1402,14 +1425,42 @@
       warn "STRANGE: $p not to be found in ", $self->root;
       next;
     }
-    $tlpsizes{$p} = $self->size_of_one_package($media, $tlpobjs{$p},
-                                               $opt_src, $opt_doc, @archs);
+    #
+    # in case we are calling the _with_deps variant, we always
+    # compute *UNCOMPRESSED* sizes (not the container sizes!!!)
+    if ($with_deps) {
+      $tlpsizes{$p} = $self->size_of_one_package('local_uncompressed' , $tlpobjs{$p},
+                                                 $opt_src, $opt_doc, @archs);
+    } else {
+      $tlpsizes{$p} = $self->size_of_one_package($media, $tlpobjs{$p},
+                                                 $opt_src, $opt_doc, @archs);
+    }
     $totalsize += $tlpsizes{$p};
   }
   if ($totalsize) {
     $tlpsizes{'__TOTAL__'} = $totalsize;
   }
-  return \%tlpsizes;
+  my %realtlpsizes;
+  for my $p (@packs) {
+    $realtlpsizes{$p} = $tlpsizes{$p};
+    if ($with_deps) {
+      # do a second round and compute the sizes with dependencies
+      for my $d ($tlpobjs{$p}->depends) {
+        next if ($d =~ m/\.ARCH/);
+        next if ($d =~ m/\.win32/ && !TeXLive::TLUtils::member('win32', @archs));
+        next if ($d =~ m/^collection-/);
+        next if ($d =~ m/^scheme-/);
+        if (defined($tlpsizes{$d})) {
+          $realtlpsizes{$p} += $tlpsizes{$d};
+        } else {
+          # silently ignore missing defined packages - they should have
+          # been computed by expand-dependencies
+          debug("TLPDB.pm: size with deps: sub package not found main=$d, dep=$p\n");
+        }
+      }
+    }
+  }
+  return \%realtlpsizes;
 }
 
 sub size_of_one_package {



More information about the tex-live-commits mailing list