#!/usr/bin/env perl # Sebastian Rahtz: $Date: 2004/06/06 $ # Process a tree in the texlive "cooked" directory and put # in the main texmf trees # # License: PUBLIC DOMAIN # use English; use File::Basename; use File::Find; use Cwd; $Date=`date +%Y/%m/%d`; $Who=`whoami`; chop($Date); chop($Who); $newpackage=0; $PM="//depot/Master"; @zapped=(); $package=$ARGV[0]; $startdir=getcwd(); $Inidir = getcwd(); chdir(dirname($0)); chdir "../../Master"; $M = getcwd(); $M =~ s/\/Archive//; chdir("$Inidir/$package"); if (-d "texmf-dist") {$Root="texmf-dist"; } elsif (-d "texmf-doc") {$Root="texmf-doc"; } elsif (-d "texmf") {$Root="texmf"; } if (!-d "$Inidir/$package") { die "No package to install: $package\n"; } print "$M, $Inidir, $Root\n"; # get list of existing files chdir($M) || die ("directory $M does not exist"); if (-f "$M/texmf/lists/$package") { open(LIST,"$M/texmf/lists/$package"); while () { chop; s/ //; if (/^[A-z]/) { $Old{$_}=1; } } close(LIST); system "p4 edit $PM/texmf/lists/$package"; } else { $newpackage=1; } if (-f "$M/$Root/tpm/$package.tpm") { system "p4 edit $PM/$Root/tpm/$package.tpm"; } else { system "p4 add $M/$Root/tpm/$package.tpm"; } chdir("$Inidir/$package"); find(\&files,"."); foreach $file (keys %Old) { print "* $file: [" . $New{$file} . "]\n"; if ($New{$file}) { system "p4 edit $PM/$file"; } else { system "p4 delete $PM/$file"; } } # copy files $Job="tar cf - . | (cd $M ; tar xf - )"; system($Job); foreach $file (keys %New) { if ($Old{$file}) { } else { system "p4 add $M/$file"; } } if ($newpackage) { system "p4 add $M/texmf/lists/$package"; system "p4 add $M/$Root/tpm/$package.tpm"; } else { system "p4 edit $PM/texmf/lists/$package"; system "p4 edit $PM/$Root/tpm/$package.tpm"; } chdir("$Inidir"); system("mv $package $package.done"); if ($Root eq 'texmf-doc') { $Type='Documentation'; } else { $Type='Package'; } $SETUP="$M/Tools/tpm-factory.pl --master=$M --tpm_dir=$M/$Root/tpm --ftp_dir=/var/tmp "; if (-f "$M/$Root/tpm/$package.tpm") { system "perl $SETUP --clean --arch=all --patterns=auto --name=$Type/$package"; } else { system "perl $SETUP --new --arch=all --patterns=auto --name=$Type/$package"; system "perl $SETUP --clean --arch=all --patterns=auto --name=$Type/$package"; } system "xsltproc --stringparam ROOT $M $M/Tools/tpm2list.xsl $M/$Root/tpm/$package.tpm"; #-------------------------------------- sub dirs { local @filenames; if (-d) { @filenames=&buildfilelist($File::Find::name, $_); if (!@filenames) { rmdir $File::Find::name;} }} sub buildfilelist { local($me,$name) = @_; my @files; opendir(DIR,$me) || cleanup ("cannot open directory $me"); @files =grep(!/^\.\.?/,readdir(DIR)); closedir(DIR); return @files; } sub files { if (-f) { $Shortname=$_; $This=$File::Find::name; $This =~ s/^\.\///; $New{$This}=1; } }