diff options
Diffstat (limited to 'Build/tools/tpm-ctan-check')
-rwxr-xr-x | Build/tools/tpm-ctan-check | 289 |
1 files changed, 289 insertions, 0 deletions
diff --git a/Build/tools/tpm-ctan-check b/Build/tools/tpm-ctan-check new file mode 100755 index 00000000000..dba82d98ab0 --- /dev/null +++ b/Build/tools/tpm-ctan-check @@ -0,0 +1,289 @@ +#!/usr/local/bin/perl +# $Author: karl $ $Date: 2005/10/30 $ $Id: //depot/Master/Tools/tpm-ctan-check#158 $ +# Public domain. Originally written 2005, Karl Berry. +# Check if a package in TL has any changes on CTAN. Just the beginnings. + +$CTAN = $ENV{"CTAN"} || "/home/ftp/tex-archive"; +chomp (my $mydir = `dirname $0`); +chomp ($TL = `cd $mydir/..; pwd`); +chdir ($TL) || die "chdir($TL) failed: $!"; + +exit (&main ()); + +sub main +{ + $OPT{"verbose"} = 1; + + # xx read FILES.last7days, determine CTAN changes, map to TL packages + # xx alternatively, check all tpm's + if ($ARGV[0] eq "--karl") { + $OPT{"verbose"} = 0; + + # xx but for now, just check the few packages we have worked with. + @ARGV = ( + "12many", "ESIEEcv", "GuIT", "HA-prosper", "IEEEconf", "IEEEtran", + "SIstyle", "SIunits", "Tabbing", "Type1fonts", + "a0poster", "aastex", "abbr", "abstract", +#"abstyles", not updated, but too old to matter + "accfonts", "acronym", "algorithm2e", "algorithms", "apacite", + "archaic", "arev", + "babel", "babelbib", "beebe", "betababel", "bibhtml", "bibleref", + "blacklettert1", "booklet", "breakurl", "bytefield" , + "caption", "carlisle", "cbcoptic", "changebar", "chemcompounds", + "circ", "cjhebrew", "colortbl", "commath", "complexity", + "comprehensive", "computational-complexity", "csquotes", "curve", + "datetime", "devanagr", "dk-bib", "doipubmed", "dottex", "dtxtut", + "ednotes", "elpres", "endheads", "enumitem", "etaremune", "esint", + "esint-type1", "ethiop", "europecv", "exteps", + "featpost", "flagderiv", "floatflt", "floatrow", "flowfram", + "fltpoint", "fmtcount", "fncychap", "fontspec", "formular", + "fourier", + "genmisc", "glossary", "gost", "graphics", "graphicx-psmin", + "hyphen-base", "hyphen-basque", "hyphen-german", "hyphen-greek", + "hyphen-norwegian", "hyphen-ukenglish", "hyphen-usorbian", + "ibygrk", "iopart-num", + "koma-script", + "ledmac", "lfb", "lineno", + "lshort-bulgarian", "lshort-dutch", "lshort-english", + "lshort-finnish", "lshort-french", "lshort-german", + "lshort-italian", "lshort-japanese", "lshort-korean", + "lshort-mongolian", "lshort-polish", "lshort-portuguese", +#"lshort-russian", # only zip files on CTAN + "lshort-slovak", "lshort-spanish", + "lshort-thai", "lshort-ukrainian", "lshort-vietnamese", + "ltabptch", "ltxmisc", +#"malayalam", # missing C sources on CTAN, wrote author 5jun05. +#"mathspic", # inside pictex, later + "makecell", "makeplot", "mathmode", "mcaption", "memoir", + "mhchem", "minitoc", "microtype", "mla-paper", "movie15", +#"mpattern", # not up-to-date on CTAN, wrote author 28may05. + "nag", "ncclatex", "ncctools", "newlfm", "nomencl", "nomentbl", + "numprint", + "oberdiek", "octavo", + "pdf-trans", "pdfcprot", "perception", "perltex", "pgf", + "pictex", "placeins", + "plnfss", "poemscol", "powerdot", "powerdot-doc-vn", + "ppr-prv", "preview", "proof", "pstricks", "pstricks-add", + "pst-3d", "pst-barcode", "pst-blur", "pst-eucl", + "pst-labo", "pst-lens", "pst-osci", "pst-slpe", + "sciposter", "sectionbox", "seminar", "semioneside", "setspace", + "sf298", "sides", "sparklines", "sttools", "struktex", + "subfig", "sudoku", "svninfo", + "tabulary", "talk", "tamethebeast", "tex-refs", "texshade", + "textcase", "textpos", "thumbpdf", "bin-thumbpdf", + "titlesec", "tokenizer", "totpages", "trajan", "twoup", + "verse", "vhistory", "volumes", + "wrapfig", + "xcolor", "xkeyval" + ); + } + + my $errcount = 0; + for my $tpm (@ARGV) { + + # look in our various hierarchies. + my $found = ""; + for my $dir ("texmf-dist", "texmf-doc", "texmf") { + my $try = "$dir/tpm/$tpm.tpm"; + if (-r $try) { + $found = $try; + last; + } + } + + if ($found) { + print "checking $tpm..." if $OPT{"verbose"}; + $errcount += &do_tpm ($found); + } else { + warn "$0: cannot find tpm file $tpm\n"; + $errcount++; + } + } + return $errcount; +} + + + +# Return 1 if TPM needs updating, 0 if ok. +# +sub do_tpm +{ + my ($tpm) = @_; + my $needed = 0; + + my %tpm = &read_tpm ($tpm); + + my @compared = (); + + for my $file (@{$tpm{"files"}}) { + my $tl_file = "$TL/$file"; + if (! -e $tl_file) { + warn "$tl_file: TL file missing\n"; + next; + } + + (my $basefile = $file) =~ s,^.*/,,; + chomp (my @ctan_files = `find $CTAN/$tpm{CTANDir}/ -name $basefile`); + # the trailing / is so if we happen to hit a symlink on CTAN, it'll + # go through. + next if @ctan_files > 1; # if more than one file by same name, skip + + my $ctan_file = $ctan_files[0]; + if (! -e $ctan_file) { + # maybe it'll be there with a case change in the name + chomp (@ctan_files = `find $CTAN/$tpm{CTANDir}/ -iname $basefile`); + next if @ctan_files > 1; # if more than one file by same name, skip + $ctan_file = $ctan_files[0]; + + if (! -e $ctan_file) { + # we generate lots of files, eg perlmacros.sty, so might skip. + warn "$ctan_file: CTAN file missing\n" + if $ctan_file && $ctan_file !~ /(cfg|dvi|sty|tex)$/; + next; + } + } + + push (@compared, $basefile); + if (&files_differ ($tl_file, $ctan_file)) { + # we mostly regenerate pdf's for TL (sebastian thinks we should :), so + # don't complain if they are different. On the other hand, we + # don't always regenerate them, so might as well check first. + next if $tl_file =~ /\.pdf$/; + + print "# $tpm\ndiff $ctan_file $tl_file\n"; + $needed = 1; + last; + } + } + + # xx check ctan dir for new files + + if (@compared == 0) { + warn "\n$tpm: no files to compare in $CTAN/$tpm{CTANDir}, fixme!\n"; + } elsif ($needed == 0) { + print "ok, " . (@compared + 0) . " compared (@compared)\n" + if $OPT{"verbose"}; + } + + return $needed; +} + + + +# Return useful information from a TPM. +# +sub read_tpm +{ + my ($tpm) = @_; + my %ret; + + local *TPM; + open (TPM, $tpm) || die "open($tpm) failed: $!\n"; + + my @files = (); + while (<TPM>) { + if (m!</TPM:.*Files!) { # might be on same line + $collecting = 0; + } elsif (/<TPM:.*Files/) { + $collecting = 1; + next; + } + if ($collecting) { + chomp; + push (@files, $_) if $_ !~ /\.tpm$/; + } + } + close (TPM) || warn "close($tpm) failed: $!\n"; + + warn "$tpm: no files found\n" if ! @files; # probably misparsed the tpm + $ret{"files"} = \@files; + + (my $me = $tpm) =~ s,.*/,,; + $me =~ s/\.tpm$//; + + (my $menobin = $me) =~ s,^bin-,,; + (my $menodash = $me) =~ s,^.*-,,; + (my $menopowerdot = $me) =~ s,^powerdot-,,; + (my $menotype1 = $me) =~ s,-type1$,,; + + # xx how to really figure this out? + for my $dir ( + "macros/latex/contrib/$me", # most everything + "macros/latex/contrib/\L$me", # HA-prosper + "macros/latex/contrib/powerdot/contrib/$menopowerdot", # powerdot-doc-vn + "macros/latex/exptl/$me", # semioneside + "macros/latex/required/$me", # babel + "macros/plain/$me", # plnfss + "macros/xetex/latex/$me", # xetex + "macros/generic/$me", # abbr + "macros/generic/diagrams/$me", # circ + "macros/$me", # eplain + "support/$me", # thumbpdf + "support/$menobin", # bin-thumbpdf + "language/vietnamese/$me/unpacked", # vntex + "language/hebrew/$me", # cjhebrew + "language/greek/package-babel/$me", # ibycus-babel + "language/coptic/$me", # cbcoptic + "info/math/voss/$me", # mathmode + "info/lshort/$menodash", # lshort-english + "info/bibtex/$me", # tamethebeast + "info/symbols/$me", # comprehensive + "info/$me", # Type1fonts + "graphics/$me", # sparklines + "graphics/metapost/contrib/macros/$me", # mpattern + "graphics/pstricks/contrib/$me", # pstricks-add + "fonts/$me", # MnSymbol + "fonts/gothic/$me", # blacklettert1 + "fonts/greek/$me", # lfb + "fonts/ps-type1/$me", # cm-super + "fonts/ps-type1/$menotype1", # esint-type1 + "fonts/utilities/$me", # accfonts + "biblio/bibtex/contrib/$me", # dk-bib + ) { + if (-d "$CTAN/$dir") { + $ret{"CTANDir"} = $dir; + last; + } + } + + # names totally dissimilar + $ret{"CTANDir"} = "fonts/fourier-GUT" if $me eq "fourier"; + $ret{"CTANDir"} = "info/biblio" if $me eq "beebe"; + $ret{"CTANDir"} = "info/tex-references" if $me eq "tex-refs"; + $ret{"CTANDir"} = "language/basque" if $me eq "hyphen-basque"; + $ret{"CTANDir"} = "language/devanagari/velthuis" if $me eq "devanagr"; + $ret{"CTANDir"} = "language/hyphenation" if $me eq "hyphen-german"; + $ret{"CTANDir"} = "language/hyphenation/elhyphen" if $me eq "hyphen-greek"; + $ret{"CTANDir"} = "macros/latex/contrib/misc" if $me eq "ltxmisc"; + $ret{"CTANDir"} = "macros/generic" if $me eq "genmisc"; + + # do last, for sake of subdirs above. + $ret{"CTANDir"} = "language/hyphenation" + if $me =~ /^hyphen-/ && ! $ret{"CTANDir"}; + + die "$0: no CTAN directory for $me\n" if ! exists $ret{"CTANDir"}; + + return %ret; +} + + + +# 0 if files are the same, 1 if they are different. +# +sub files_differ +{ + my ($tl_file,$ctan_file) = @_; +#warn "comparing $tl_file $ctan_file\n"; + + my $different = 0; + if (-s $tl_file != -s $ctan_file) { + # sometimes what's checked into CTAN vs. TL differs in the eol + # conventions. Don't worry about that. + if (system ("diff -q --strip-trailing-cr $tl_file $ctan_file >/dev/null") + != 0) { + $different = 1; + } + } + + return $different; +} |