#!/usr/bin/env perl # $Id: tl-update-containers 5188 2007-10-14 20:32:44Z karl $ # Copyright 2008 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # # Generate a zip file for the packages specified on the cmdline, or # for -all BEGIN { $^W = 1; ($mydir = $0) =~ s,/[^/]*$,,; unshift (@INC, "$mydir/.."); } use strict; use TeXLive::TLConfig; use TeXLive::TLPOBJ; use TeXLive::TLPDB; use TeXLive::TLUtils; use Getopt::Long; use Pod::Usage; use File::Path; my $opt_all = 0; our $mydir; my $opt_debug = 0; my $opt_containerdir = "./archive"; my $opt_relative = 0; my $help = 0; GetOptions("containerdir=s" => \$opt_containerdir, "debug!" => \$opt_debug, "help|?" => \$help) or pod2usage(1); pod2usage(-exitstatus => 0, -verbose => 2) if $help; if ($opt_debug) { $::LOGLEVELFILE = $::LOG_DDDEBUG; $::LOGLEVELTERMINAL = $::LOG_DDDEBUG; } my $srcsplit = 0; my $docsplit = 0; my $type = "lzma"; exit (&main ()); sub main { # get the db. chomp (my $Master = `cd $mydir/../.. && pwd`); # xx TLPDB should default my $tlpdb = TeXLive::TLPDB->new ("root" => "$Master"); die("Cannot find tlpdb in $Master!\n") unless defined($tlpdb); my @packs; @packs = $tlpdb->list_packages; # get configuration of package splitting $srcsplit = $tlpdb->config_src_container; $docsplit = $tlpdb->config_doc_container; my $format = $tlpdb->config_container_format; if (($format eq "lzma") || ($format eq "zip")) { $type = $format; } else { warn "unknown container format specified in 00texlive.config: $format\nIgnoring and continuing with $type!\n"; } # read in the old texlive.pkgver and save the revisions my %archiverevs; if (-r "$opt_containerdir/texlive.pkgver") { open(TMP,"<$opt_containerdir/texlive.pkgver") or die "Cannot open $opt_containerdir/texlive.pkgver for reading: $!\nPlease use tlpdb2container first!\n"; while () { my ($pkg,$rev) = split; $archiverevs{$pkg} = $rev; } close(TMP); } else { die "No $opt_containerdir/texlive.pkgver, please use tlpdb2container first!\n"; } # collect packages to be updated: my @todopacks; for my $pkg (@packs) { my $oldrev = 0; if (defined($archiverevs{$pkg})) { $oldrev = $archiverevs{$pkg}; } else { tllog($::LOG_DEBUG, "found a new package without container: $pkg\n"); } my $tlp = $tlpdb->get_package($pkg); my $newrev = 0; if (defined($tlp)) { $newrev = $tlp->revision; } else { tllog($::LOG_NORMAL, "It looks like $pkg has disappeared, removing its containers!\n"); `rm $opt_containerdir/$pkg.*`; } if ($oldrev == $newrev) { tllog($::LOG_DEBUG, "$pkg up to date\n"); } elsif ($oldrev < $newrev) { push @todopacks, $pkg; } else { # huhh, the new rev is SMALLER then the oldrev?!?! die "This shouldn't happen, the revision of $pkg in texlive.tlpdb is OLDER than the one in $opt_containerdir/texlive.pkgver.\nAre you sure???\n"; } } # get list of packages. for my $pkg (sort @todopacks) { next if ($pkg eq "00texlive.config"); next if ($pkg eq "00texlive.installer"); my $obj = $tlpdb->get_package ($pkg); die "$0: no TeX Live package named $pkg in $Master.\n" if ! $obj; printf STDERR "updating $pkg containers ...\n"; if ($srcsplit) { my $objsrc = $obj->split_src_package; if ($objsrc) { $objsrc->make_container($type,$Master,$opt_containerdir,"$pkg.source",$opt_relative); } } if ($docsplit) { my $objdoc = $obj->split_doc_package; if ($objdoc) { $objdoc->make_container($type,$Master,$opt_containerdir,"$pkg.doc",$opt_relative); } } $obj->make_container($type,$Master,$opt_containerdir,$pkg,$opt_relative); } if (@todopacks) { # we did update something printf STDERR "updating $opt_containerdir/texlive.pkgver ...\n"; open(TMP,">$opt_containerdir/texlive.pkgver") or die "Cannot create $opt_containerdir/texlive.pkgver"; $tlpdb->generate_packagelist(\*TMP); close(TMP); print "all done.\n"; } else { printf STDERR "Nothing to be done.\n"; } } __END__ =head1 NAME tl-update-containers - update already generated containers =head1 SYNOPSIS tl-update-containers [OPTION]... =head1 OPTIONS =over 8 =item B<-containerdir> I The location where the previously generated containers are to be found, defaults to ./zip. =back The standard options C<-help> and C<-debug> are also accepted. See the tlpfiles documentation for details. Note that the format of the containers and the splitting off of source and documentation files are controlled by the TLPDB options saved in the pseudo package C<00texlive.config>. Please see the documentation for TLPDB for details. =head1 DESCRIPTION The B program compares the revisions of all packages as found in the C with the revisions of the packages in the C. In case the latter is more recent (i.e., a higher number) the containers are updated. =head1 AUTHORS AND COPYRIGHT This script and its documentation were written for the TeX Live distribution (L) and both are licensed under the GNU General Public License Version 2 or later. =cut ### Local Variables: ### perl-indent-level: 2 ### tab-width: 2 ### indent-tabs-mode: nil ### End: # vim:set tabstop=2 expandtab: #