Author: frank
Date: 2006-03-24 17:24:50 +0000 (Fri, 24 Mar 2006)
New Revision: 1108

Modified:
   tetex-base/trunk/debian/tpm2licenses-new.pl
Log:
tpm2licenses-new.pl now also works for texlive (and still for tetex, yeah!)

Modified: tetex-base/trunk/debian/tpm2licenses-new.pl
===================================================================
--- tetex-base/trunk/debian/tpm2licenses-new.pl 2006-03-24 09:18:01 UTC (rev 
1107)
+++ tetex-base/trunk/debian/tpm2licenses-new.pl 2006-03-24 17:24:50 UTC (rev 
1108)
@@ -73,7 +73,7 @@
     die "Unknown Debian package: $debian_package." unless
        ( $debian_package =~ /^tetex-base$/ || 
          $debian_package =~ /^tetex-src$/  ||
-         $debian_package =~ /^texlive$/ );
+         $debian_package =~ /^texlive-base$/ );
 };
 
 my $TpmGlobalPath = $Master;
@@ -146,6 +146,9 @@
 chdir($startdir);
 File::Basename::fileparse_set_fstype('unix');
 
+my @TpmList;
+create_tpmlist();
+
 list_licenses();
 
 1;
@@ -157,9 +160,46 @@
 my $node;
 my $printfiles = '';
 
