summaryrefslogtreecommitdiff
path: root/Master/texmf/scripts
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2010-03-31 22:49:08 +0000
committerNorbert Preining <preining@logic.at>2010-03-31 22:49:08 +0000
commit93b4b1825f34a8285de4c2cf6377fc2631b331c4 (patch)
treebf5ed498e12b7f147c5b94b8ea772bd540662cb6 /Master/texmf/scripts
parent010f9b8f9711d7393dfea00a88948d257af5acac (diff)
add support for restore in the tlmgr gui
git-svn-id: svn://tug.org/texlive/trunk@17644 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf/scripts')
-rw-r--r--Master/texmf/scripts/texlive/tlmgrgui.pl102
1 files changed, 102 insertions, 0 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui.pl
index 36b6076445d..09b5f79cba0 100644
--- a/Master/texmf/scripts/texlive/tlmgrgui.pl
+++ b/Master/texmf/scripts/texlive/tlmgrgui.pl
@@ -505,6 +505,11 @@ sub setup_menu_system {
$mw->Unbusy;
});
+ $menu_actions->add('command',
+ -label => __("Restore packages from backup") . " ...",
+ -state => $::action_button_state,
+ -command => \&cb_handle_restore);
+
if (!win32()) {
$menu_actions->add('command',
-label => __("Handle symlinks in system dirs") . " ...",
@@ -1707,6 +1712,103 @@ sub currmem {
}
}
+sub cb_handle_restore {
+ init_defaults_setting();
+ # first do the handling of the backup dir selection
+ {
+ my ($a, $b) = check_backupdir_selection();
+ if (!$a) {
+ # in all these cases we want to terminate in the non-gui mode
+ my $sw = $mw->DialogBox(-title => __("Warning"), -buttons => [ __("Ok") ]);
+ $sw->add("Label", -text => $b)->pack(@p_iii);
+ $sw->Show;
+ # delete the backupdir setting it might contain rubbish and
+ # we want to recheck
+ delete $opts{'backupdir'};
+ return;
+ }
+ }
+
+ my $sw = $mw->Toplevel(-title => __("Restore packages from backup"));
+ $sw->transient($mw);
+ $sw->grab;
+
+ my $tf = $sw->Frame;
+ $tf->pack(-ipadx => '3m', -ipady => '3m');
+
+ my %backups = get_available_backups($opts{"backupdir"});
+
+ my @pkgbackup = sort keys %backups;
+ my $lstlen = ($#pkgbackup >= 10 ? 10 : ($#pkgbackup + 1));
+
+ my $pkg;
+ my $rev;
+
+ my $restore_dialog = $sw->DialogBox(-title => __("Restore done"),
+ -buttons => [ __("Ok") ]);
+ $restore_dialog->add("Label", -text => __("Restore completed"))->pack(@p_iii);
+
+
+ my $revbrowser;
+
+ $tf->Label(-text => __("Select the package to restore, or restore all packages"))->pack(@p_ii);
+
+ $tf->BrowseEntry(-label => __("Package:"),
+ -listheight => $lstlen,
+ -autolistwidth => 1,
+ -choices => \@pkgbackup,
+ -browsecmd =>
+ sub { my @revlist = sort { $b <=> $a } (keys %{$backups{$pkg}});
+ $revbrowser->delete(0,"end");
+ for my $r (@revlist) {
+ $revbrowser->insert("end", $r);
+ };
+ $rev = "";
+ },
+ -variable => \$pkg)->pack(@p_ii);
+
+ $revbrowser = $tf->BrowseEntry(-label => __("Revision:"),
+ -listheight => 10,
+ -variable => \$rev)->pack(@p_ii);
+
+ $tf->pack(-ipadx => '3m', -ipady => '3m');
+ $tf->Button(-text => __("Restore selected package"),
+ -command => sub {
+ if (!defined($pkg) || !defined($rev) ||
+ !($backups{$pkg}->{$rev})) {
+ tlwarn("Please select a package and revision first!\n");
+ return;
+ }
+ $mw->Busy(-recurse => 1);
+ info("Restoring $pkg, rev $rev from $opts{'backupdir'}/${pkg}.r${rev}.tar.xz\n");
+ restore_one_package($pkg, $rev, $opts{"backupdir"});
+ reinit_local_tlpdb;
+ $restore_dialog->Show;
+ $pkg = "";
+ $rev = "";
+ $mw->Unbusy;
+ })->pack(@p_ii);
+ $tf->Button(-text => __("Restore all package to latest version"),
+ -command => sub {
+ $mw->Busy(-recurse => 1);
+ for my $p (@pkgbackup) {
+ my @tmp = sort {$b <=> $a} (keys %{$backups{$p}});
+ my $r = $tmp[0];
+ info("Restoring $p, rev $r from $opts{'backupdir'}/${p}.r${r}.tar.xz\n");
+ restore_one_package($p, $r, $opts{"backupdir"});
+ }
+ reinit_local_tlpdb;
+ $restore_dialog->Show;
+ $pkg = "";
+ $rev = "";
+ $mw->Unbusy;
+ })->pack(@p_ii);
+
+ $tf->Button(-text => __("Close"),
+ -command => sub { $sw->destroy; })
+ ->pack(@p_iii);
+}
+
sub cb_handle_symlinks {
my $sw = $mw->Toplevel(-title => __("Handle symlinks in system dirs"));