summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tlpkg-ctan-check
blob: 6ff3f3ca8af30b99c7b279a9a1be234917781a74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#!/usr/bin/env perl
# $Id$
# Public domain.  Originally written 2005, Karl Berry.
# Rewritten for new infrastructure 2007, Norbert Preining.
# Check if a package in TL has any changes on CTAN.  Just the beginnings.

BEGIN {
  chomp ($mydir = `dirname $0`);  # we are in Master/tlpkg/bin
  unshift (@INC, "$mydir/..");
}

use TeXLive::TLConfig;
use TeXLive::TLPOBJ;
use TeXLive::TLPDB;

use File::Basename;

my $tlpdb;
my $Master;
our %OPT;

my @WorkingTLP = qw(
        12many
        a0poster a2ping aastex abbr abc abstract abstyles accfonts achemso
          acmconf acmtrans acronym 
          active-conf addlines adrconv ae afthesis
          aguplus aichej AkkTeX akletter
          algorithm2e algorithmicx algorithms alnumsec altfont ametsoc ams
          amsaddr amslatex-primer amsldoc-it amsmath amsrefs
          amsthdoc-it animate ANUfinalexam anyfontsize anysize
          apa apacite appendix apl
          arabi arabtex arabxetex archaic arcs arev
          armenian AroBend arphic arrayjob arsclassica
          arydshln Asana-Math ascii assignment astro
          attachfile auncial-new aurical authoraftertitle authorindex
          auto-pst-pdf autoarea automata
        babel babelbib bangtex barcodes bbcard bbding bbold bclogo
          beamer beamer-contrib beamer-tut-pt beamerposter
          begriff bera betababel beton
          bez123 bezos bibhtml bibleref bibtopic bibtopicprefix
          bibunits bidi bigfoot binomexp blacklettert1 blindtext
          blockdraw_mp blowup boisik
          boites boldtensors bookest booklet booktabs bophook
          boxhandler bpchem breakurl bullcntr bussproofs bytefield 
        captcont caption carlisle casyl catechis carolmin-ps
          cbcoptic cbfonts ccaption cclicenses cd cdpbundl cellspace
          changebar changepage changes chappg chapterfolder
          chem-journal chembst chemcompounds
          chemstyle cherokee chessboard chessfss chletter circ
          citeref cjhebrew cjk classicthesis
          clefval cleveref
          clock clrscode cm-super
          cmap cmastro cmcyr cmdstring cmdtrack cmll colorinfo
          colortbl colorwav commath compact compactbib complexity comprehensive
          computational-complexity confproc constants
          context-account context-bnf context-chromato 
          context-construction-plan context-degrade context-french
          context-letter context-lettrine context-lilypond context-mathsets
          context-taspresent
          context-typearea context-vim
          cooking cool coollist coolstr cooltooltips
          coordsys courier-scaled courseoutline coursepaper coverpage
          crop crossreference crosswrd cryst csbulletin csquotes csvtools ctable
          cursolatex cursor cuisine
          currvita curve curve2e curves
          custom-bib cv cweb-latex cyklop cyrillic
        dancers dashbox dashrule datatool
          dateiliste datetime dcpic decimal dehyph-exptl
          delimtxt digiconfigs din1505
          dinat dingbat directory disser dk-bib dlfltxb
          doc-pictex docmfp doi doipubmed
          dotarrow dottex
          doublestroke dpfloat dprogress drac draftcopy
          draftwatermark dramatist dratex dtxgallery
          dtxtut duerer-latex dvdcoll dviasm dviincl dvipdfmx-def
          dvipsconfig dyntree
        ean13isbn easy ebong ebsthesis eCards ecc ecclesiastic economic
          ecv ed edmac edmargin ednotes eemeir egameps
          egplot eijkhout
          ellipsis elpres elsarticle elsevier elsevier-bib
          emulateapj emp encxvlna endfloat endheads
          engpron engrec enumitem envbig environ envlab
          epigrafica epigraph epiolmec eplain
          epsdice epsf epsincl epslatex-fr epspdfconversion
          eqlist eqparbox errata es-tex-faq
          ESIEEcv esdiff esint esint-type1 eskd eskdx eso-pic esvect etaremune
          etex-pkg ethiop ethiop-t1 etoolbox euenc eukdate
          eulervm euproposal euro europecv eurosans everypage exam
          examdesign examplep exercise expdlist expl3 expressg extarrows exteps
          extpfeil extract extsizes
        faktor fancybox fancyhdr fancynum fancyref fancytooltips fancyvrb
          FAQ-en fax
          fbs featpost
          feyn feynmf fge filecontents fink fixme
          flagderiv flippdf float floatrow flowfram fltpoint
          fmtcount fnbreak
          fncychap foekfont fontch fontinst fontspec fonttable fontwrap
          footbib footmisc footnpag forarray forloop formular
          fouridx fourier fouriernc
          fp fpl fragments frankenstein free-math-font-survey
          frenchle fribrief frletter frontespizio fullblck fullpict functan
        gaceta galois gastex gatech-thesis gb4e gcard gcite gene-logic
          genmisc genmpage gentle geometry germbib
          gfsartemisia gfsbodoni gfscomplutum gfsdidot gfsneohellenic
          gfsporson gfssolomos
          ginpenc gloss glossaries gmdoc gmeometric
          gmiflink gmutils gmverb gmverse gnuplottex gost graphics
          graphicx-psmin greek-inputenc greekdates greenpoint
          gu GuIT guitar
        HA-prosper hands hanging harmony harvardkyoto hc hep hepnames
          hepparticles hepthesis hepunits 
          hhtensor histogr hitec hrlatex hvfloat 
          hypdvips hyperref hyperxmp hyph-utf8 hyphen-base 
          hyphenat hyphenex hyplain
        ibygrk icsv IEEEconf IEEEtran ifplatform ifxetex
          ijmart ijqc image-gallery impatient impatient-fr imtekda
          inlinebib inlinedef
          interactiveworkbook intro-scientific inversepath invoice
          ionumbers iopart-num iso
          iso10303 isodate isodoc isomath isonums isorot isotope itnumpar iwona
        jeopardy jknapltx jneurosci jpsj
          jura juraabbrev jurabib juramisc jurarsp
        kalender kastrup kerkis kerntest keystroke knuth koma-script kpfonts
        l2picfaq l2tabu-english l2tabu-spanish
          labbook labelcas labels lastpage
          latex latex2e-help-texinfo latex-course latex-tds latexmk latexmp
          layouts lcd lcg lcyw leading leaflet ledmac leftidx lettrine
          lewis lfb lgreek lh
          libertine limap linearA lineno linguex
          lipsum listings listliketab lithuanian liturg lkproof lm lnotes
          logic logpap lps lsc lshort-bulgarian lshort-chinese
          lshort-dutch lshort-english
          lshort-finnish lshort-french lshort-german lshort-italian
          lshort-japanese lshort-korean lshort-mongolian
          lshort-polish lshort-portuguese lshort-slovak lshort-slovenian
          lshort-spanish lshort-thai lshort-turkish lshort-ukr
          lshort-vietnamese ltablex ltabptch ltxdockit
          ltxindex ltxmisc lxfonts
        mafr magyar mailing
          makebarcode makebox makecell makecirc makecmds makeglos
          makeplot maple margbib
          marginnote marvosym mathabx mathdots mathexam
          mathmode mathspec maybemath
          mcaption mceinleger mciteplus mdwtools memexsupp
          memoir MemoirChapStyles mentis
          menu metago metaobj metaplot metatex metauml
          mff mfnfss mfpic mftinc mh mhchem
          mhequ mhs microtype midnight minipage-marginpar minitoc minutes
          mkjobtexmf mkpattern
          mla-paper mlist mmap mnsymbol
          moderncv modroman mongolian-babel moreverb movie15 mp3d mparhack
          mpman-ru ms msc msg multicap
          multido multiobjective munich muthesis mwcls
        nag namespc natbib nath nature ncclatex ncctools newlfm nih noitcrul
          nomencl nomentbl nostarch notes notes2bib
          ntgclass ntheorem-vn numname numprint
        oberdiek ocr-latex octavo ofs ogham ogonek oldstyle onlyamsmath opcit
          ordinalpt othello outline
        pageno pagenote paper papercdcase papertex
          parallel paresse parrun passivetex 
          patch pauldoc pax pbox pb-diagram
          pdf-forms-tutorial-de pdf-forms-tutorial-en
          pdf-trans pdfcprot pdfcrop
          pdfpages pdfscreen pdfslide pdfsync pdftex-def pdftricks
          perception perltex
          permute petiteannonce
          pgf pgf-soroban pgfopts pgfplots phaistos philex philosophersimprint
          pict2e pictex pictex2 pinlabel pittetd placeins plari plates play
          plnfss pmgraph poemscol polski polyglossia polynom polynomial
          polytable
          powerdot ppr-prv pracjourn preprint
          prettyref preview proba probsoln procIAGssymp program protex protocol
          pseudocode psfrag psfrag-italian psgo pslatex psnfss pspicture
          pst-2dplot pst-3d pst-3dplot pst-asr pst-bar
          pst-barcode pst-blur pst-circ pst-cox pst-dbicons pst-diffraction
          pst-eps pst-eucl pst-fill
          pst-fr3d pst-fractal pst-fun pst-func
          pst-geo pst-grad pst-infixplot pst-jtree pst-labo
          pst-lens pst-light3d pst-math pst-ob3d pst-optexp pst-optic
          pst-osci pst-pad pst-pdf pst-pdgr pst-qtree
          pst-solides3d pst-soroban pst-spectra
          pst-slpe pst-stru pst-text pst-uml pst-vue3d
          pst2pdf pstool pstricks pstricks-add
          psu-thesis ptptex pxfonts
        qcm qstest quotmark qtree
        r_und_s randbild rccol rcs rcsinfo recipe recipecard
          refman refstyle regcount register resume robustcommand
          robustindex rotating rsc rtkinenc rtklage
        sagetex sauerj sauterfonts savefnmark savesym savetrees scale
          scalebar scientificpaper sciposter screenplay script
          sdrt sectionbox sectsty semantic semaphor seminar semioneside
          seqsplit setspace sf298 sffms sfg sfmath sgame shadbox shapepar
          shipunov shorttoc show2e showdim showexpl showlabels shuffle
          SIstyle SIunits
          sidecap sides siggraph simplecv simplewick siunitx
          skak skaknew slideshow smalltableof smartref smflatex
          snapshot songbook sort-by-letters soul spanish-mx sparklines spie
          splines splitbib splitindex spotcolor sprite srcltx sseq
          ssqquote stack stage statex2 staves stdclsdv stdpage stellenbosch
          stex stringstrings struktex
          sttools stubs subdepth subeqn subeqnarray
          subfig subfigure subfloat substr sudoku sudokubundle sugconf 
	  supertabular susy svgcolor svn svn-multi svninfo
          swebib syllogism syntax synproof syntrace synttree
        t-angles t2 Tabbing tablists tablor tabulary tabvar talk 
	  tamethebeast tdsfrmath
          ted templates-fenn templates-sommer tengwarscript
          tensor termlist teubner tex-gyre texilikecover texmate
          texpower texshade
          textcase textfit textopo textpath textpos
          theoremref thesis-titlepage-fhac
          thinsp thmtools thumb thumbpdf thuthesis ticket tikz-inet
          timetable titlefoot titlesec
          titling tocbibind
          tocloft todo todonotes
          tokenizer toolbox tools toptesi totpages tracking
          trajan translator tree-dvips trfsigns trivfloat trsym
          tufte-latex tugboat tugboat-plain turnstile twoup txfonts Type1fonts
          typedref typogrid
        uebungsblatt ucthesis uhrzeit uiucthesis ulsy umich-thesis uml umlaute
          umthesis umtypewriter underlin undertilde units unitsdef
          universa unroman
          upmethodology upquote urlbst ushort ut-thesis uwthesis
        vancouver variations varindex varsfromjobname vaucanson-g
          vector velthuis venn verbatimbox verbatimcopy verse versions vertex
          vhistory visualfaq vmargin vntex volumes vpe vwcol vxu
        wadalab wallpaper warning warpcol williams wordlike wrapfig
        xargs xcolor xdoc xecyr xelibertine xepersian
          xetex-def xetex-pstricks xetexfontinfo
          xetexref xfor xgreek xifthen
          xkeyval xlop xltxtra xmpincl xnewcommand xoptarg xpackages
          xq xskak xstring xtab xtcapts xunicode xyling xypic-tut-pt xytree
        york-thesis yplan
        ziffer zwgetfdate
    ); 


