summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2016-01-06 04:21:37 +0000
committerNorbert Preining <preining@logic.at>2016-01-06 04:21:37 +0000
commitebf0dca7678cef41dbc45a184a5e1c7966961a33 (patch)
tree0ae7abd0f12a4927ddda0b76b5ca28af2f1b8556 /Master/tlpkg/TeXLive/TLUtils.pm
parent13d701031f45d0f89570ab34649b80bdcc473edc (diff)
unpack: return pair of 0,1 and msg, use it
git-svn-id: svn://tug.org/texlive/trunk@39294 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm53
1 files changed, 20 insertions, 33 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 74ff59a0a52..e1c85f049b8 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -1959,24 +1959,21 @@ sub check_file {
my ($xzfile, $checksum, $size) = @_;
if ($checksum) {
if (tlmd5($xzfile) ne $checksum) {
- tlwarn("Found $xzfile, but hashsums differ, removing it.\n");
+ tlwarn("TLUtils::check_file: found $xzfile, but hashsums differ, removing it.\n");
unlink($xzfile);
+ return;
}
- } elsif ($size) {
+ }
+ if ($size) {
my $filesize = (stat $xzfile)[7];
if ($filesize != $size) {
- tlwarn("Found $xzfile, but sizes differ, removing it.\n");
+ tlwarn("TLUtils::check_file: found $xzfile, but sizes differ, removing it.\n");
unlink($xzfile);
- } else {
- tlwarn("Found $xzfile, with equal size, continuing fingers crossed.\n");
+ return;
}
- } else {
- # We cannot remove the file here, otherwise restoring of backups
- # or unwind packages might die.
- #
- #tlwarn("Found $xzfile but no size or checksum information, removing it.\n");
- # unlink($xzfile);
- }
+ }
+ # We cannot remove the file here, otherwise restoring of backups
+ # or unwind packages might die.
}
=pod
@@ -1989,8 +1986,8 @@ options: C<tmpdir> (use this directory for downloaded files),
C<checksum> (check downloaded file against this checksum),
C<size> (check downloaded file against this size),
C<remove> (remove temporary files after operation).
-Returns the name of the unpacked package (determined from the name of C<$what>)
-in case of success, otherwise undefined.
+Returns a pair of values: in case of error return 0 and an additional
+explanation, in case of success return 1 and the name of the package.
=cut
@@ -2003,22 +2000,19 @@ sub unpack {
my $size = (defined($opts{'size'}) ? $opts{'size'} : 0);
if (!defined($what)) {
- tlwarn("TLUtils::unpack: nothing to unpack!\n");
- return;
+ return (0, "nothing to unpack");
}
# we assume that $::progs has been set up!
my $wget = $::progs{'wget'};
my $xzdec = TeXLive::TLUtils::quotify_path_with_spaces($::progs{'xzdec'});
if (!defined($wget) || !defined($xzdec)) {
- tlwarn("_install_package: programs not set up properly, strange.\n");
- return;
+ return (0, "programs not set up properly");
}
my $type;
if ($what !~ m/\.tar\.xz$/) {
- tlwarn("TLUtils::unpack: don't know how to unpack this: $what\n");
- return;
+ return(0, "don't know how to unpack");
}
my $fn = basename($what);
@@ -2051,11 +2045,8 @@ sub unpack {
download_file($what, $xzfile);
# remove false downloads
check_file($xzfile, $checksum, $size);
- if ( -r $xzfile ) {
- tlwarn("Downloading\n");
- tlwarn(" $what\n");
- tlwarn("did not succeed, please retry.\n");
- return;
+ if ( ! -r $xzfile ) {
+ return(0, "downloading did not succeed");
}
}
} else {
@@ -2065,10 +2056,7 @@ sub unpack {
check_file($xzfile, $checksum, $size);
if (! -r $xzfile) {
- tlwarn("Your local copy of\n");
- tlwarn(" $what\n");
- tlwarn("does fail consistency checks (see above). Stopping here.\n");
- return;
+ return (0, "consistency checks failed");
}
# we can remove it afterwards
$remove_xzfile = 1;
@@ -2076,15 +2064,14 @@ sub unpack {
debug("un-xzing $xzfile to $tarfile\n");
system("$xzdec < $xzfile_quote > $tarfile_quote");
if (! -f $tarfile) {
- tlwarn("TLUtils::unpack: Unpacking $xzfile failed, please retry.\n");
unlink($tarfile, $xzfile);
- return;
+ return(0, "Unpacking $xzfile failed");
}
unlink($xzfile) if $remove_xzfile;
if (untar($tarfile, $target, 1)) {
- return "$pkg";
+ return (1, "$pkg");
} else {
- return;
+ return (0, "untar failed");
}
}