diff options
author | Norbert Preining <preining@logic.at> | 2007-07-12 09:38:09 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2007-07-12 09:38:09 +0000 |
commit | 2559ab32acfcf160257c8a7c85c968e7dd58b589 (patch) | |
tree | 96c6dfb1847833fd69bf0b03305a22f6119e5cc7 /Master/tlpkg/TeXLive/TLPOBJ.pm | |
parent | fb899d343bd98cff4dfa012ef1e5cb7f851e69f4 (diff) |
the road to new texdoc handling:
- allow tags "details" and "language" for docfiles
- allow catalogue-* keys in a TLPOBJ file
- TLPOBJ.pm: add update_from_catalogue which updates some information
- adapt the tlpsrc2tlpdb script to take another argument -catalogue
in which case the database is build with catalogue information included
git-svn-id: svn://tug.org/texlive/trunk@4568 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPOBJ.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLPOBJ.pm | 185 |
1 files changed, 153 insertions, 32 deletions
diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm index 814c2d7d314..425bdcd480f 100644 --- a/Master/tlpkg/TeXLive/TLPOBJ.pm +++ b/Master/tlpkg/TeXLive/TLPOBJ.pm @@ -8,10 +8,13 @@ package TeXLive::TLPOBJ; use TeXLive::TLUtils; +use TeXLive::TeXCatalogue; use File::Path; use Cwd; use TeXLive::TLTREE; use FileHandle; +use Text::ParseWords; +use File::Basename; my $_tmp; my $_zipdir; @@ -37,6 +40,7 @@ sub new { binsize => defined($params{'binsize'}) ? $params{'binsize'} : {}, depends => defined($params{'depends'}) ? $params{'depends'} : [], revision => $params{'revision'}, + cataloguedata => defined($params{'cataloguedata'}) ? $params{'cataloguedata'} : {}, }; $_zipdir = $params{'zipdir'} if defined($params{'zipdir'}); bless $self, $class; @@ -61,7 +65,6 @@ sub from_fh { while (my $line = $fh->getline) { &TeXLive::TLUtils::debug("reading line: >>>$line<<<\n"); - &TeXLive::TLUtils::debug("multi=...$multi...\n"); $line =~ /^\s*#/ && next; # skip comment lines if ($line =~ /^\s*$/) { if (!$started) { next; } @@ -135,7 +138,24 @@ sub from_fh { $self->{"${type}size"} = $size; } next; - } elsif ($line =~ /^(doc|src|run)filescontinued\s+(.*)$/) { + } elsif ($line =~ /^docfilescontinued\s+(.*)$/) { + # docfiles can have tags + my @words = "ewords('\s+', 0, "$1"); + # the first entry is the file + my $f = shift @words; + push @{$self->{'docfiles'}}, $f; + while (@words) { + $_ = shift @words; + if (/^details=(.*)$/) { + $self->{'docfiledata'}{$f}{'details'} = "$1"; + } elsif (/^language=(.*)$/) { + $self->{'docfiledata'}{$f}{'href'} = "$1"; + } else { + die "Unknown docfile tag: $line"; + } + } + next; + } elsif ($line =~ /^(src|run)filescontinued\s+(.*)$/) { push @{$self->{$1."files"}}, "$2"; next; } elsif ($line =~ /^binfiles\s+/) { @@ -168,6 +188,8 @@ sub from_fh { push @{$self->{'depends'}}, "$2" unless "$2" eq ""; $lastcmd = "depend"; next; + } elsif ($line =~ /^catalogue-([^\s]+)\s+(.*)$/) { + $self->{'cataloguedata'}{$1} = "$2"; } else { die("Unknown directive ...$line... , please fix it!"); } @@ -237,6 +259,7 @@ sub writeout { defined($self->{'revision'}) && print $fd "revision $self->{'revision'}\n"; defined($self->{'catalogue'}) && print $fd "catalogue $self->{'catalogue'}\n"; defined($self->{'shortdesc'}) && print $fd "shortdesc $self->{'shortdesc'}\n"; + defined($self->{'license'}) && print $fd "license $self->{'license'}\n"; if (defined($self->{'longdesc'})) { $_tmp = "$self->{'longdesc'}"; write $fd; @@ -253,8 +276,15 @@ sub writeout { } if (defined($self->{'docfiles'}) && (@{$self->{'docfiles'}})) { print $fd "docfiles size=$self->{'docsize'}\n"; - foreach (sort @{$self->{'docfiles'}}) { - print $fd " $_\n"; + foreach my $f (sort @{$self->{'docfiles'}}) { + print $fd " $f"; + if (defined($self->{'docfiledata'}{$f}{'details'})) { + print $fd ' details="', $self->{'docfiledata'}{$f}{'details'}, '"'; + } + if (defined($self->{'docfiledata'}{$f}{'language'})) { + print $fd ' language="', $self->{'docfiledata'}{$f}{'language'}, '"'; + } + print $fd "\n"; } } if (defined($self->{'srcfiles'}) && (@{$self->{'srcfiles'}})) { @@ -277,6 +307,10 @@ sub writeout { } } } + # writeout all the catalogue keys + foreach my $k (keys %{$self->cataloguedata}) { + print $fd "catalogue-$k ", $self->cataloguedata->{$k}, "\n"; + } } sub writeout_simple { @@ -381,24 +415,24 @@ sub _make_zip { return; } my $cwd = &getcwd; - if ("$destdir" !~ m@^/@) { - # we have an relative zipdir, so we have to make it absolute - $destdir = "$cwd/$destdir"; - } + if ("$destdir" !~ m@^/@) { + # we have an relative zipdir, so we have to make it absolute + $destdir = "$cwd/$destdir"; + } &mkpath("$destdir") if (! -d "$destdir"); chdir($tltree->svnroot); - if ($arch eq "all") { - # we add the .tlpobj into the .tlpobj directory - my $removetlpobjdir = 0; - if (! -d ".tlpobj") { - &mkpath(".tlpobj"); - $removetlpobjdir = 1; - } - open(TMP,">.tlpobj/$self->{'name'}.tlpobj") or die "Cannot create .tlpobj/$self->{'name'}.tlpobj"; - $self->writeout(\*TMP); - close(TMP); - push @files, ".tlpobj/$self->{'name'}.tlpobj"; - } + if ($arch eq "all") { + # we add the .tlpobj into the .tlpobj directory + my $removetlpobjdir = 0; + if (! -d ".tlpobj") { + &mkpath(".tlpobj"); + $removetlpobjdir = 1; + } + open(TMP,">.tlpobj/$self->{'name'}.tlpobj") or die "Cannot create .tlpobj/$self->{'name'}.tlpobj"; + $self->writeout(\*TMP); + close(TMP); + push @files, ".tlpobj/$self->{'name'}.tlpobj"; + } unlink($zipname); print $zipcmd . "$destdir/$zipname" . " > $nul\n" if ($::opt_debug); open ZIP, $zipcmd . "$destdir/$zipname" . " > $nul"; @@ -410,11 +444,11 @@ sub _make_zip { } } @files; close ZIP; - if ($arch eq "all") { - # cleaning up - unlink(".tlpobj/$self->{'name'}.tlpobj"); - rmdir(".tlpobj") if $removetlpobjdir; - } + if ($arch eq "all") { + # cleaning up + unlink(".tlpobj/$self->{'name'}.tlpobj"); + rmdir(".tlpobj") if $removetlpobjdir; + } print "Done $zipname\n" if ($::opt_debug); } @@ -444,6 +478,57 @@ sub total_size { return($ret); } +sub update_from_catalogue { + my ($self, $tlc) = @_; + my $tlcname = defined($self->catalogue) ? $self->catalogue : $self->name; + if (defined($tlc->entries->{$tlcname})) { + my $entry = $tlc->entries->{$tlcname}; + if (defined($entry->license)) { + $self->cataloguedata->{'license'} = $entry->license; + } + if (defined($entry->version)) { + $self->cataloguedata->{'version'} = $entry->version; + } + if (defined($entry->url)) { + $self->cataloguedata->{'url'} = $entry->url; + } + # + # we need to do the following: + # - take the href entry for a documentation file entry in the TC + # - remove the 'ctan:' prefix + # - remove the <ctan path='...'> part + # - match the rest against all docfiles in an intelligent way + # + # Example: + # juramisc.xml contains: + # <documentation details='Package documentation' language='de' + # href='ctan:/macros/latex/contrib/juramisc/doc/jmgerdoc.pdf'/> + # <ctan path='/macros/latex/contrib/juramisc'/> + my @tcdocfiles = keys %{$entry->docs}; + my @tlpdocfiles = $self->docfiles; + foreach my $tcdocfile (@tcdocfiles) { + # basename also kills the ctan: prefix! + my $tcdocfilebasename = $tcdocfile; + # remove the ctan: prefix + $tcdocfilebasename =~ s/^ctan://; + # remove the ctan path if present + my $tcctanpath = $entry->ctan; + $tcdocfilebasename =~ s/^$tcctanpath//; + foreach my $tlpdocfile (@tlpdocfiles) { + if ($tlpdocfile =~ m/$tcdocfilebasename$/) { + # update the language/detail tags if present! + if (defined($entry->docs->{$tcdocfile}{'details'})) { + $self->{'docfiledata'}{$tlpdocfile}{'details'} = $entry->docs->{$tcdocfile}{'details'}; + } + if (defined($entry->docs->{$tcdocfile}{'language'})) { + $self->{'docfiledata'}{$tlpdocfile}{'language'} = $entry->docs->{$tcdocfile}{'language'}; + } + } + } + } + } +} + # # member access functions # @@ -589,6 +674,12 @@ sub zipdir { if (@_) { $_zipdir = $_[0] } return $_zipdir; } +sub cataloguedata { + my $self = shift; + my %ct = @_; + if (@_) { $self->{'cataloguedata'} = \%ct } + return $self->{'cataloguedata'}; +} 1; @@ -623,8 +714,10 @@ files describing a self-contained package. Please see L<TeXLive::TLPSRC> documentation for the specification. The only differences are that the various C<*pattern> keys are invalid, and instead there are the respective C<*files> keys described below. Furthermore -one more I<key> is allowed, C<revision> which specifies the maximum of -all last changed revision of files contained in the package. +some more I<keys> is allowed: C<revision> which specifies the maximum of +all last changed revision of files contained in the package, and anything +starting with C<catalogue-> specifying information coming from the +TeX Catalogue. All these keys have in common that the are followed by a list of files B<intended> by one space. They differ only in the first line itself @@ -632,15 +725,32 @@ B<intended> by one space. They differ only in the first line itself =over -=item C<srcfiles>, C<docfiles>, C<runfiles> +=item C<srcfiles>, C<runfiles> each of these three items contains in addition the sum of sizes of the single files (currently in byte, but this may change). srcfiles size=NNNNNN - docfiles size=NNNNNN runfiles size=NNNNNN +=item C<docfiles> + +The docfiles line itself is similar to the C<srcfiles> and C<runfiles> lines +above: + + docfiles size=NNNNNN + +But the lines listing the files are allowed to have additional tags: + + /------- excerpt from achemso.tlpobj + |... + |docfiles size=1702468 + | texmf-dist/doc/latex/aeguill/README details="Package Readme" + | texmf-dist/doc/latex/achemso/achemso.pdf details="Package documentation" language="en" + |... + +Currently only the tags C<details> and C<language> are allowed. + =item C<runfiles> Since C<runfiles> are different for the different architectures one C<tlpobj> @@ -685,7 +795,12 @@ For any of the I<keys> a function $tlpobj->key is available, which returns the current value when called without an argument, -and sets the respective value when called with an argument. +and sets the respective value when called with an argument. For the +TeX Catalogue Data the function + + $tlpobj->cataloguedata + +returns and takes as argument a hash. Arguments and return values for C<name>, C<category>, C<shortdesc>, C<longdesc>, C<catalogue>, C<revision> are single scalars. @@ -771,6 +886,12 @@ recomputes the sizes based on the information present in C<$tltree>. recomputes the revision based on the information present in C<$tltree>. +=item C<update_from_catalogue ($texcatalogue)> + +adds information from a C<TeXCatalogue> object +(currently license, version, url, and updates docfiles with details and +languages tags if present in the Catalogue) + =item C<is_arch_dependent> returns 1 if there are C<binfiles>, otherwise 0. @@ -799,7 +920,7 @@ adds or removes files for the given type (only for C<run>, C<src>, C<doc>). =head1 SEE ALSO The modules L<TeXLive::TLUtils>, L<TeXLive::TLPSRC>, -L<TeXLive::TLPDB>, L<TeXLive::TLTREE>. +L<TeXLive::TLPDB>, L<TeXLive::TLTREE>, L<TeXLive::TeXCatalogue>. =head1 AUTHORS AND COPYRIGHT @@ -814,4 +935,4 @@ GNU General Public License Version 2 or later. ### tab-width: 2 ### indent-tabs-mode: nil ### End: -# vim:set tabstop=2: # +# vim:set tabstop=2 expandtab: # |