+sub create_tpmlist {
 
+  if   ( $debian_package =~ /^tetex-/ ) {
+    foreach (<$TpmDirGlob >) {push(@TpmList,$_)};
+  };
+
+  if   ( $debian_package =~ /^texlive-/ ) {
+    my $cfgfile = "../../" . $debian_package . ".tpm4licenses.cfg";
+    my @cfgLines;
+    open CFGFILE, $cfgfile;
+    while (<CFGFILE>) {
+      # this could go into one line (next if...) if only Emacs would grok it...
+      if (m/^#/) { 
+         next ; 
+       }
+      chomp;
+      push(@cfgLines,$_);
+    };
+    for (@cfgLines) {
+      my $tpmFullname;
+      if ( -f "texmf/tpm/" . $_ ) {
+       $tpmFullname = "texmf/tpm/" . $_
+      }
+      elsif ( -f "texmf-dist/tpm/" . $_ ) {
+       $tpmFullname = "texmf-dist/tpm/" . $_
+      }
+      elsif ( -f "texmf-doc/tpm/" . $_ ) {
+       $tpmFullname = "texmf-doc/tpm/" . $_
+      }
+      else {
+       print STDERR "Could not find $_\n";
+       exit 1;
+      };
+      push(@TpmList,$tpmFullname);
+    };
+  }; #end texlive
+};
+
 sub list_licenses {
-   foreach $LocalTPM (<$TpmDirGlob >) {
+   foreach $LocalTPM (@TpmList) {
       $licline = "";
       $bn = &basename($LocalTPM,".tpm");
       if (defined($Tpm2Catalogue{$bn})) {
@@ -246,38 +286,56 @@
     my @DocFiles = split(/\n/m,$DocFiles{"text"});
 
     for ($debian_package) {
-       if ( /^texlive$/ ) { 1 };
+      my @texmfPath;
+       if ( /^texlive/ ) { 
+         @texmfPath = ("texmf","texmf-dist","texmf-doc");
+         foreach ($RunFiles{"text"}, $DocFiles{"text"}, $SourceFiles{"text"}) {
+               my @filelist = split(/\n/m,$_);
+               next if (! @filelist);
+               foreach (@filelist) {CheckFileExistence($_,[EMAIL PROTECTED])};
+           };
+
+           MergeDirectories([EMAIL PROTECTED],[EMAIL PROTECTED]);
+           MergeDirectories([EMAIL PROTECTED],[EMAIL PROTECTED]) if 
(@DocFiles);
+           MergeDirectories([EMAIL PROTECTED],[EMAIL PROTECTED]) if 
(@SourceFiles);
+           print $pkg_header . "\n @RunFiles @DocFiles @SourceFiles";
+       };
        if ( /^tetex-base$/ ) {
+           @texmfPath = (".");
            foreach ($RunFiles{"text"}, $DocFiles{"text"}) {
                my @filelist = split(/\n/m,$_);
                next if (! @filelist);
-               foreach (@filelist) {CheckFileExistence($_)};
+               foreach (@filelist) {CheckFileExistence($_,[EMAIL PROTECTED])};
            };
 
-           MergeDirectories([EMAIL PROTECTED]);
-           MergeDirectories([EMAIL PROTECTED]) if (@DocFiles);
+           MergeDirectories([EMAIL PROTECTED],[EMAIL PROTECTED]);
+           MergeDirectories([EMAIL PROTECTED],[EMAIL PROTECTED]) if 
(@DocFiles);
            print $pkg_header . "\n @RunFiles @DocFiles";
        };
        if ( /^tetex-src$/ ) {
-           foreach (\$SourceFiles{"text"}) {
-               my @filelist = split(/\n/m,${$_});
-               foreach (@filelist) {CheckFileExistence($_)};
+           @texmfPath = (".");
+           foreach ($SourceFiles{"text"}) {
+               my @filelist = split(/\n/m,$_);
+               foreach (@filelist) {CheckFileExistence($_,[EMAIL PROTECTED])};
            };
 
-           MergeDirectories([EMAIL PROTECTED]);
+           MergeDirectories([EMAIL PROTECTED],[EMAIL PROTECTED]);
            print $pkg_header . "\n @SourceFiles \n" unless (! @SourceFiles);
        };
     };
 }
 
 sub CheckFileExistence {
-    my $file = $_[0];
-    $file =~ [EMAIL PROTECTED]@${sourceDir}source@;
-    print STDERR "$file: Does not exist!\n" if ! -f $file;
+    my ($file,@texmfPath) = ($_[0],@{$_[1]});
+    my $found = 0;
+    foreach my $texmfDir (@texmfPath) {
+      -f $texmfDir . "/" . $file && ($found =1);
+    };
+    print STDERR "$file: Does not exist!\n" if ! $found;
 }
 
 sub MergeDirectories {
-    my $filelist = $_[0]; # $filelist is actually a pointer
+    my ($filelist,@texmfPath) = ($_[0],@{$_[1]}); # $filelist is actually a 
pointer
     
     # create a list of dirnames, and remove duplicates
     my @dirnames = map {dirname($_) } @{$filelist};
@@ -288,31 +346,40 @@
     my %SearchHash;
     %SearchHash = map { $_, 1 } @{$filelist} ;
 
-
     my %DirComplete = map { $_, 1 } @dirnames;
     for (@dirnames) {
        my $dirname = $_;
-       my @InstalledFiles = `find $dirname -maxdepth 1 -type f | grep -v 
tetex` 
-           or die "calling find to find installed files failed.";
+       my $fullDir;
+       my $rootDir;
+       for (@texmfPath) {
+         if ( -d ( $_ . "/" . $dirname )) { 
+           $rootDir = $_;
+           $fullDir =  ( $_ . "/" . $dirname );
+         };
+       };
+       $fullDir or die "This should not happen: no directory $dirname, 
nowhere.";
+       my  @InstalledFiles = `find $fullDir -maxdepth 1 -type f 2>/dev/null | 
grep -v tetex` 
+             or die "Calling find for $dirname, expanded to $fullDir, failed.";
        for (@InstalledFiles) {
-           chomp;
-           $DirComplete{$dirname} = 0 unless $SearchHash{$_};
+         chomp;
+         [EMAIL PROTECTED]/@@;
+         $DirComplete{$dirname} = 0 unless $SearchHash{$_};
        };
        if ( $DirComplete{$dirname} ) {
-           for (@{$filelist} ) {
-               # replace the file by its directory name
-               [EMAIL PROTECTED]/[EMAIL PROTECTED]/*@;
-           };
+         for (@{$filelist} ) {
+           # replace the file by its directory name
+           [EMAIL PROTECTED]/[EMAIL PROTECTED]/*@;
+         };
        };
 #      print STDERR "Directory $_ is $DirComplete{$dirname}\n";
-    };
+      };
 
     # now the complete directories occur multiple times, remove duplicates 
again
     %UniqueHash = map { ("$_\n" , 1) } @{$filelist} ;
     @{$filelist} = keys %UniqueHash;
+    
+  }
 
-}
-
 #   foreach $LocalTPM (<./texmf-doc/tpm/*.tpm>) {
 #      my $dat = $parser->parsefile($LocalTPM);
 #      if (defined($dat->getElementsByTagName("TPM:License")) &&


_______________________________________________
Pkg-tetex-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-tetex-commits

Reply via email to