summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-05-08 21:33:40 +0000
committerNorbert Preining <preining@logic.at>2008-05-08 21:33:40 +0000
commit35cb33b8777bf424d169f588af8518c1b25389ba (patch)
tree431ff60549ae553d6970702690f20d202b85bcd2
parent6a0b0313821b09b39711e640cdaacb79f85606eb (diff)
make tlmgrgui working with a wrong set default location
git-svn-id: svn://tug.org/texlive/trunk@7951 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf/scripts/texlive/tlmgrgui/gui-arch.pl42
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl64
2 files changed, 68 insertions, 38 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgrgui/gui-arch.pl b/Master/texmf/scripts/texlive/tlmgrgui/gui-arch.pl
index d0ab708dbff..c6be80d86da 100644
--- a/Master/texmf/scripts/texlive/tlmgrgui/gui-arch.pl
+++ b/Master/texmf/scripts/texlive/tlmgrgui/gui-arch.pl
@@ -13,27 +13,24 @@ $screens{"arch"} = $back_arch;
# this will be loaded only on unix systems!
#
-my @archsavail;
-my @archsinstalled;
-my %archs;
+our @archsavail;
+our @archsinstalled;
+our %archs;
-init_archs();
+our %archsbuttons;
+our $arch_frame;
+
+push @update_function_list, \&init_archs;
$back_arch->Label(-text => "Select architectures to be added (removal not possible)")->pack(-padx => "5m", -pady => "5m");
-foreach my $a (@archsavail) {
- $back_arch->Checkbutton(-command => sub { check_on_removal($a); },
- -variable => \$archs{$a},
- -text => platform_desc($a)
- )->pack(-anchor => 'w');
-}
-my $f = $back_arch->Frame;
-$f->pack(-padx => "10m", -pady => "5m");
-$f->Button(-text => "Apply changes", -command => sub { apply_changes(); })->pack(-side => 'left', -padx => "3m");
-$f->Button(-text => "Reset changes", -command => sub { init_archs(); })->pack(-side => 'left', -padx => "3m");
sub init_archs {
- @archsavail = $tlmediatlpdb->available_architectures;
+ if (!defined($tlmediatlpdb)) {
+ @archsavailable = ();
+ } else {
+ @archsavail = $tlmediatlpdb->available_architectures;
+ }
@archsinstalled = $localtlpdb->available_architectures;
foreach my $a (@archsavail) {
$archs{$a} = 0;
@@ -41,6 +38,21 @@ sub init_archs {
$archs{$a} = 1;
}
}
+ foreach my $a (keys %archsbuttons) {
+ $archsbuttons{$a}->destroy;
+ }
+ $arch_frame->destroy if defined($arch_frame);
+ foreach my $a (@archsavail) {
+ $archsbuttons{$a} =
+ $back_arch->Checkbutton(-command => sub { check_on_removal($a); },
+ -variable => \$archs{$a},
+ -text => platform_desc($a)
+ )->pack(-anchor => 'w');
+ }
+ $arch_frame = $back_arch->Frame;
+ $arch_frame->pack(-padx => "10m", -pady => "5m");
+ $arch_frame->Button(-text => "Apply changes", -command => sub { apply_changes(); })->pack(-side => 'left', -padx => "3m");
+ $arch_frame->Button(-text => "Reset changes", -command => sub { init_archs(); })->pack(-side => 'left', -padx => "3m");
}
sub check_on_removal {
diff --git a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl
index 24c379298e7..60d3dec65f1 100755
--- a/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl
+++ b/Master/texmf/scripts/texlive/tlmgrgui/tlmgrgui.pl
@@ -45,6 +45,8 @@ GetOptions("location=s" => \$opt_location,
"screen=s" => \$opt_screen,
"debug!" => \$opt_debug) or die("Unsupported argument!");
+our @update_function_list;
+
our $localtlpdb = TeXLive::TLPDB->new ("root" => "$Master");
die("cannot find tlpdb!") unless (defined($localtlpdb));
our @alllocalpackages = setup_list(0,$localtlpdb->list_packages);
@@ -65,11 +67,12 @@ our $tlmediasrc;
our $tlmediatlpdb;
our @allpackages;
-init_install_media($location);
-@updatepackages = create_update_list();
+our $mw = MainWindow->new(-title => "tlmgr 2008");
+
+push @update_function_list, \&init_install_media;
+push @update_function_list, \&create_update_list;
# wm title . "tlmgr 2008"
-our $mw = MainWindow->new(-title => "tlmgr 2008");
# frame .top
our $top = $mw->Frame;
@@ -108,7 +111,8 @@ if (!win32()) {
}
require("gui-config.pl");
-my $packed = 0;
+run_update_functions();
+
if (defined($opt_screen)) {
$back->raise("$opt_screen");
}
@@ -117,17 +121,21 @@ Tk::MainLoop();
sub init_install_media {
- my $newroot = shift;
+ my $newroot = $location;
if (defined($tlmediatlpdb) && ($tlmediatlpdb->root eq $newroot)) {
# nothing to be done
} else {
$tlmediasrc = TeXLive::TLMedia->new($newroot);
if (!defined($tlmediasrc)) {
# something went badly wrong, maybe the newroot is wrong?
- die "Something went badly wrong here, we cannot load the\nTeX Live Database from location `$newroot'.\nAre you sure that there is one?";
+ $mw->Dialog(-title => "warning",
+ -text => "Could not load the TeX Live Database from $newroot\nPlease try with a different installation source/location!",
+ -buttons => [ "Ok" ])->Show;
+ @allpackages = ();
+ } else {
+ $tlmediatlpdb = $tlmediasrc->tlpdb;
+ @allpackages = setup_list(1,$tlmediatlpdb->list_packages);
}
- $tlmediatlpdb = $tlmediasrc->tlpdb;
- @allpackages = setup_list(1,$tlmediatlpdb->list_packages);
}
}
@@ -281,26 +289,30 @@ sub reinit_local_tlpdb {
die("cannot find tlpdb!") unless (defined($localtlpdb));
@alllocalpackages = setup_list(0,$localtlpdb->list_packages);
@allpackages = setup_list(1,$tlmediatlpdb->list_packages);
- @updatepackages = create_update_list();
+ create_update_list();
}
sub create_update_list {
my @ret;
- foreach my $lp ($localtlpdb->list_packages) {
- next if ($lp =~ m/00texlive-installation.config/);
- my $lrev = $localtlpdb->get_package($lp)->revision;
- my $up = $tlmediatlpdb->get_package($lp);
- my $urev;
- if ($up) {
- $urev = $up->revision;
- } else {
- $urev = 0;
+ if (defined($tlmediatlpdb)) {
+ foreach my $lp ($localtlpdb->list_packages) {
+ next if ($lp =~ m/00texlive-installation.config/);
+ my $lrev = $localtlpdb->get_package($lp)->revision;
+ my $up = $tlmediatlpdb->get_package($lp);
+ my $urev;
+ if ($up) {
+ $urev = $up->revision;
+ } else {
+ $urev = 0;
+ }
+ if ($urev > $lrev) {
+ push @ret, $lp;
+ }
}
- if ($urev > $lrev) {
- push @ret, $lp;
- }
+ } else {
+ @ret = ();
}
- return @ret;
+ @updatepackages = @ret;
}
sub setup_list {
@@ -350,13 +362,19 @@ sub menu_edit_location {
my $f = $sw->Frame;
$f->Button(-text => 'ok',
-command => sub { $location = $entry->get;
- init_install_media($location) ;
+ run_update_functions() ;
$sw->destroy })->pack(-side => 'left');
$f->Button(-text => 'cancel',
-command => sub { $sw->destroy })->pack(-side => 'right');
$f->pack(-expand => 'x');
}
+sub run_update_functions {
+ foreach my $f (@update_function_list) {
+ &{$f}();
+ }
+}
+
__END__