diff options
author | Karl Berry <karl@freefriends.org> | 2007-10-17 18:58:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-10-17 18:58:53 +0000 |
commit | cb091d9b79eb9d6cce2c94c8c0112ed30aa4b64a (patch) | |
tree | cbe87c9096e6aed19c09a8dc98a8cd04b3f3a2e2 | |
parent | e2343fd9fc761d631f2a04049f7393910b75c7b2 (diff) |
implement new option --all to use *.tlpsrc.
git-svn-id: svn://tug.org/texlive/trunk@5219 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/tlpkg/bin/tlpsrc2tlpdb | 121 |
1 files changed, 80 insertions, 41 deletions
diff --git a/Master/tlpkg/bin/tlpsrc2tlpdb b/Master/tlpkg/bin/tlpsrc2tlpdb index dcf9d1d4ba2..170f932f442 100755 --- a/Master/tlpkg/bin/tlpsrc2tlpdb +++ b/Master/tlpkg/bin/tlpsrc2tlpdb @@ -1,11 +1,10 @@ #!/usr/bin/env perl # $Id$ -# tlpsrc2tlpdb -# convert a set of tlpsrc files (given as arguments) into tlpdb -# # Copyright 2007 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. +# +# convert a set of tlpsrc files (given as arguments) into tlpdb BEGIN { $^W = 1; @@ -23,59 +22,93 @@ use Getopt::Long; use Pod::Usage; use File::Path; - +my $opt_all = 0; +my $opt_catalogue = ""; chomp (my $opt_master = `cd $::mydir/../.. && pwd`); our $opt_debug = 0; my $man = 0; my $help = 0; -my $opt_catalogue = ""; -GetOptions("debug!", # debug mode - "master=s" => \$opt_master, # location of the tree +GetOptions( + "all!" => \$opt_all, + "master=s" => \$opt_master, # location of the TL tree "catalogue=s" => \$opt_catalogue, # location of the TeX Catalogue - 'help|?' => \$help, man => \$man - ) or pod2usage(2); + "debug!", "help|?" => \$help, "man" => \$man) or pod2usage(2); pod2usage(1) if $help; pod2usage(-exitstatus => 0, -verbose => 2) if $man; -if (! -d "$opt_master") { - die "Master $opt_master does not exists!"; -} - -my $tlc; -if (! -d "$opt_catalogue") { - warn "$0: -d /Cat/a/logue not given, continuing without it.\n"; -} else { - require TeXLive::TeXCatalogue; # not at compile time, for now anyway. - $tlc = TeXLive::TeXCatalogue->new( 'location' => "$opt_catalogue" ); -} - -my $tltree = TeXLive::TLTREE->new( 'svnroot' => "$opt_master" ); -$tltree->init_from_svn; +exit (&main ()); + +sub main +{ + if (! -d $opt_master) { + die "$0: Master $opt_master not a directory, goodbye.\n"; + } -my $tldb = TeXLive::TLPDB->new; + my $tlc = undef; + if (! -d $opt_catalogue) { + warn "$0: -c /Cat/a/logue not given, continuing without it.\n"; + } else { + require TeXLive::TeXCatalogue; # not at compile time, for now anyway. + $tlc = TeXLive::TeXCatalogue->new( "location" => $opt_catalogue ); + } -foreach my $f (@ARGV) { - my $tlsrc = new TeXLive::TLPSRC; - $tlsrc->from_file($f); - my $tlp = $tlsrc->make_tlpobj($tltree); - # now merge the TeX Catalogue Information, currently only license - #xx set in struct somehow? my $tlcname = defined($tlp->catalogue) ? $tlp->catalogue : $tlp->name; - if ($tlc) { - $tlp->update_from_catalogue($tlc); + # if we're regenerating the whole thing, get all our tlpsrc files. + if ($opt_all) { + my $tlpsrc_dir = "$opt_master/tlpkg/tlpsrc"; + chdir ($tlpsrc_dir) || die "chdir($tlpsrc_dir) failed: $!"; + @ARGV = glob ("*.tlpsrc"); + } + + warn "$0: reading Master tree $opt_master ...\n"; + my $tltree = TeXLive::TLTREE->new( "svnroot" => $opt_master ); + $tltree->init_from_svn; + + warn "$0: updating from tlpsrc ...\n"; + my $tldb = TeXLive::TLPDB->new; + my $last = ""; + foreach my $f (@ARGV) { + if ($opt_all) { # progress report + my $first = lc (substr ($f, 0, 1)); + if ($first ne $last) { + print STDERR "$first "; + $last = $first; + } + } + my $tlsrc = new TeXLive::TLPSRC; + $tlsrc->from_file ($f); + my $tlp = $tlsrc->make_tlpobj ($tltree); + + if ($tlc) { + # merge TeX Catalogue information + $tlp->update_from_catalogue ($tlc); + } + + $tldb->add_tlpobj ($tlp); } - $tldb->add_tlpobj($tlp); + warn "\n"; + + # write the new db, to the real location given --all, or stdout. + if ($opt_all) { + local *TLPDB; + our $TLPDB = ">$opt_master/texlive.tlpdb"; + open (TLPDB) || die "open($TLPDB) failed: $!"; + $tldb->writeout (*TLPDB); + warn "$0: wrote $TLPDB.\n"; + } else { + $tldb->writeout; + } + + return 0; } -$tldb->writeout; - __END__ =head1 NAME -tlpsrc2tlpdb - converting tlpsrc files into tlpdb +tlpsrc2tlpdb - generate a TeX Live database from tlpsrc files =head1 SYNOPSIS @@ -85,6 +118,11 @@ tlpsrc2tlpdb [OPTION]... [TLPSRC]... =over 8 +=item B<-all> +Use all .tlpsrc files in C<Master/tlpkg/tlpsrc/*.tlpsrc>, and update the +live database in C<Master/texlive.tlpdb>. (No repository operations are +done.) + =item B<-catalogue> I<Catalogue_dir> The location given by B<-catalogue> must point to a valid TeX Catalogue. No default value. If given, the generated tlpobj files will contain information @@ -101,11 +139,12 @@ See the tlpfiles documentation for details. =head1 DESCRIPTION -B<tlpsrc2tlpdb> converts TeX Live Source Package files (tlpsrc) files into a -TeX Live Package Database (tlpdb). If a TeX Catalogue is specified additional -information from the catalogue are merged into the TeX Live Database -(see L<TeXLive::TLPOBJ> for the list of included information from -the TeX Catalogue). +B<tlpsrc2tlpdb> converts TeX Live source package files (tlpsrc) files into a +TeX Live package database (tlpdb) + +If a TeX Catalogue hierarchy is specified, additional information from +the catalogue are merged into the database (see L<TeXLive::TLPOBJ> for +the list of included information from the TeX Catalogue). =head1 AUTHORS AND COPYRIGHT |