From da48e049c8574348df6eff939730856523f6d0a0 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 2 Oct 2015 01:35:01 +0000 Subject: tlmgr: proper return code handling for action_platform git-svn-id: svn://tug.org/texlive/trunk@38522 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/tlmgr.pl | 41 +++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 539267b40e8..4d7597888d2 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -4296,16 +4296,17 @@ sub action_option { # ARCH # sub action_platform { + my $ret = $F_OK; my @extra_w32_packs = qw/tlperl.win32 tlgs.win32 tlpsv.win32 collection-wintools dviout.win32 wintools.win32/; if ($^O=~/^MSWin(32|64)$/i) { warn("action `platform' not supported on Windows\n"); - return(); + return ($F_WARNING); } if ($opts{"usermode"}) { tlwarn("action `platform' not supported in usermode\n"); - exit 1; + return ($F_ERROR); } my $what = shift @ARGV; init_local_db(1); @@ -4328,18 +4329,18 @@ sub action_platform { print "You can add new platforms with: tlmgr platform add ARCH1 ARCH2...\n"; return ($F_OK | $F_NOPOSTACTION); } elsif ($what =~ m/^add$/i) { - return if !check_on_writable(); + return ($F_ERROR) if !check_on_writable(); init_tlmedia_or_die(); my @already_installed_arch = $localtlpdb->available_architectures; my @available_arch = $remotetlpdb->available_architectures; my @todoarchs; foreach my $a (@ARGV) { if (TeXLive::TLUtils::member($a, @already_installed_arch)) { - print "Platform $a is already installed\n"; + info("Platform $a is already installed\n"); next; } if (!TeXLive::TLUtils::member($a, @available_arch)) { - print "Platform $a not available, use 'tlmgr platform list'!\n"; + info("Platform $a not available, use 'tlmgr platform list'!\n"); next; } push @todoarchs, $a; @@ -4353,8 +4354,14 @@ sub action_platform { foreach my $a (@todoarchs) { if ($remotetlpdb->get_package("$pkg.$a")) { info("install: $pkg.$a\n"); - $remotetlpdb->install_package("$pkg.$a", $localtlpdb) - if (!$opts{"dry-run"}); + if (!$opts{'dry-run'}) { + if (! $remotetlpdb->install_package("$pkg.$a", $localtlpdb)) { + $ret |= $F_ERROR; + } + } + } else { + tlwarn("action platform add, cannot find package $pkg.$a\n"); + $ret |= $F_WARNING; } } } @@ -4364,7 +4371,11 @@ sub action_platform { # install the necessary w32 stuff for my $p (@extra_w32_packs) { info("install: $p\n"); - $remotetlpdb->install_package($p, $localtlpdb) if (!$opts{"dry-run"}); + if (!$opts{'dry-run'}) { + if (! $remotetlpdb->install_package($p, $localtlpdb)) { + $ret |= $F_ERROR; + } + } } } # update the option("available_architectures") list of installed archs @@ -4375,17 +4386,19 @@ sub action_platform { $localtlpdb->save; } } elsif ($what =~ m/^remove$/i) { - return if !check_on_writable(); + return ($F_ERROR) if !check_on_writable(); my @already_installed_arch = $localtlpdb->available_architectures; my @todoarchs; my $currentarch = $localtlpdb->platform(); foreach my $a (@ARGV) { if (!TeXLive::TLUtils::member($a, @already_installed_arch)) { - print "Platform $a not installed, use 'tlmgr platform list'!\n"; + tlwarn("Platform $a not installed, use 'tlmgr platform list'!\n"); + $ret |= $F_WARNING; next; } if ($currentarch eq $a) { info("You are running on platform $a, you cannot remove that one!\n"); + $ret |= $F_WARNING; next; } push @todoarchs, $a; @@ -4404,6 +4417,7 @@ sub action_platform { foreach my $a (@todoarchs) { if ($localtlpdb->get_package("$pkg.$a")) { info("remove: $pkg.$a\n"); + # assume that this works out $localtlpdb->remove_package("$pkg.$a") if (!$opts{"dry-run"}); } } @@ -4421,6 +4435,7 @@ sub action_platform { for my $a (@todoarchs) { if (!rmdir("$Master/bin/$a")) { tlwarn("binary directory $Master/bin/$a not empty after removal of $a.\n"); + $ret |= $F_WARNING; } } # update the option("available_architectures") list of installed archs @@ -4444,14 +4459,16 @@ sub action_platform { } else { if (!TeXLive::TLUtils::member($arg, @already_installed_arch)) { tlwarn("cannot set platform to a not installed one.\n"); - return; + return ($F_ERROR); } $localtlpdb->setting('platform', $arg); $localtlpdb->save; } } else { - die "Unknown option for platform: $what"; + tlwarn("Unknown option for platform: $what\n"); + $ret |= $F_ERROR; } + return ($ret); } -- cgit v1.2.3