diff options
author | Karl Berry <karl@freefriends.org> | 2007-09-18 18:08:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-09-18 18:08:12 +0000 |
commit | 4bcdf188ddd28090273b1a0d5463b8490bb43474 (patch) | |
tree | c6e1a9b7a37a16929e3c888d26445c5d6e64f597 /Master/tlpkg | |
parent | d48fdb47c2b84e93e19ba16d13a96198144441dd (diff) |
move to tlpkg/bin
git-svn-id: svn://tug.org/texlive/trunk@4973 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rwxr-xr-x | Master/tlpkg/bin/tlpkginfo | 205 |
1 files changed, 205 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/tlpkginfo b/Master/tlpkg/bin/tlpkginfo new file mode 100755 index 00000000000..d1e9d3d377e --- /dev/null +++ b/Master/tlpkg/bin/tlpkginfo @@ -0,0 +1,205 @@ +#!/usr/bin/env perl +# $Id$ +# Return information given a TL package name (i.e., a tpm file name). +# We use local copies of CTAN and the TeX Catalogue. +# +exit (&main ()); + +sub main +{ + $CTAN = $ENV{"CTAN"} || "/home/ftp/tex-archive"; + $TMPDIR = $ENV{"TMPDIR"} || "/tmp"; + $CATALOGUE = $ENV{"TEX_CATALOGUE"} || "/home/httpd/html/catalogue/entries"; + -d "$CATALOGUE/k" + || die "$0: TEX_CATALOGUE ($CATALOGUE) must point to entries/ subdir" + . " of a TeX Catalogue checkout.\n"; + + if ($ARGV[0] eq "--ctan-dir") { + return &find_ctan_dir ($ARGV[1]); + + } elsif ($ARGV[0] eq "--ctan-root") { + print "$CTAN\n"; + return 0; + + } else { + die "Usage: $0 --ctan-dir PKGNAME or --ctan-root (not \"@ARGV\").\n"; + } +} + + +# +# Return 0 for success if we find a path (and print it on stdout), else +# return 1. +# +sub find_ctan_dir +{ + my ($me) = @_; + return 1 unless $me; + + # regrettably, this list of amslatex packages is duplicated in ctan2tl. + # unavoidable since ctan throws them all together, but we don't want + # to, to preserve the package-per-directory name. + if ($me =~ /^(ams|amscls|amsltx2|amsmath|amsrefs)$/) { + $me = "amslatex"; + } + + # use explicit catalogue name if given in tlpsrc. + $me = &tlpsrc_find_catalogue ($me) || $me; + + # The CTAN path to a package is sometimes stored in the TeX Catalogue, + # but old entries don't have it, etc. Still, we want to use it if present. + my $ctan_dir = &catalogue_find_ctan_path ($me); + if (! $ctan_dir) { + # fall back on many special cases + (my $menobin = $me) =~ s,^bin-,,; + (my $menopowerdot = $me) =~ s,^powerdot-,,; + (my $menotype1 = $me) =~ s,-type1$,,; + + 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/hyphenation/$me", # bghyphen + "language/hebrew/$me", # cjhebrew + "language/greek/package-babel/$me", # ibycus-babel + "language/devanagari/$me", # velthuis + "language/croatian/$me", # hrlatex + "language/coptic/$me", # cbcoptic + "info/spanish/$me", # guia-bibtex + "info/symbols/$me", # comprehensive + "info/math/voss/$me", # mathmode + "info/bibtex/$me", # tamethebeast + "info/$me", # Type1fonts + "help/$me", # es-tex-faq + "graphics/$me", # sparklines + "graphics/metapost/contrib/macros/$me", # mpattern + "graphics/pstricks/contrib/pedigree/$me", # pst-pdgr + "graphics/pstricks/contrib/$me", # pstricks-add + "fonts/$me", # MnSymbol + "fonts/utilities/$me", # accfonts + "fonts/ps-type1/$me", # cm-super + "fonts/ps-type1/$menotype1", # esint-type1 + "fonts/greek/$me", # lfb + "fonts/gothic/$me", # blacklettert1 + "fonts/cyrillic/$me/texmf", # lh + "fonts/chess/$me", # skaknew + "biblio/bibtex/contrib/$me", # dk-bib + ) { + if (-d "$CTAN/$dir") { + $ctan_dir = $dir; + last; + } + } + + # names totally dissimilar + $ctan_dir = "fonts/fourier-GUT" if $me eq "fourier"; + $ctan_dir = "graphics/pdftex" if $me eq "pdftex-def"; + $ctan_dir = "info/biblio" if $me eq "beebe"; + $ctan_dir = "info/epslatex/french" if $me eq "epslatex-fr"; + $ctan_dir = "info/italian/amsldoc" if $me eq "amsldoc-it"; + $ctan_dir = "info/italian/amsthdoc" if $me eq "amsthdoc-it"; + $ctan_dir = "info/tex-references" if $me eq "tex-refs"; + $ctan_dir = "info/translations/vn" if $me eq "ntheorem-vn"; + $ctan_dir = "language/armenian/armtex" if $me eq "armenian"; + $ctan_dir = "language/basque" if $me eq "hyphen-basque"; + $ctan_dir = "language/hungarian/babel" if $me eq "magyar"; + $ctan_dir = "language/hyphenation/elhyphen" if $me eq "hyphen-greek"; + $ctan_dir = "macros/latex/contrib/misc" if $me eq "ltxmisc"; + $ctan_dir = "macros/generic" if $me eq "genmisc"; + + # do last, for sake of subdirs above. + $ctan_dir = "language/hyphenation" + if $me =~ /^hyphen-/ && ! $ctan_dir; + } + + # prepend ctan root if not an absolute dir (this happens when we make + # a temp dir). + $ctan_dir = "$CTAN/$ctan_dir" if $ctan_dir =~ m,^[^/],; + print "$ctan_dir\n" if $ctan_dir; + return $ctan_dir ? 0 : 1; +} + + + +# If the .tlpsrc file for ME has a catalogue entry, return it. +# Else return empty string. +# +sub tlpsrc_find_catalogue +{ + my ($me) = @_; + + chomp (my $mydir = `dirname $0`); + chomp (my $tlpsrcdir = `cd $mydir/../../Master/tlpkg/tlpsrc && /bin/pwd`); + my $tlpsrc = "$tlpsrcdir/$me.tlpsrc"; + if (! -r $tlpsrc) { + warn "$0: no tlpsrc $tlpsrc\n"; + return ""; + } + + chomp (my $cat = `awk '\$1 == "catalogue" {print \$2}' $tlpsrc`); + return $cat; +} + + + +# look up ctan path for given package name in catalogue entry. +# xml is too hard to parse, so just look for the <ctan path...> entry. +# Sometimes there is a single file, but worry about that later. +# +# Return the ctan path if found (without leading /), or undef. +# +sub catalogue_find_ctan_path +{ + my ($pkgname) = @_; + + my $firstchar = substr ($pkgname, 0, 1); + my $catfile = "$CATALOGUE/$firstchar/$pkgname.xml"; + return undef unless -r $catfile; + + # get the raw line from the catalogue file. (let's hope it's one line.) + my $ctan_path = `sed -n "s,^ *<ctan path='/,,p" $catfile`; + return undef unless $ctan_path; # in case it's not present at all + + # extract just the dir or file name, without options, etc. + (my $ctan_loc = $ctan_path) =~ s,'/>,,; + $ctan_loc =~ s,' .*,,; + chomp ($ctan_loc); + + # if the Catalogue lists the path as a single file, there are two + # possibilities: (1) it really is a single file, e.g., texilikecover, + # in which case we copy that file into a temp dir and return that temp + # dir; (2) it is actually in its own directory, e.g., ifxetex, in + # which case we return undef here and let the code above find it. + # (The Catalogue maintainers do not consider this a problem for + # various reasons.) + # + if ($ctan_path =~ /file='true'/) { + return undef if $ctan_path =~ m,/$pkgname/,; # pkg dir somewhere in path + + # ok, we will copy to temp dir. + my $pkgdir = "$TMPDIR/tl.$pkgname"; + system ("rm -rf $pkgdir"); + mkdir ($pkgdir, 0777); + + warn "$0: copying single file:\n"; + warn "$0: $CTAN/$ctan_loc\n"; + unless (system ("cp -p '$CTAN/$ctan_loc' '$pkgdir/'") == 0) { + warn "$0: copy of $CTAN/$ctan_loc to $pkgdir failed?!\n"; + return undef; + } + return $pkgdir; + } + + # ok, we will use the ctan path. + return $ctan_loc; +} |