exit (&main ());

sub main
{
  # get the Master dir and texlive.tlpdb
  chomp ($Master = `cd $mydir/../.. && pwd`);
  $tlpdb = TeXLive::TLPDB->new ("root" => $Master);
  die "Cannot find tlpdb in $Master!" unless defined $tlpdb;

  $OPT{"verbose"} = 0;
  if ($ARGV[0] eq "--verbose") {
    $OPT{"verbose"} = 1;
    shift @ARGV;
  }
  
  if ($ARGV[0] eq "--list-not-treated") {
    print "TeX Live packages not in $0:\n";
    for my $b (&normal_tlps ()) {
      print "$b\n" if ! grep (/^$b$/, @WorkingTLP);
    }
    @ARGV = (); # no normal checks

  } elsif ($ARGV[0] eq "--check") {
    # check all/only those packages we have actually run through this mill.
    @ARGV = @WorkingTLP;
  } elsif ($ARGV[0] eq "--check-all") {
    @ARGV = &normal_tlps ();
  }

  my $errcount = 0;
  for my $tlp (@ARGV) {
    print "checking $tlp..." if $OPT{"verbose"};
    $errcount += &do_tlp ($tlp);
  }
  return $errcount;
}

# gives a list with only the 'normal' packages,
# that is, excluding meta-packages and binary packages
# (and hyphen for the moment)
# 
sub normal_tlps
{
  my @normal;
  my $non_normal = `ls $Master/bin`;
  $non_normal =~ s/\n/\$|/g;
  $non_normal .= '^0+texlive|^bin-|^collection-|^scheme-|^texlive-|^hyphen-';
  foreach ($tlpdb->list_packages) {
    push (@normal, $_) unless (/$non_normal/);
  }
  return @normal;
}


