summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tlpkginfo
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-05-09 01:53:16 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2008-05-09 01:53:16 +0000
commit908ab07d0121eb079549a81f6ea8151dbe9ba8fd (patch)
tree5eca95172e2f3a10140cfeb5278493ed3645374f /Master/tlpkg/bin/tlpkginfo
parent4995e66a9fc9c535b4cf23a7ca354313c1a5283f (diff)
tlpkinfo --prepare for all tds incl. latex-tds (moved from ctan2tl and ctan2tds). Fix -> 2x in tlpkg-ctan-check.
git-svn-id: svn://tug.org/texlive/trunk@7964 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/bin/tlpkginfo')
-rwxr-xr-xMaster/tlpkg/bin/tlpkginfo126
1 files changed, 88 insertions, 38 deletions
diff --git a/Master/tlpkg/bin/tlpkginfo b/Master/tlpkg/bin/tlpkginfo
index ea9eb27d462..c21a2ddf255 100755
--- a/Master/tlpkg/bin/tlpkginfo
+++ b/Master/tlpkg/bin/tlpkginfo
@@ -16,28 +16,40 @@ sub main
|| die "$0: TEX_CATALOGUE ($CATALOGUE) must point to entries/ subdir"
. " of a TeX Catalogue checkout.\n";
+ # special packages from latex-tds project (used by prepare())
+ $corelatex_tds_pkgs = "babel|cyrillic|graphics|latex|psnfss|tools";
+ $amslatex_tds_pkgs = "ams|amsrefs|amsmath"; # for tlpsrc_find_catalogue() too
+ $latex_tds_pkgs = "latex-tds|$amslatex_tds_pkgs|$corelatex_tds_pkgs";
+ $latex_tds_dir = "$CTAN/macros/latex/contrib/latex-tds";
+
+ # erroneous tds files (warn Robin about them)
+ $erroneus_tds = "lcyw"; # list format: pkg1|pkg2|etc
+
if ($ARGV[0] eq "--ctan-dir") {
- return &find_ctan_dir ($ARGV[1]);
+ my $output = &find_ctan_dir ($ARGV[1]);
+ print "$output\n";
+ return $output ? 0 : 1;
- } elsif ($ARGV[0] eq "--ctan-dir-tds") {
- $want_tds = 1;
- return &find_ctan_dir ($ARGV[1]);
+ } elsif ($ARGV[0] eq "--prepare") {
+ my $output = &prepare ($ARGV[1]);
+ print "$output\n";
+ return $output ? 0 : 1;
} elsif ($ARGV[0] eq "--ctan-root") {
print "$CTAN\n";
return 0;
} else {
- die "Usage: $0 --ctan-dir[-tds] PKGNAME or --ctan-root (not \"@ARGV\").\n";
+ die "Usage: $0 --ctan-dir PKGNAME or --prepare 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
+sub find_ctan_dir
{
my ($me) = @_;
return 1 unless $me;
@@ -45,12 +57,9 @@ sub find_ctan_dir
# use explicit catalogue name if given in tlpsrc.
$me = &tlpsrc_find_catalogue ($me) || $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|amsrefs|amsmath)$/) {
- $me = "amslatex";
- }
+ # ctan (and latex-tds) bundles all ams packages together,
+ # but we use separate tlp names
+ $me = "amslatex" if me =~ /^($amslatex_tds_pkgs)$/;
# 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.
@@ -131,8 +140,7 @@ sub find_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;
+ return $ctan_dir
}
@@ -180,21 +188,6 @@ sub catalogue_find_ctan_path
$ctan_loc =~ s,' .*,,;
chomp ($ctan_loc);
- # if the package claims to have tds-ready .zip file, use it.
- if ($want_tds) {
- my $tds_path = "$CTAN/install/$ctan_loc.tds.zip";
- # don't use erroneous tds.
- if (-s $tds_path && $pkgname !~ /^(lcyw)$/) {
- $ctan_loc = &copy_to_tmpdir ($pkgname, $tds_path);
- # unzip it so that tlpkg-ctan-check has files to compare.
- system ("unzip -q -a $ctan_loc/$pkgname.tds.zip -d $ctan_loc");
- # remove the zip and put a flag for ctan2tds to know.
- system ("rm $ctan_loc/$pkgname.tds.zip");
- system ("touch $ctan_loc/TDS_READY");
- return $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
@@ -204,15 +197,73 @@ sub catalogue_find_ctan_path
# various reasons.)
#
if ($ctan_path =~ /file='true'/) {
- return $ctan_path =~ m,/$pkgname/, # pkg dir somewhere in path?
- ? undef
- : &copy_to_tmpdir ($pkgname, "$CTAN/$ctan_loc");
+ if ($ctan_path =~ m,/$pkgname/,) { # pkg dir somewhere in path?
+ return undef;
+ } else {
+ return $do_copy # are we called by prepare() or not?
+ ? &copy_to_tmpdir ($pkgname, "$CTAN/$ctan_loc")
+ : "$CTAN/$ctan_loc";
+ }
}
- # no tds.zip, not a single file, so use the regular ctan location.
+ # not a single file, so use the regular ctan location.
return $ctan_loc;
}
+#
+# Create a tmpdir with the tds-ready tree unpacked if any,
+# else return the normal ctan dir.
+#
+sub prepare
+{
+ my ($pkg) = @_;
+ return undef unless $pkg;
+
+ # find the real ctan dir and return it if our tds is erroneous
+ # (warn Robin Fairbairns about buggy tds zips)
+ $do_copy = 1; # ask find_catalogue() to copy single files, too
+ my $ctan_loc = &find_ctan_dir ("$pkg");
+ return $ctan_loc if ($pkg =~ /^($erroneous_tds)$/);
+
+ # tds path is usually in ctan/install...
+ my $tds_path = "$ctan_loc.tds.zip";
+ $tds_path =~ s#^$CTAN#$CTAN/install#;
+
+ # ...except for files in latex-tds...
+ if ($pkg =~ /^($latex_tds_pkgs)$/) {
+ $tds_path = "$latex_tds_dir/$pkg.tds.zip";
+ # ...and some exceptions in latex-tds itself.
+ $tds_path = "$latex_tds_dir/source.tds.zip" if ($pkg eq "latex-tds");
+ $tds_path = "$latex_tds_dir/base.tds.zip" if ($pkg eq "latex");
+ $tds_path = "$latex_tds_dir/amslatex.tds.zip"
+ if ($pkg =~ /^($amslatex_tds_pkgs)$/);
+ }
+
+ return $ctan_loc unless (-s $tds_path);
+
+ # now we have a tds, so unzip it in a tmpdir
+ my $tmpdir = &copy_to_tmpdir ($pkg);
+ system ("unzip -q -a $tds_path -d $tmpdir");
+ # put a flag for ctan2tds' donormal() to work
+ system ("touch $tmpdir/TDS_READY");
+
+ # more problems with amsmath: we got all three packages together,
+ # we now have to remove the unwanted ones...
+ if ($pkg =~ /^($amslatex_tds_pkgs)$/) {
+ chdir ($tmpdir);
+ my @deldir = ();
+ # List of subsubdirectories, at the package level.
+ chomp (my @dirlist = `find */*/* -type d | sort -u`);
+ for my $dir (@dirlist) {
+ next if $dir =~ m!$pkg$!; # keep matching directories
+ push (@deldir, $dir);
+ }
+ system ("rm -rf @deldir"); # discard the rest
+ }
+
+ return $tmpdir;
+}
+
# copy file to temp dir and return that for ctan2tl to use.
#
sub copy_to_tmpdir
@@ -224,10 +275,9 @@ sub copy_to_tmpdir
mkdir ($pkgdir, 0777);
# warn "$0: copying single file $src\n";
- unless (system ("cp -p '$src' '$pkgdir/'") == 0) {
- warn "$0: copy of $src to $pkgdir failed?!\n";
- return undef;
- }
+
+ system ("cp -p '$src' '$pkgdir/'") if $src;
return $pkgdir;
}
+