diff options
author | Norbert Preining <preining@logic.at> | 2012-05-23 05:01:58 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2012-05-23 05:01:58 +0000 |
commit | ed64153cb6d4b37b71ccc90c0d831943323ddeed (patch) | |
tree | cf20c1187972ffb1131a8762b5fdeefea2bb3df3 /Master | |
parent | e4d44d22b1f2a5da029d33fe38762067700bf097 (diff) |
tlmgr and tlmgrgui updates:
- (gui) make a few more strings translateable
- (gui) allow selection English as GUI language
- (gui) show GUI language selection also on Windows (in expert mode)
- (text) proper return codes with error msgs from init_tlmedia
- (gui) show warning window when loading of remote tlpdb does not work
git-svn-id: svn://tug.org/texlive/trunk@26587 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 82 | ||||
-rw-r--r-- | Master/texmf/scripts/texlive/tlmgrgui.pl | 31 |
2 files changed, 71 insertions, 42 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index cd78e6c1425..181ff6702c4 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -1113,7 +1113,7 @@ sub action_dumptlpdb { $localtlpdb->writeout; } elsif ($opts{"remote"} && !$opts{"local"}) { - init_tlmedia(); + init_tlmedia_or_die(); $remotetlpdb->writeout; } else { @@ -1156,7 +1156,7 @@ sub action_info { my $installed = 0; if (!$tlp) { if (!$remotetlpdb) { - init_tlmedia(); + init_tlmedia_or_die(); } if (defined($tag)) { if (!$remotetlpdb->is_virtual) { @@ -1225,7 +1225,7 @@ sub action_info { if (!@colls) { # not referenced in the local tlpdb, so try the remote here, too if (!$remotetlpdb) { - init_tlmedia(); + init_tlmedia_or_die(); } @colls = $remotetlpdb->needed_by($pkg); } @@ -1415,7 +1415,7 @@ sub action_search { } init_local_db(); if ($opts{"global"}) { - init_tlmedia(); + init_tlmedia_or_die(); $tlpdb = $remotetlpdb; } else { $tlpdb = $localtlpdb; @@ -2259,7 +2259,7 @@ sub action_update { return; } - init_tlmedia(); + init_tlmedia_or_die(); info("update: dry run, no changes will be made\n") if $opts{"dry-run"}; my @excluded_pkgs = (); @@ -3221,7 +3221,7 @@ sub action_install { return if !check_on_writable(); # initialize the TLPDB from $location $opts{"no-depends"} = 1 if $opts{"no-depends-at-all"}; - init_tlmedia(); + init_tlmedia_or_die(); # check for updates to tlmgr itself, and die unless --force is given if (check_for_critical_updates( $localtlpdb, $remotetlpdb)) { @@ -3386,7 +3386,7 @@ sub show_list_of_packages { if ($opts{"only-installed"}) { $tlm = $localtlpdb; } else { - init_tlmedia(); + init_tlmedia_or_die(); $tlm = $remotetlpdb; } my @whattolist; @@ -3594,7 +3594,7 @@ sub action_candidates { return; } init_local_db(); - init_tlmedia(); + init_tlmedia_or_die(); my @cand = $remotetlpdb->candidates($what); if (@cand) { my $first = shift @cand; @@ -3805,7 +3805,7 @@ sub action_platform { if ($what =~ m/^list$/i) { # list the available platforms # initialize the TLPDB from $location - init_tlmedia(); + init_tlmedia_or_die(); my @already_installed_arch = $localtlpdb->available_architectures; print "Available platforms:\n"; foreach my $a ($remotetlpdb->available_architectures) { @@ -3820,7 +3820,7 @@ sub action_platform { finish(0); } elsif ($what =~ m/^add$/i) { return if !check_on_writable(); - init_tlmedia(); + init_tlmedia_or_die(); my @already_installed_arch = $localtlpdb->available_architectures; my @available_arch = $remotetlpdb->available_architectures; my @todoarchs; @@ -4977,6 +4977,13 @@ sub init_local_db { # initialize the global $remotetlpdb object, or die. # uses the global $location. # +sub init_tlmedia_or_die { + my ($ret, $err) = init_tlmedia(); + if (!$ret) { + tldie("$prg: $err"); + } +} + sub init_tlmedia { # first check if $location contains multiple locations @@ -4995,14 +5002,13 @@ sub init_tlmedia # check if we are only one tag/repo if ($#tags == 0) { # go to normal mode - _init_tlmedia(); - return; + return _init_tlmedia(); } # we are still here, so we have more tags # check that there is a main repository if (!TeXLive::TLUtils::member('main', @tags)) { - tldie("$prg: Cannot find main repository, you have to tag one as main!\n"); + return(0, "Cannot find main repository, you have to tag one as main!"); } # TODO TODO @@ -5012,11 +5018,17 @@ sub init_tlmedia $remotetlpdb->make_virtual; my $locstr = $repos{'main'}; - my $tlmdb = setup_one_remotetlpdb($locstr); + my ($tlmdb, $errormsg) = setup_one_remotetlpdb($locstr); + if (!defined($tlmdb)) { + return (0, $errormsg); + } $remotetlpdb->virtual_add_tlpdb($tlmdb, "main"); for my $t (@tags) { if ($t ne 'main') { - my $tlmdb = setup_one_remotetlpdb($repos{$t}); + my ($tlmdb, $errormsg) = setup_one_remotetlpdb($repos{$t}); + if (!defined($tlmdb)) { + return(0, $errormsg); + } $remotetlpdb->virtual_add_tlpdb($tlmdb, $t); $locstr .= " $repos{$t}"; } @@ -5052,6 +5064,7 @@ sub init_tlmedia info("\t$t = " . $repos{$t} . "\n"); } } + return 1; } @@ -5067,7 +5080,7 @@ sub _init_tlmedia if (defined($remotetlpdb) && !$remotetlpdb->is_virtual && ($remotetlpdb->root eq $location)) { # nothing to be done - return; + return 1; } # choose a mirror if we are asked. @@ -5078,11 +5091,18 @@ sub _init_tlmedia $location =~ s,^$TeXLiveServerURL,$mirrorbase,; } - $remotetlpdb = setup_one_remotetlpdb($location); + my $errormsg; + ($remotetlpdb, $errormsg) = setup_one_remotetlpdb($location); + if (!defined($remotetlpdb)) { + return(0, $errormsg); + } + + # this "location-url" line should not be changed since GUI programs # depend on it: print "location-url\t$location\n" if $::machinereadable; info("tlmgr: package repository $location\n"); + return 1; } sub setup_one_remotetlpdb @@ -5157,7 +5177,9 @@ END_NO_INTERNET if (!$local_copy_tlpdb_used) { $remotetlpdb = TeXLive::TLPDB->new(root => $location); } - die($loadmediasrcerror . $location) unless defined($remotetlpdb); + if (!defined($remotetlpdb)) { + return(undef, $loadmediasrcerror . $location); + } # we allow a range of years to be specified by the remote tlpdb # for which it might work. # the lower limit is TLPDB->config_minrelease @@ -5173,15 +5195,15 @@ END_NO_INTERNET my $texlive_release = $remotetlpdb->config_release; my $texlive_minrelease = $remotetlpdb->config_minrelease; if (!defined($texlive_release)) { - tldie("$prg: The installation repository does not specify a " - . "release year for which it was prepared, goodbye.\n"); + return(undef, "The installation repository does not specify a " + . "release year for which it was prepared, goodbye."); } # still here, so we have $texlive_release defined my $texlive_release_year = $texlive_release; $texlive_release_year =~ s/^(....).*$/$1/; if ($texlive_release_year !~ m/^[1-9][0-9][0-9][0-9]$/) { - tldie("$prg: The installation repository does not specify a " - . "valid release year, goodbye: $texlive_release\n"); + return(undef, "The installation repository does not specify a " + . "valid release year, goodbye: $texlive_release"); } # so $texlive_release_year is numeric, good if (defined($texlive_minrelease)) { @@ -5189,29 +5211,25 @@ END_NO_INTERNET my $texlive_minrelease_year = $texlive_minrelease; $texlive_minrelease_year =~ s/^(....).*$/$1/; if ($texlive_minrelease_year !~ m/^[1-9][0-9][0-9][0-9]$/) { - tldie("The installation repository does not specify a " - . "valid minimal release year, goodbye: $texlive_minrelease\n"); + return(undef, "The installation repository does not specify a " + . "valid minimal release year, goodbye: $texlive_minrelease"); } # ok, all numeric and fine, check for range if ($TeXLive::TLConfig::ReleaseYear < $texlive_minrelease_year || $TeXLive::TLConfig::ReleaseYear > $texlive_release_year) { - tldie <<END_BADRANGE -$prg: The TeX Live versions supported by the repository + return (undef, "The TeX Live versions supported by the repository ($texlive_minrelease_year--$texlive_release_year) do not include the version of the local installation - ($TeXLive::TLConfig::ReleaseYear). Goodbye. -END_BADRANGE + ($TeXLive::TLConfig::ReleaseYear)."); } } else { # $texlive_minrelease not defined, so only one year is valid if ($texlive_release_year != $TeXLive::TLConfig::ReleaseYear) { - tldie <<END_BADYEAR -$prg: The TeX Live versions of the local installation + return(undef, "The TeX Live versions of the local installation and the repository being accessed are not compatible: local: $TeXLive::TLConfig::ReleaseYear repository: $texlive_release_year -(Perhaps you need to use a different CTAN mirror?) Goodbye. -END_BADYEAR +(Perhaps you need to use a different CTAN mirror?)."); } } diff --git a/Master/texmf/scripts/texlive/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui.pl index 3319438bd67..b583f0f1da8 100644 --- a/Master/texmf/scripts/texlive/tlmgrgui.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui.pl @@ -11,7 +11,6 @@ # TODO: Fix return codes of execute_action sub items and execute_action # so that we can give a decent warning window # TODO: implement path adjustment also for Windows -# TODO: make the path adjustment dialog for Unix a bit nicer $^W = 1; use strict; @@ -537,8 +536,10 @@ sub setup_menu_system { if (!win32() && $mode_expert) { $menu_options->add('command', -label => __("Platforms ..."), -command => sub { do_arch_settings(); }); - $menu_options->add('command', -label => __("GUI Language ..."), - -command => sub { do_gui_language_setting(); }); + } + if ($mode_expert) { + $menu_options->add('command', -label => __("GUI Language ..."), + -command => sub { do_gui_language_setting(); }); } $menu_options->add('separator'); $menu_options->add('checkbutton', -label => __("Expert options"), @@ -1372,12 +1373,14 @@ sub do_gui_language_setting { my %code_lang = ( cs => "Czech", de => "German", + en => "English", es => "Spanish", fr => "French", it => "Italian", ja => "Japanese", nl => "Dutch", pl => "Polish", + "pt_br" => "Brasilian", ru => "Russian", sk => "Slovak", sl => "Slovenian", @@ -1401,9 +1404,11 @@ sub do_gui_language_setting { $p =~ s!\.po$!!; push @ll, $p; } + # add English as possible language! + push @ll, "en"; foreach my $l (sort @ll) { my $el = (defined($code_lang{$l}) ? $code_lang{$l} : $l); - $opt->insert("end",$el); + $opt->insert("end", $el); } $opt->pack(-padx => "2m", -pady => "2m"); $sw->Label(-text => __("Changes will take effect after restart"))->pack(-padx => "2m", -pady => "2m"); @@ -1577,8 +1582,13 @@ sub menu_multi_location { $ref->{'chg_w'} = $f1->Button(-text => __("Change"), -command => sub { our $sw; - my $ret = ask_one_repository($sw, __("Change " . ($t eq "main" ? "main" : "subsidiary") . " package repository"), - __(($t eq "main" ? "Change main" : "New subsidiary") . " package repository")); + my $ret = ask_one_repository($sw, + ($t eq "main" ? + __("Change main package repository") : + __("Change subsidiary package repository")), + ($t eq "main" ? + __("Change main package repository") : + __("Change subsidiary package repository"))); $ref->{'val'} = $ret if (defined($ret)); }); } @@ -1852,13 +1862,14 @@ sub init_install_media { # nothing to be done } else { $mw->Busy(-recurse => 1); - init_tlmedia(); + my ($ret, $err) = init_tlmedia(); $mw->Unbusy; - if (!defined($remotetlpdb)) { + if (!$ret) { # something went badly wrong, maybe the newroot is wrong? $mw->Dialog(-title => __("Warning"), - -text => __("Could not load the TeX Live Database from %s\nIf you want to install or update packages, please try with a different package repository!\n\nFor configuration and removal you don\'t have to do anything.", $newroot), - -buttons => [ __("Ok") ])->Show; + -text => __("Loading of remote database failed.") . "\n" . + __("Error message:") . "\n$err\n\n", + -buttons => [ __("Ok") ])->Show; $remotetlpdb = undef; update_list_remote(); update_grid(); |