# Return 1 if package needs updating, 0 if ok.
# 
sub do_tlp
{
  my ($tlpn) = @_;
  my $needed = 0;
  
  my $tlp = $tlpdb->get_package($tlpn);
  if (not(defined($tlp))) {
    warn "$0: no package $tlpn\n";
    return 1;
  }

  chomp (my $ctan_dir = `$mydir/tlpkginfo --prepare '$tlpn'`);
  if (! $ctan_dir) {
    warn "$0: oops, no CTAN directory for $tlpn, fix fix\n";
    return ();
  }
  my @tpm_files = ();
  push @tpm_files, $tlp->runfiles;
  push @tpm_files, $tlp->docfiles;
  push @tpm_files, $tlp->srcfiles;
  # we don't push bin files, should we?
  
  my @compared = ();
  for my $file (@tpm_files) {
#warn "checking file $file\n";
    my $tl_file = "$Master/$file";
    if (! -e $tl_file) {
      warn "$tl_file: TL file missing\n";
      next;
    }
    
    (my $basefile = $file) =~ s,^.*/,,;
    chomp (my @ctan_files = `find $ctan_dir/ -name $basefile`);
#warn "ctan find $basefile: @ctan_files\n";
    # 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];
#warn "ctan file is $ctan_file\n";
    if (! -e $ctan_file) {
      # maybe it'll be there with a case change in the name
      chomp (@ctan_files = `find $ctan_dir/ -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 sometimes regenerate pdf's for TL, so we 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 "# $tlpn\ndiff $ctan_file $tl_file\n";
      $needed = 1;
      last;
    }
  }
  
  # xx check ctan dir for new files
  
  if (@compared == 0) {
    warn "\n$tlpn: no files to compare in $ctan_dir, fixme!\n";
    warn "(tpm_files = @tpm_files)\n";
  } elsif ($needed == 0) {
    print "ok, " . (@compared + 0) . " compared (@compared)\n"
      if $OPT{"verbose"};
  }

  # clean up the tmpdir possibly created when invoking 'tlpkginfo --prepare'
  chomp (my $ctan_root = `tlpkginfo --ctan-root`);
  system ("rm -rf $ctan_dir") unless ($ctan_dir =~ m#^$ctan_root#);

  return $needed;
}



# 0 if files are the same, 1 if they are different.
# 
sub files_differ
{
  my ($tl_file,$ctan_file) = @_;
#warn "comparing $ctan_file $tl_file\n";
  return system ("$mydir/cmp-textfiles $ctan_file $tl_file");
}

# vim: set ts=8 sw=2 expandtab: