summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLMedia.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-04-16 10:30:44 +0000
committerNorbert Preining <preining@logic.at>2008-04-16 10:30:44 +0000
commit819a736f4a34367ec63da21b0c221cd4749ab0d1 (patch)
tree9a624ca46063606b55fb7923084f40f5dcd93302 /Master/tlpkg/TeXLive/TLMedia.pm
parentcbcd661b4ec0163299c6494524dd5ad2afbdef38 (diff)
rework installation
git-svn-id: svn://tug.org/texlive/trunk@7445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLMedia.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLMedia.pm100
1 files changed, 44 insertions, 56 deletions
diff --git a/Master/tlpkg/TeXLive/TLMedia.pm b/Master/tlpkg/TeXLive/TLMedia.pm
index 061e369b6a8..1d04b2233db 100644
--- a/Master/tlpkg/TeXLive/TLMedia.pm
+++ b/Master/tlpkg/TeXLive/TLMedia.pm
@@ -280,36 +280,21 @@ sub install_package {
}
sub _install_package {
- sub mysystem {
- my $cmd = shift;
- # print "DEBUG: $cmd\n";
- system("$cmd");
- }
my ($self, $what, $filelistref, $totlpdb) = @_;
- my $buffer;
- my $offset;
- my $blocksize=2048;
+
my $media = $self->media;
my $target = $totlpdb->root;
- $blocksize=4096 if ($media eq 'NET');
-
my @filelist = @$filelistref;
- my $bindir = "$target/tlpkg/installer";
- my $platform = $totlpdb->option_platform;
- # unix defaults
- my $wget = "wget";
- my $lzmadec = "$bindir/lzmadec.$platform";
- my $tar = "tar";
- if (win32()) {
- $wget = conv_to_win_path("$bindir/wget.exe");
- #$tar = conv_to_win_path("$bindir/bsdtar.exe");
- # try Akira's tar.exe
- $tar = conv_to_win_path("$bindir/tar.exe");
- $lzmadec = conv_to_win_path("$lzmadec");
- $target =~ s!/!\\!g;
+ # we assume that $::progs has been set up!
+ my $wget = $::progs{'wget'};
+ my $lzmadec = $::progs{'lzmadec'};
+ my $tar = $::progs{'tar'};
+ if (!defined($wget) || !defined($lzmadec) || !defined($tar)) {
+ die "Programs have not been set up properly, strange!";
}
+
if (ref $what) {
# we are getting a ref to a list of files, so install from DVD
my $location = $self->location;
@@ -320,43 +305,46 @@ sub _install_package {
mkdirhier("$target/$dn");
copy "$location/$file", "$target/$dn";
}
- } elsif ($what =~ m,http://|ftp://,) {
- # we are installing from the NET
- # currently the list of file @filelist is NOT EVALUATED!!!
- if (win32()) {
- # we need temporary files here
- # tmpdir is $target/temp
- my $fn = basename($what);
- my $tarfile = $fn;
- $tarfile =~ s/\.lzma$//;
- mkdirhier("$target/temp");
- tllog($::LOG_DEBUG, "Downloading $what to $target\\temp\\$fn\n");
- tllog($::LOG_DEBUG, `$wget --tries=2 --timeout=60 -q -O \"$target\\temp\\$fn\" \"$what\" 2>\&1`);
- tllog($::LOG_DEBUG, "Un-lzmaing $target\\temp\\$fn to $target\\temp\\$tarfile\n");
- #tllog($::LOG_DEBUG, `type \"$target\\temp\\$fn\" | $lzmadec > \"$target\\temp\\$tarfile\" 2>&1`);
- tllog($::LOG_DEBUG, `$lzmadec < \"$target\\temp\\$fn\" > \"$target\\temp\\$tarfile\" 2>&1`);
- tllog($::LOG_DEBUG, "Unpacking temp\\$tarfile\n");
- tllog($::LOG_DEBUG, `pushd \"$target\" & $tar -xf \"temp\\$tarfile\" 2>&1`);
- unlink("$target/temp/$tarfile", "$target/temp/$fn");
- } else {
- tllog($::LOG_DEBUG, "downloading/unlzma-ing/unpacking $what\n");
- tllog($::LOG_NORMAL, `$wget --tries=2 --timeout=60 -q -O- \"$what\"|\"$lzmadec\"|$tar -xf - -C \"$target\"`);
- }
} elsif ($what =~ m,\.tar.lzma$,) {
+ # this is the case when we install from CD or the NET
+ #
+ # in all other cases we create temp files .tar.lzma (or use the present
+ # one), lzmadec them, and then call tar
+
+ my $fn = basename($what);
+ mkdirhier("$target/temp");
+ my $lzmafile = "$target/temp/$fn";
+ my $tarfile = "$target/temp/$fn"; $tarfile =~ s/\.lzma$//;
+ my $lzmafile_quote = $lzmafile;
+ my $tarfile_quote = $tarfile;
+ my $target_quote = $target;
if (win32()) {
- my $fn = basename($what);
- my $tarfile = $fn;
- $tarfile =~ s/\.lzma$//;
- mkdirhier("$target/temp");
- tllog($::LOG_DEBUG, "Un-lzmaing $what to $target\\temp\\$tarfile\n");
- tllog($::LOG_DEBUG, `$lzmadec < \"$what\" > \"$target\\temp\\$tarfile\" 2>&1`);
- tllog($::LOG_DEBUG, "Unpacking temp\\$tarfile\n");
- tllog($::LOG_DEBUG, `pushd \"$target\" & $tar -xf \"temp\\$tarfile\" 2>&1`);
- unlink("$target/temp/$tarfile");
+ $lzmafile =~ s!/!\\!g;
+ $lzmafile_quote = "\"$lzmafile\"";
+ $tarfile =~ s!/!\\!g;
+ $tarfile_quote = "\"$tarfile\"";
+ $target =~ s!/!\\!g;
+ $target_quote = "\"$target\"";
+ }
+ if ($what =~ m,http://|ftp://,) {
+ # we are installing from the NET
+ # download the file and put it into temp
+ if (!download_file($what, $lzmafile) || (! -r $lzmafile)) {
+ die "Downloading $what did not succeed, please retry!";
+ }
} else {
- tllog($::LOG_DEBUG, "downloading/unlzma-ing/unpacking $what\n");
- tllog($::LOG_DEBUG, `cat \"$what\"|\"$lzmadec\"|$tar -xf - -C \"$target\" 2>&1`);
+ # we are installing from CD
+ # copy it to temp
+ copy($what, "$target/temp");
+ }
+ tllog($::LOG_DEBUG, "Un-lzmaing $lzmafile to $tarfile\n");
+ system("$lzmadec < $lzmafile_quote > $tarfile_quote");
+ if (! -f $tarfile) {
+ die "Unpacking $lzmafile did not succeed, please retry!";
}
+ tllog($::LOG_DEBUG, "Unpacking $tarfile\n");
+ system($tar,"-x","-C",$target,"-f",$tarfile);
+ unlink($tarfile, $lzmafile);
} else {
die "Don't know how to install $what!\n";
}