summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLPDB.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-04-19 10:22:03 +0000
committerNorbert Preining <preining@logic.at>2008-04-19 10:22:03 +0000
commitae800c9ec7b6edbb316da1a84bb10161410302f6 (patch)
treebc1faa709fefb32faf2e83950bb0e33faaefe3d9 /Master/tlpkg/TeXLive/TLPDB.pm
parentba27f568a1af1d55353f4deb35d9d839fc762287 (diff)
2 big changes:
- tlpdb initialization tries the lzma compressed one from the net - download_file honors $TL_DOWNLOAD_PROG and $TL_DOWNLOAD_ARGS git-svn-id: svn://tug.org/texlive/trunk@7511 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPDB.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm46
1 files changed, 40 insertions, 6 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index 857d4370b81..ad97970de46 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -54,7 +54,7 @@ C<TeXLive::TLPDB> -- A database of TeX Live Packages
use TeXLive::TLConfig qw($CategoriesRegexp $DefaultCategory $InfraLocation
$DatabaseName $MetaCategoriesRegexp);
-use TeXLive::TLUtils qw(dirname mkdirhier tllog member);
+use TeXLive::TLUtils qw(dirname mkdirhier tllog member win32);
use TeXLive::TLPOBJ;
my $_listdir;
@@ -184,11 +184,45 @@ sub from_file {
my $retfh;
if ($path =~ /^(http|ftp):\/\//) {
tllog($::LOG_DDDEBUG, "TLPDB.pm: trying to initialize from $path\n");
- $retfh = TeXLive::TLUtils::download_file($path, "|");
- #open(TMP, "wget -q --output-document=- $path|")
- # || die("Cannot open tlpdb file: $path");
- if (!$retfh) {
- die("Cannot open tlpdb file: $path");
+ # if we have lzmadec available we try the lzma file
+ if (defined($::progs{'lzmadec'})) {
+ # we first try the lzma compressed file
+ my $tmpdir = TeXLive::TLUtils::get_system_tmpdir();
+ my $bn = TeXLive::TLUtils::basename("$path");
+ my $lzmafile = "$tmpdir/$bn.lzma";
+ my $lzmafile_quote = $lzmafile;
+ my $tlpdbfile = "$tmpdir/$bn";
+ my $tlpdbfile_quote = $tlpdbfile;
+ if (win32()) {
+ $lzmafile =~ s!/!\\!g;
+ $tlpdbfile =~ s!/!\\!g;
+ }
+ $lzmafile_quote = "\"$lzmafile\"";
+ $tlpdbfile_quite = "\"$tlpdbfile\"";
+ tllog($::LOG_DEBUG, "trying to download $path.lzma to $lzmafile\n");
+ my $ret = TeXLive::TLUtils::download_file("$path.lzma", "$lzmafile");
+ # better to check both, the return value AND the existence of the file
+ if ($ret && (-r "$lzmafile")) {
+ # ok, let the fun begin
+ tllog($::LOG_DEBUG, "Un-lzmaing $lzmafile to $tlpdbfile\n");
+ system("$::progs{'lzmadec'} < $lzmafile_quote > $tlpdbfile_quote");
+ if (! -r $tlpdbfile) {
+ tllog($::LOG_DEBUG, "Un-lzmaing $lzmafile did not succeed, try normally\n");
+ } else {
+ unlink($lzmafile);
+ open $retfh, "<$tlpdbfile" or die"Cannot open $tlpdbfile!";
+ tllog($::LOG_DEBUG, "Ok, found the uncompressed lzma file!\n");
+ }
+ }
+ } else {
+ tllog($::LOG_DEBUG, "no lzmadec defined, not trying tlpdb.lzma ...\n");
+ }
+ if (!defined($retfh)) {
+ # lzma did not succeed, so try the normal file
+ $retfh = TeXLive::TLUtils::download_file($path, "|");
+ if (!$retfh) {
+ die("Cannot open tlpdb file: $path");
+ }
}
} else {
open(TMP,"<$path") || die("Cannot open tlpdb file: $path");