Hi Norbert, I've started adapting tpm2license-new.pl so that it
- is usable for tetex-base - also produces a list of files for each package. The first one is done, the second I cannot achieve. I simply don't grok whether and how it is possible to use methods from Tpm.pm (and in fact I never used OO features in Perl, or anywhere). I attach the patch that describes my current state. After copying tpms for fontinst, wasysym and xkeyval from LocalTPM to their tetex directory, this is what I get: $ debian/tpm2licenses-new.pl --master=../../texlive/texlive/LocalTPM/ --catalogue=/home/frank/src/Upstream-source/texcatalogue --what=files Subroutine main::dirname redefined at /usr/share/perl/5.8/Exporter.pm line 65. at debian/tpm2licenses-new.pl line 79 % fontinst ARRAY(0x8646684) % wasysym texmf-dist/source/latex/wasysym/wasysym.dtx texmf-dist/source/latex/wasysym/wasysym.ins % xkeyval texmf-dist/source/latex/xkeyval/xkeyval.dtx $ I don't understand why this guess works with xkeyval, gives an additional empty line with wasysym, but just data rubbish with fontinst. This is the relevant part: sub printFiles { my ($pkgcat, $LocalTPM)= @_; my $pkg_header = "% $pkgcat"; my $dom_parser = new XML::DOM::Parser; my $doc = $dom_parser->parsefile($LocalTPM); my %SourceFiles = &Tpm::getListField($doc, "SourceFiles"); print $pkg_header . "\n"; print $SourceFiles{text} . "\n"; } Do I need to access getListField differently? TIA, Frank -- Frank Küster Single Molecule Spectroscopy, Protein Folding @ Inst. f. Biochemie, Univ. Zürich Debian Developer (teTeX)
--- /home/frank/src/Packages/texlive/texlive/LocalTPM/tpm2licenses-new.pl 2006-02-23 14:35:50.000000000 +0100 +++ debian/tpm2licenses-new.pl 2006-03-03 21:58:41.000000000 +0100 @@ -20,7 +20,7 @@ # unshift (@INC, "$mydir/.."); } -#use Strict; +use strict; use Getopt::Long; use File::Basename; use File::Copy; @@ -34,15 +34,20 @@ #use Tpm; -$opt_debug=0; -$opt_master="."; -$opt_catalogue="/src/TeX/texcatalogue/"; +# $opt_debug=0; # unused +my $opt_master="."; +my $opt_catalogue="/src/TeX/texcatalogue/"; +my $opt_what="license"; +my $Master; +my $what; GetOptions ("debug!", # debug mode "master=s" => \$opt_master, # location of Master - "catalogue=s" => \$opt_catalogue # location of the catalogue + "catalogue=s" => \$opt_catalogue, # location of the catalogue + "what=s" => \$opt_what # print licenses or files in a tpm? ); + if (!($opt_master =~ m,/.*$,,)) { $Master = `pwd`; chomp($Master); @@ -50,9 +55,17 @@ } else { $Master = $opt_master; } +$what = $opt_what; + my $TpmGlobalPath = $Master; my $DataGlobalPath = $Master; +# texlive +# my $TpmDirGlob = $Master . "./texmf-dist/tpm/*.tpm"; +# teTeX +my $TpmDirGlob = "./debian/tpm/*.tpm"; + + # # put Master/Tools/ into the include path to find TeX live perl modules # @@ -114,10 +127,17 @@ 1; +my $LocalTPM; +my $licline; +my $bn; +my $pkgcat; +my $node; + sub list_licenses { - foreach $f (<./texmf-dist/tpm/*.tpm>) { + foreach $LocalTPM (<$TpmDirGlob >) { +# foreach $LocalTPM (</home/frank/src/Packages/texlive/texlive/LocalTPM/texmf-dist/tpm/*.tpm>) { $licline = ""; - $bn = &basename($f,".tpm"); + $bn = &basename($LocalTPM,".tpm"); if (defined($Tpm2Catalogue{$bn})) { $pkgcat = $Tpm2Catalogue{$bn}; } else { @@ -150,23 +170,37 @@ $licline .= "unknown"; } else { $licline .= "$ltype (unverified)"; + # we know the license, it makes sense to output the files + $what eq "files" && &printFiles($pkgcat,$LocalTPM) } - print "$licline\n"; + $what eq "license" && print "$licline\n"; next; } $licline .= "$ltype (verification data:$version:$lversion:$lchecked:$luser)"; - print "$licline\n"; + $what eq "license" && print "$licline\n"; + # we know the license, it makes sense to output the files + $what eq "files" && &printFiles($pkgcat,$catname) } } -# foreach $f (<./texmf-doc/tpm/*.tpm>) { -# my $dat = $parser->parsefile($f); +sub printFiles { + my ($pkgcat, $LocalTPM)= @_; + my $pkg_header = "% $pkgcat"; + my $dom_parser = new XML::DOM::Parser; + my $doc = $dom_parser->parsefile($LocalTPM); + my %SourceFiles = &Tpm::getListField($doc, "SourceFiles"); + print $pkg_header . "\n"; + print $SourceFiles{text} . "\n"; +} + +# foreach $LocalTPM (<./texmf-doc/tpm/*.tpm>) { +# my $dat = $parser->parsefile($LocalTPM); # if (defined($dat->getElementsByTagName("TPM:License")) && # defined($dat->getElementsByTagName("TPM:License")->item(0)) && # defined($dat->getElementsByTagName("TPM:License")->item(0)->getFirstChild)) { -# print &basename($f,".tpm"), "\t", $dat->getElementsByTagName("TPM:License")->item(0)->getFirstChild->toString, "\n"; +# print &basename($LocalTPM,".tpm"), "\t", $dat->getElementsByTagName("TPM:License")->item(0)->getFirstChild->toString, "\n"; # } else { -# print &basename($f,".tpm"), "\tnon-in-catalogue\n"; +# print &basename($LocalTPM,".tpm"), "\tnon-in-catalogue\n"; # } # } }