#!/usr/bin/env perl use strict; $^W=1; my $prj = 'latex-tds'; my $file = 'build.pl'; my $version = cvs('$Revision: 1.102 $'); my $date = cvs('$Date: 2006/08/28 09:42:43 $'); my $author = 'Heiko Oberdiek'; my $copyright = "Copyright 2006 $author"; chomp(my $license = <<"END_LICENSE"); % $copyright % % This file is part of project `$prj'. % % It may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status `maintained'. % % The Current Maintainer of this work is Heiko Oberdiek. % % See `readme.txt' for a list of all files belonging to the % project `$prj' and additional information. % END_LICENSE my $time_start = time; my $url_ctan = 'ftp://dante.ctan.org/tex-archive'; my $url_ams = 'ftp://ftp.ams.org/pub/tex'; my @required_list = ( 'amslatex', 'babel', 'psnfss', 'cyrillic', 'graphics', 'tools' ); my @pkg_list = ('base', @required_list, $prj, 'source', 'tds'); my $zip_comment = <<'END_ZIP_COMMENT'; ************************************************** * This file is part of project 'latex-tds', see * * CTAN:macros/latex/contrib/latex-tds/readme.txt * ************************************************** END_ZIP_COMMENT my $error = "!!! Error:"; my $dir_incoming = 'incoming'; my $dir_incoming_ctan = "$dir_incoming/ctan"; my $dir_incoming_ams = "$dir_incoming/ams"; my $dir_build = 'build'; my $dir_lib = 'lib'; my $dir_license = 'license'; my $dir_tex = 'tex'; my $dir_patch = 'patch'; my $dir_distrib = 'distrib'; chomp(my $cwd = `pwd`); my $jar_pdfbox_rewrite = "$cwd/$dir_lib/pdfbox-rewrite.jar"; my $jar_multivalent = "$cwd/$dir_lib/Multivalent20060102.jar"; my $file_zip_comment = "$cwd/$dir_build/zip-comment.txt"; my $file_tmp = "$cwd/$dir_build/tmp.pdf"; my $file_tmp_o = "$cwd/$dir_build/tmp-o.pdf"; my $file_ziptimetree = get_perl_script('ziptimetree'); my $file_adjust_checksum = get_perl_script('adjust_checksum'); my $prg_checksum = $file_adjust_checksum; my $prg_bibtex = "bibtex"; my $prg_chmod = "chmod"; my $prg_cp = 'cp -p'; my $prg_curl = 'curl'; my $prg_docstrip = 'tex -shell-escape'; my $prg_epstopdf = 'epstopdf'; my $prg_find = 'find'; my $prg_java = 'java'; my $prg_ls = "ls"; my $prg_makeindex = 'makeindex'; my $prg_mkdir = 'mkdir'; my $prg_mv = 'mv'; my $prg_patch = "patch"; my $prg_pdflatex = 'pdflatex'; my $prg_rm = "rm"; my $prg_rsync = "rsync"; my $prg_sed = "sed"; my $prg_sort = "sort"; my $prg_unzip = 'unzip'; my $prg_wget = 'wget'; my $prg_zip = 'zip'; my $prg_ziptimetree = $file_ziptimetree; $ENV{'TEXINPUTS'} = "$cwd/tex:.:texmf/tex//:"; $ENV{'BSTINPUTS'} = '.:texmf/bibtex//:'; # amslatex $ENV{'TFMFONTS'} = 'texmf/fonts/tfm//:'; # psnfss $ENV{'VFFONTS'} = 'texmf/fonts/vf//:'; # psnfss $ENV{'INDEXSTYLE'} = '.:texmf/makeindex//:'; # babel sub install ($@); ### Print title { my $line = "Building $prj, $date $version, $copyright"; print "$line\n", "=" x length($line), "\n"; } ### Option handling my $usage = <<"END_OF_USAGE"; Usage: build.pl [options] General options: --(no)download (check for newer files, disabled by default) --(no)postprocess (pdf files are postprocessed, enabled by default) Module options: --all (select all modules) END_OF_USAGE map { $usage .= " --(no)$_\n"; } @pkg_list; my $opt_download = 0; my $opt_postprocess = 1; my $opt_all = 0; my %modules; my @list_modules; use Getopt::Long; GetOptions( ( map { ("$_!" => \$modules{$_}); } @pkg_list ), 'all' => sub { $opt_all = 1; map { $modules{$_} = 1; } @pkg_list; }, 'download!' => \$opt_download, 'postprocess!' => \$opt_postprocess ) or die $usage; @ARGV == 0 or die $usage; @list_modules = grep { $modules{$_}; } @pkg_list; info("Build modules: @list_modules"); ### Download { section('Download'); sub download_ctan ($$) { my $file = shift; my $ctan_path = shift; ensure_directory($dir_incoming_ctan); download("$dir_incoming_ctan/$file.zip", "$url_ctan/$ctan_path/$file.zip"); } sub download_ams ($) { my $file = shift; ensure_directory($dir_incoming_ams); download("$dir_incoming_ams/$file.zip", "$url_ams/$file.zip"); } sub download ($$) { my $file = shift; my $url = shift; return 1 if -f $file and !$opt_download; info("download $url\n --> $file"); my $cmd = $prg_curl; $cmd .= " --disable-epsv"; # for ftp.ams.org $cmd .= " --time-cond $file" if -f $file; # download only if newer $cmd .= " --remote-time"; # set file date $cmd .= " --output $file"; # target file $cmd .= " $url"; # url run($cmd); -f $file or die "$error Download failed ($url)!\n"; } download_ctan('base', 'macros/latex'); download_ctan('tools', 'macros/latex/required'); download_ctan('graphics', 'macros/latex/required'); download_ctan('cyrillic', 'macros/latex/required'); download_ctan('babel', 'macros/latex/required'); download_ctan('amslatex', 'macros/latex/required'); download_ctan('psnfss', 'macros/latex/required'); download_ctan('tds', ''); download_ams('amslatex'); download_ams('amsrefs'); } ### Remove previous build section('Remove previous build'); { foreach my $pkg (@list_modules) { run("$prg_rm -rf $dir_build/$pkg"); my $distribfile = "$dir_distrib/$pkg.zip"; unlink $distribfile if -f $distribfile; } } ### Unpack section('Unpacking'); { sub unpacking ($$$) { my $pkg = shift; my $zipfile = shift; my $dir = shift; run("$prg_unzip $zipfile -d$dir"); } sub unpack_ctan ($) { my $pkg = shift; $modules{$pkg} or return 1; unpacking($pkg, "$dir_incoming_ctan/$pkg.zip", $dir_build); } sub unpack_ams ($) { my $name = shift; $modules{'amslatex'} or return 1; unpacking('amslatex', "$dir_incoming_ams/$name.zip", "$dir_build/amslatex/texmf"); } sub unpack_psnfss ($) { my $name = shift; my $dir = "$dir_build/psnfss"; $modules{'psnfss'} or return 1; unpacking('psnfss', "$dir/$name.zip", "$dir/texmf"); } ensure_directory($dir_build); unpack_ctan('base'); map { unpack_ctan($_); } @required_list; unpack_ams('amslatex'); unpack_ams('amsrefs'); unpack_psnfss('lw35nfss'); unpack_psnfss('freenfss'); unpack_ctan('tds'); } ### Patches section('Patches'); { ; # if ($modules{'base'}) { patch("base/classes.dtx"); } if ($modules{'psnfss'}) { chdir "$dir_build/psnfss"; run("$prg_checksum psfonts.dtx"); chdir $cwd; } if ($modules{'babel'}) { map { patch("babel/$_"); } qw[ greek.ins bbcompat.dtx athnum.dtx albanian.dtx finnish.dtx frenchb.dtx ]; } } ### Install TDS/source section('Install source'); { sub install_gen_source ($$@) { my $fmt = shift; my $pkg = shift; my @list = @_; $modules{$pkg} or return 1; chdir "$dir_build/$pkg"; install "texmf/source/$fmt/$pkg", @list; chdir $cwd; } sub install_source ($@) { my $pkg = shift; my @list = @_; install_gen_source('latex', $pkg, @list); } install_source 'base', qw[ *.dtx *.fdd *.ins *guide.tex ltnews*.tex source2e.tex ltx3info.tex latexbug.el ]; install_source 'tools', qw[ *.dtx *.ins ]; install_source('graphics', '*.dtx', '*.ins', '*.tex' ); install_source('cyrillic', '*.dtx', '*.fdd', '*.ins', ); install_source('psnfss', 'psnfss2e.tex', '*.dtx', '*.ins' ); install_gen_source('generic', 'babel', qw[ *.ins *.dtx *.fdd *.dat usage.tex tb*.tex ]); # babel/manifest.txt: to be removed in a future release # already removed: bghyphen.tex, bghyphsi.tex install_gen_source('generic', 'babel', qw[ mik2t2.tex catmik.tex lahyph.tex ]); # *.tex install_gen_source('', 'tds', qw[ Makefile tds2texi.el tdsguide.cls tds.sed tds.tex ]); } ### Patch source files after source install section('Paches after source install'); { if ($modules{'base'}) { chdir "$dir_build/base"; # ltdirchk.dtx must be patched to fool it in # not having texsys.cfg { my $file_dtx = 'ltdirchk.dtx'; my $file_org = 'ltdirchk.dtx.org'; rename $file_dtx, $file_org; open(IN, '<', $file_org) or die "$error Cannot open `$file_org'!\n"; open(OUT, '>', $file_dtx) or die "$error Cannot write `$file_dtx'!\n"; while () { s/openin15=texsys.cfg/openin15=texsys.cfg-not-found/; print OUT; } close(OUT); close(IN); } # base: TDS:makeindex/base -> TDS:makeindex/latex { my $file_ins = 'docstrip.ins'; my $file_org = 'docstrip.ins.org'; rename $file_ins, $file_org; open(IN, '<', $file_org) or die "$error Cannot open `$file_org'!\n"; open(OUT, '>', $file_ins) or die "$error Cannot write `$file_ins'!\n"; while () { s|makeindex/base|makeindex/latex|; print OUT; } close(OUT); close(IN); } chdir $cwd; } } ### Docstrip section('Docstrip'); { sub docstrip ($$) { my $pkg = shift; my $ins = shift; $modules{$pkg} or return 1; chdir "$dir_build/$pkg"; run("$prg_docstrip $ins.ins"); chdir $cwd; 1; } docstrip('base', 'unpack'); docstrip('psnfss', 'psfonts'); docstrip('cyrillic', 'cyrlatex'); docstrip('graphics', 'graphics'); docstrip('graphics', 'graphics-drivers'); docstrip('tools', 'tools'); docstrip('babel', 'babel'); } section('TDS cleanup'); { if ($modules{'amslatex'}) { sub cleanup_tds ($@) { my $dir_tds = "$dir_build/amslatex/texmf"; my $sub_tree = shift; my @list = map { glob("$dir_tds/$sub_tree/$_"); } @_; unlink grep { -f $_; } @list; map { rmdir; } grep { -d $_; } @list; } cleanup_tds 'bibtex', qw[ bib/ams bib ]; cleanup_tds 'source/latex/amscls', qw[ *.bst *.template diffs-c.txt ]; cleanup_tds 'source/latex/amsmath', qw[ diffs-m.txt amstex.sty ]; cleanup_tds 'source/latex/amsrefs', qw[ *.dvi *.pdf amsrefs.faq cite-x*.tex jr.bib gktest.ltb ]; cleanup_tds 'doc/latex/amscls', qw[ amsrefs.dvi textcmds.dvi ]; # CTAN:macros/latex/required/amslatex/other/* run("$prg_cp $dir_build/amslatex/other/amsbooka.sty" . " $dir_build/amslatex/texmf/tex/latex/amscls/amsbooka.sty"); } if ($modules{'babel'}) { my $tds_dir = "$dir_build/babel/texmf"; my $from_dir = "$tds_dir/tex/generic/babel"; ### Correction for *.drv files run("$prg_mv $from_dir/*.drv $dir_build/babel"); ### Correction for *.ist files my $dir_dest = "$tds_dir/makeindex/babel"; ensure_directory($dir_dest); run("$prg_mv $from_dir/*.ist $dir_dest"); } } ### Install TDS/tex, TDS/doc files section('Install tex doc'); { if ($modules{'base'}) { chdir "$dir_build/base"; install 'texmf/doc/latex/base', qw[ 00readme.txt autoload.txt bugs.txt changes.txt l*.txt manifest.txt patches.txt t*.txt ]; install 'texmf/tex/latex/base', qw[ *.cls ltpatch.ltx idx.tex lablst.tex latexbug.tex lppl.tex testpage.tex ltxcheck.tex sample2e.tex small2e.tex ]; install 'texmf/tex/latex/base', qw[ texsys.cfg ]; chdir $cwd; } if ($modules{'tools'}) { chdir "$dir_build/tools"; install 'texmf/doc/latex/tools', qw[ changes.txt manifest.txt readme.txt ]; chdir $cwd; } if ($modules{'graphics'}) { chdir "$dir_build/graphics"; install('texmf/doc/latex/graphics', '*.txt' ); install('texmf/tex/latex/graphics', '*.def' ); chdir $cwd; } if ($modules{'cyrillic'}) { chdir "$dir_build/cyrillic"; install('texmf/doc/latex/cyrillic', '*.txt' ); chdir $cwd; } if ($modules{'psnfss'}) { chdir "$dir_build/psnfss"; install('texmf/doc/latex/psnfss', '*.txt' ); install('texmf/doc/latex/psnfss/test', '*test*.tex' ); install('texmf/fonts/enc/dvips/psnfss', '8r.enc' ); install('texmf/fonts/map/dvips/psnfss', '*.map' ); chdir $cwd; } if ($modules{'babel'}) { chdir "$dir_build/babel"; install('texmf/doc/generic/babel', qw[ *.txt *.heb *.bbl *.dat *.skeleton install.OzTeX* ]); install('texmf/tex/generic/hyphen', qw[ iahyphen.tex icehyph.tex ]); chdir $cwd; } if ($modules{'tds'}) { chdir "$dir_build/tds"; install('texmf/doc/tds', qw[ README ChangeLog tds.html ]); install('texmf/doc/info', qw[ tds.info ]); chdir $cwd; } my $dummy = <<'END_DUMMY'; if ($modules{'babel'}) { chdir "$dir_build/babel"; install('texmf/tex/generic/bghyph', 'bghyphen.txt', 'bghyphsi.tex', 'catmik.tex', 'mik2t2.tex' ); install('texmf/tex/generic/hyphen', 'icehyph.tex', 'lahyph.tex' ); chdir $cwd; } END_DUMMY } ### Generate documentation for base if ($modules{'base'}) { section('Documenation: base'); sub base_guide ($) { my $guide = "$_[0]guide"; run("$prg_pdflatex $guide"); run("$prg_pdflatex $guide"); run("$prg_pdflatex $guide"); install_pdf('base', $guide); 1; } sub simple_gen ($$) { my $ext = shift; my $base = shift; my $file = "$base.$ext"; run("$prg_pdflatex $file"); run("$prg_pdflatex $file"); run("$prg_pdflatex $file"); install_pdf('base', $base); 1; } sub complex_dtx ($) { my $base = shift; my $dtx = "$base.dtx"; run("$prg_pdflatex $dtx"); run_makeindex("$base.idx", 'gind.ist'); run_makeindex("$base.glo", 'gglo.ist', "$base.gls"); run("$prg_pdflatex $dtx"); run_makeindex("$base.idx", 'gind.ist'); run_makeindex("$base.glo", 'gglo.ist', "$base.gls"); run("$prg_pdflatex $dtx"); run("$prg_pdflatex $dtx"); # hydestopt install_pdf('base', "$base"); 1; } sub book_err ($) { my $base = shift; my $err = "$base.err"; run("$prg_pdflatex $err"); run("$prg_sed -i -e '" . 's/\\\\endinput/\\\\input{errata.cfg}\\n\\\\endinput/' . "' $base.cfg"); run("$prg_pdflatex $err"); run("$prg_pdflatex $err"); run("$prg_pdflatex $err"); # hydestopt install_pdf('base', "$base"); 1; } chdir "$dir_build/base"; run("$prg_pdflatex source2e"); run_makeindex('source2e.idx', 'gind.ist'); run_makeindex('source2e.glo', 'gglo.ist', 'source2e.gls'); run("$prg_pdflatex source2e"); run_makeindex('source2e.idx', 'gind.ist'); run_makeindex('source2e.glo', 'gglo.ist', 'source2e.gls'); run("$prg_pdflatex source2e"); run("$prg_pdflatex source2e"); # hydestopt install_pdf('base', 'source2e'); map { complex_dtx $_ } qw[ classes doc docstrip letter ]; map { simple_gen 'dtx', $_ } qw[ alltt exscale fixltx2e graphpap ifthen inputenc latex209 latexsym ltxdoc makeindx newlfont oldlfont proc slides syntonly utf8ienc ]; map { simple_gen 'fdd', $_ } qw[ cmfonts slifonts ]; map { book_err $_ } qw[ tlc2 lb2 grphcomp webcomp webcompg ]; run("$prg_sed -i -e '" . 's/\\\\documentclass{article}/' . '\\\\documentclass{article}\\n\\\\input{manual.cfg}/' . "' manual.err"); run("$prg_pdflatex manual.err"); run("$prg_pdflatex manual.err"); run("$prg_pdflatex manual.err"); # hydestopt install_pdf('base', 'manual'); base_guide('cfg'); base_guide('cls'); base_guide('cyr'); base_guide('enc'); base_guide('fnt'); base_guide('mod'); base_guide('usr'); run("$prg_pdflatex doc_lppl"); run("$prg_pdflatex doc_lppl"); run("$prg_pdflatex doc_lppl"); # hydestopt run("$prg_mv doc_lppl.pdf lppl.pdf"); install_pdf('base', 'lppl'); run("$prg_pdflatex ltxcheck.drv"); run("$prg_pdflatex ltxcheck.drv"); install_pdf('base', 'ltxcheck'); my $code = <<'END_CODE'; \let\SavedDocumentclass\documentclass \def\documentclass[#1]#2{ \SavedDocumentclass[{#1}]{#2} \usepackage[colorlinks,pdfusetitle]{hyperref} } \input{ltx3info} END_CODE $code =~ s/\s//g; run("$prg_pdflatex '$code'"); run("$prg_pdflatex '$code'"); run("$prg_pdflatex '$code'"); # hydestopt install_pdf('base', 'ltx3info'); # for (my $i = 1; $i <= 17; $i++) { # my $ltnews = 'ltnews'; # $ltnews .= '0' if $i < 10; # $ltnews .= $i; # run("$prg_pdflatex $ltnews"); # run("$prg_pdflatex $ltnews"); # install_pdf('base', $ltnews); # } my $ltnews = 'ltnews'; my $lastissue = 0; map { $lastissue = $1 if /ltnews(\d+)\.tex/ and $lastissue < $1; } glob('ltnews*.tex'); my $cmd_ltnews = "$prg_pdflatex '\\def\\lastissue{$lastissue}\\input{$ltnews}'"; run($cmd_ltnews); run($cmd_ltnews); run($cmd_ltnews); install_pdf('base', $ltnews); chdir $cwd; } ### Generate documentation for tools if ($modules{'tools'}) { section('Documentation: tools'); chdir "$dir_build/tools"; my @list = glob("*.dtx"); map { s/\.dtx$//; } @list; foreach my $entry (@list) { run("$prg_pdflatex $entry.dtx"); run_makeindex("$entry.idx", 'gind.ist'); run_makeindex("$entry.glo", 'gglo.ist', "$entry.gls"); run("$prg_pdflatex $entry.dtx"); run_makeindex("$entry.idx", 'gind.ist'); run_makeindex("$entry.glo", 'gglo.ist', "$entry.gls"); run("$prg_pdflatex $entry.dtx"); run("$prg_pdflatex $entry.dtx"); # hydestopt install_pdf('tools', $entry); } # Generate overview my $infile = 'manifest.txt'; my $texfile = "$cwd/$dir_tex/tools.tex"; my @time = localtime(time); my ($mday, $month, $year) = splice @time, 3, 3; my $release_info = sprintf "%04d/%02d/%02d Tools overview (HO)", $year + 1900, $month + 1, $mday; open(OUT, ">$texfile") or die "$error Cannot open `$texfile'!\n"; print OUT <<"END_HEADER"; \\NeedsTeXFormat{LaTeX2e} \\ProvidesFile{tools.tex}% [$release_info] $license \\documentclass{tools-overview} \\begin{document} END_HEADER my $entry; my %db; open(IN, $infile) or die "$error Cannot open `$infile'!\n"; while () { next if /^%/; next if /^\s*$/; if (/^(\S+)\.dtx/) { $entry = $1; $db{$entry} = ''; next; } s/\\(\w+)/\\cs{\1}/g; s/(LaTeX|TeX)/\\\1\{\}/g; s/`([^']+)'/\\emph{\1}/g; s/Indent The/Indent the/; # typo s/Requies/Requires/; # typo $db{$entry} .= $_; } close(IN); $db{'layout'} = <<'END_LAYOUT'; Produces an overview of the layout of the current document. END_LAYOUT $db{'trace'} = <<'END_TRACE'; The package helps to suppress and to control the amount of tracing output (\cs{tracingall}) by taming calc and making NFSS less noisy. END_TRACE for my $entry (sort keys %db) { my $text = $db{$entry}; $text =~ s/^\s*/ /mg; chomp $text; print OUT <<"END_ENTRY"; \\entry{$entry}{% $text }% END_ENTRY } print OUT <<'END_TRAILER'; \end{document} END_TRAILER close(OUT); run("$prg_pdflatex tools.tex"); install_pdf('tools', 'tools'); chdir $cwd; } ### Generate documentation for cyrillic if ($modules{'cyrillic'}) { section('Documentation: cyrillic'); chdir "$dir_build/cyrillic"; my @list = (glob("*.dtx"), glob("*.fdd")); foreach my $entry (@list) { run("$prg_pdflatex $entry"); run("$prg_pdflatex $entry"); run("$prg_pdflatex $entry"); # hydestopt $entry =~ s/\.(dtx|fdd)$//; install_pdf('cyrillic', $entry); } chdir $cwd; } ### Generate documentation for graphics if ($modules{'graphics'}) { section('Documentation: graphics'); chdir "$dir_build/graphics"; my @list = glob("*.dtx"); map { s/\.dtx$//; } @list; foreach my $entry (@list) { run("$prg_pdflatex $entry.dtx"); run("$prg_pdflatex $entry.dtx"); run("$prg_pdflatex $entry.dtx"); # hydestopt install_pdf('graphics', $entry); } my $code = <<'END_CODE'; \makeatletter \let\documentclass\@@end \input{grfguide} END_CODE $code =~ s/\s//g; run("$prg_pdflatex '$code'"); run("$prg_epstopdf a.ps"); run("$prg_pdflatex grfguide"); run("$prg_pdflatex grfguide"); run("$prg_pdflatex grfguide"); install_pdf('graphics', 'grfguide'); chdir $cwd; } ### Generate documentation for amslatex if ($modules{'amslatex'}) { section('Documentation: amslatex'); sub makeindex ($) { my $doc = shift; my $style; $style = 'gind.ist' unless $doc eq 'amsldoc'; run_makeindex("$doc.idx", $style); } sub bibtex ($) { my $doc = shift; if ($doc =~ /^cite-x[bh]$/) { run("$prg_bibtex $doc"); } } sub generate_doc ($$) { my $amspkg = shift; my $doc = shift; my $ams_drv = "$cwd/$dir_tex/ams.drv"; symlink $ams_drv, "$doc.drv"; run("$prg_pdflatex $doc.drv"); makeindex($doc); bibtex($doc); run("$prg_pdflatex $doc.drv"); makeindex($doc); run("$prg_pdflatex $doc.drv"); makeindex($doc); run("$prg_pdflatex $doc.drv"); run("$prg_pdflatex $doc.drv") if $doc eq 'amsrefs'; install_pdf($amspkg, $doc); } chdir "$dir_build/amslatex/math"; symlink '../texmf', 'texmf'; map { generate_doc 'amsmath', $_; } qw[ amsldoc subeqn technote testmath amsbsy amscd amsgen amsmath amsopn amstext amsxtra ]; chdir $cwd; chdir "$dir_build/amslatex/classes"; symlink '../texmf', 'texmf'; map { generate_doc 'amscls', $_; } qw[ amsthdoc instr-l thmtest amsclass amsdtx amsmidx upref ]; chdir $cwd; chdir "$dir_build/amslatex/amsrefs"; symlink '../texmf', 'texmf'; map { generate_doc 'amscls', $_; } qw[ cite-xa cite-xb cite-xh cite-xs amsrefs amsxport ifoption mathscinet pcatcode rkeyval textcmds ]; chdir $cwd; } ### Generate documentation for psnfss if ($modules{'psnfss'}) { section('Documentation: psnfss'); chdir "$dir_build/psnfss"; run("$prg_pdflatex psfonts.dtx"); run("$prg_pdflatex psfonts.dtx"); install_pdf('psnfss', 'psfonts'); run("$prg_pdflatex psnfss2e.drv"); run("$prg_pdflatex psnfss2e.drv"); run("$prg_pdflatex psnfss2e.drv"); install_pdf('psnfss', 'psnfss2e'); chdir $cwd; } ### Generate documentation for babel if ($modules{'babel'}) { section('Documentation: babel'); sub install_babel_pdf ($) { install_gen_pdf('generic', 'babel', shift); } sub simple_doc ($) { my $file = shift; run("$prg_pdflatex $file"); run("$prg_pdflatex $file"); $file =~ s/\.\w{3}$//; install_babel_pdf($file); } sub generate_babel_doc ($) { my $doc = shift; my $drv = "$cwd/$dir_tex/ams.drv"; symlink $drv, "$doc.drv"; run("$prg_pdflatex $doc.drv"); run("$prg_pdflatex $doc.drv"); run("$prg_pdflatex $doc.drv"); run("$prg_pdflatex $doc.drv"); install_babel_pdf($doc); } chdir "$dir_build/babel"; my $greek_fdd = 'greek-fdd.drv'; open(OUT, ">$greek_fdd") or die "$error Cannot open `$greek_fdd'!\n"; print OUT "\\input{greek.fdd}\n"; close(OUT); map { simple_doc($_); } $greek_fdd, qw[ athnum.dtx grmath.dtx grsymb.dtx bbidxglo.dtx bbcompat.dtx greek-usage.tex ]; map { generate_babel_doc($_); } qw[ tb1202 tb1401 tb1604 ]; run("$prg_pdflatex babel.tex"); run_makeindex('babel.idx', 'bbind.ist'); run_makeindex('babel.glo', 'bbglo.ist', 'babel.gls'); run("$prg_pdflatex babel.tex"); run_makeindex('babel.idx', 'bbind.ist'); run_makeindex('babel.glo', 'bbglo.ist', 'babel.gls'); run("$prg_pdflatex babel.tex"); run("$prg_pdflatex babel.tex"); install_babel_pdf('babel'); chdir $cwd; } ### Generate documentation for tds if ($modules{'tds'}) { section('Documentation: tds'); chdir "$dir_build/tds"; my $file_tds = 'tds.tex'; my $file_tds_new = 'tds.new'; # make nicer references and use CVS date instead of current date open(IN, $file_tds) or die "$error Cannot open `$file_tds'!\n"; open(OUT, '>', $file_tds_new) or die "$error Cannot write `$file_tds_new'!\n"; while () { s/Appendix~\\ref/\\appref/g; s/Section~\\ref/\\secref/g; if (/^% \$Id:.* (\d\d\d\d)\/(\d\d)\/(\d\d) /) { print OUT <<"END_TEXT"; \\year=$1\\relax \\month=$2\\relax \\day=$3\\relax END_TEXT } print OUT; } close(OUT); close(IN); unlink('tds.aux'); run("$prg_pdflatex $file_tds_new"); run("$prg_pdflatex $file_tds_new"); run("$prg_pdflatex $file_tds_new"); install_gen_pdf('', 'tds', 'tds'); chdir $cwd; } ### Module source if ($modules{'source'}) { section('Module source'); my $dir_dest = "$dir_build/source/texmf/source/latex/latex-tds"; my $dir_scripts = "$dir_build/source/texmf/scripts"; install $dir_dest, qw[ build.pl readme.txt ]; install "$dir_dest/tex", glob("$dir_tex/*.*"); install "$dir_dest/patch", glob("$dir_patch/*.*"); install "$dir_dest/lib", $file_ziptimetree; install "$dir_dest/lib", $file_adjust_checksum; install "$dir_dest/license", "$dir_license/lppl.txt"; install "$dir_dest/license/ziptimetree", "$dir_license/ziptimetree/lgpl.txt"; install $dir_distrib, 'readme.txt'; } ### Module latex-tds if ($modules{$prj}) { section('Module latex-tds'); my $dir = "$dir_build/$prj"; ensure_directory($dir); my $cmd_rsync = "$prg_rsync " . join ' ', qw[ --recursive --times --perms --owner --group --hard-links ]; for (@pkg_list) { next if $_ eq $prj; my $reftree = "$dir_build/$_"; next unless -d "$reftree/texmf"; run("$cmd_rsync --link-dest=$cwd/$reftree $reftree/texmf $dir"); } } ### Pack result section('Distrib'); { ensure_directory($dir_distrib); # write zip comment file open(OUT, '>', $file_zip_comment) or die "$error Cannot write file `$file_zip_comment'!\n"; print OUT $zip_comment; close OUT; for my $pkg (@list_modules) { my $dir_tds = "$dir_build/$pkg/texmf"; my $file_distrib = "$cwd/$dir_distrib/$pkg.zip"; if (-d $dir_tds) { run_zip($file_distrib, $dir_tds); } else { print "!!! Warning: Missing TDS tree for `$pkg'!\n"; } } } ### Display result section('Result'); { for my $pkg (@list_modules) { my $file = "$dir_distrib/$pkg.zip"; if (-f $file) { system("$prg_ls -l $file"); system("$prg_ls -l $dir_distrib/readme.txt")if $pkg eq 'source'; } else { print "!!! Warning: Missing distribution for `$pkg'!\n"; } } # display time my $time_diff = time - $time_start; my $time_str = sprintf "%d:%02d:%02d\n", $time_diff / 3600, ($time_diff % 3600) / 60, ($time_diff % 3600) % 60; $time_str =~ s/^0:0?//; print "* Elapsed time: $time_str\n"; } sub install ($@) { my $dir_target = shift; my @list = @_; ensure_directory($dir_target); run("$prg_cp @list $dir_target/"); 1; } sub install_gen_pdf ($$$) { my $fmt = shift; my $pkg = shift; my $file_base = shift; my $file_source = "$file_base.pdf"; my $dir_dest = "texmf/doc/$fmt/$pkg"; my $file_dest = "$dir_dest/$file_base.pdf"; ensure_directory($dir_dest); if ($opt_postprocess) { printsize($file_source, 0); if (-f $jar_pdfbox_rewrite) { run("$prg_java -jar $jar_pdfbox_rewrite $file_source $file_tmp"); } else { run("$prg_cp $file_source $file_tmp"); } run("$prg_java -cp $jar_multivalent tool.pdf.Compress -old $file_tmp"); run("$prg_mv $file_tmp_o $file_dest"); printsize($file_dest, 1); } else { run("$prg_cp $file_source $file_dest"); } 1; } sub install_pdf ($$) { my $pkg = shift; my $file_base = shift; install_gen_pdf('latex', $pkg, $file_base); } sub printsize ($$) { my $file = shift; my $modus = shift; my $size = (stat($file))[7]; $size =~ s/(\d)(\d{6})$/$1.$2/; $size =~ s/(\d)(\d{3})$/$1.$2/; $size = " " x (9 - length($size)) . $size; if ($modus == 0) { print "*" x 78 . "\n"; print "* $size $file\n"; } else { print "* $size $file\n"; print "*" x 78 . "\n"; print "\n"; } } sub ensure_directory ($) { my $dir = shift; return 1 if -d $dir; run("$prg_mkdir -p '$dir'"); return 1 if -d $dir; die "$error Cannot generate directory `$dir'!\n"; } sub section ($) { my $title = shift; print "\n=== $title ===\n"; 1; } sub run ($) { my $cmd = shift; info("system: $cmd"); my $ret = system($cmd); if ($ret != 0) { if ($? == -1) { die "$error Failed to execute: $!\n"; } elsif ($? & 127) { die "$error Child died with signal " . ($? & 127) . (($? & 128) ? ' with coredump' : '') . "!\n"; } else { die "$error Child exited with value " . ($? >> 8) . "!\n"; } } 1; } sub run_makeindex ($;$$) { my $input_file = shift; my $style_file = shift; my $output_file = shift; return 1 unless -f $input_file; my $cmd = $prg_makeindex; $cmd .= " -s $style_file" if $style_file; $cmd .= " -o $output_file" if $output_file; $cmd .= " $input_file"; run($cmd); } sub run_zip ($$) { my $zip_file = shift; my $dir_start = shift; run("$prg_ziptimetree --verbose --noroot $zip_file $dir_start"); run("$prg_zip -z $zip_file <$file_zip_comment"); } sub info ($) { my $msg = shift; print "* $msg\n"; 1; } sub cvs ($) { $_ = shift; s/^\$\w+:?\s*(\S*).*\$$/$1/; $_ = "v$_" if /\./; $_; } sub patch ($) { my $file = shift; my $patch = $file; $patch =~ s/^.*\/([^\/]+)$/$1/; run("$prg_patch $dir_build/$file $dir_patch/$patch.diff"); } sub get_perl_script ($) { # Either the source of latex-tds is unpacked as TDS tree, # then the perl script is below TDS:scripts/ # or it can be put into the lib directory $dir_lib that I am using. my $script = shift; if (-f "$cwd/$dir_lib/$script.pl") { $script = "$cwd/$dir_lib/$script.pl"; } else { if (-f "$cwd/../../../scripts/latex-tds/$script.pl") { $script = "$cwd/../../../scripts/latex-tds/$script.pl"; } else { $script = "$cwd/../../../scripts/$script/$script.pl"; } } die "$error Script $script.pl not found!\n" unless -f $script; run("$prg_chmod +x $script") unless -x $script; die "$error Script $script is not executable!\n" unless -x $script; $script; } __END__