summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2009-07-09 14:52:51 +0000
committerNorbert Preining <preining@logic.at>2009-07-09 14:52:51 +0000
commit8a6a08b307d544f708e75f405a4de2aea186c512 (patch)
treee2ba1bc67f3e87456f15d41bccf020700bcfcd19 /Master
parent2cbbb287ec0431a9840e2dc26751d58b1621a97d (diff)
implement
tlmgr postaction add|remove shortcut|fileassoc|script ... git-svn-id: svn://tug.org/texlive/trunk@14207 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl115
1 files changed, 115 insertions, 0 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index cd01495709b..858dce9f4fc 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -138,6 +138,8 @@ my %actionoptions = (
"arch" => { "dry-run|n" => 1 },
"generate" => { "localcfg" => "=s",
"dest" => "=s" },
+ "postaction" => {"w32mode" => "=s",
+ "fileassoc" => "=i" },
"uninstall"=> { "force" => 1 },
"check" => { "use-svn" => 1 },
"recreate-tlpdb" => { "arch" => "=s" }
@@ -374,6 +376,9 @@ sub execute_action {
} elsif ($action =~ m/^search$/i) {
action_search();
finish(0);
+ } elsif ($action =~ m/^postaction$/i) {
+ action_postaction();
+ finish(0);
} elsif ($action =~ m/^show$/i) {
action_show();
finish(0);
@@ -2890,6 +2895,108 @@ sub check_depends {
return $ret;
}
+
+#
+# action_postaction
+# this action calls the various post actions if one want's to do that
+# on a client system or overriding global settings
+# tlmgr postaction [--w32mode=user|admin] [--fileassoc=1|2] [--all]
+# [install|remove] [shortcut|fileassoc|script] [<package> <package> ...]
+
+sub action_postaction {
+ my $how = shift @ARGV;
+ if (!defined($how) || ($how !~ m/^(install|remove)$/i)) {
+ tlwarn("action postaction needs at least two arguments, first being either 'install' or 'remove'\n");
+ return;
+ }
+ my $type = shift @ARGV;
+ my $badtype = 0;
+ if (!defined($type)) {
+ $badtype = 1;
+ } elsif ($type !~ m/^(shortcut|fileassoc|script)$/i) {
+ $badtype = 1;
+ }
+ if ($badtype) {
+ tlwarn("action postaction needs as second argument one from 'shortcut', 'fileassoc', 'script'\n");
+ return;
+ }
+ if ($opts{"w32mode"}) {
+ if ($opts{"w32mode"} eq "user") {
+ if (win32() && TeXLive::TLWinGoo::admin()) {
+ debug("Switching to user mode on user request\n");
+ TeXLive::TLWinGoo::non_admin();
+ }
+ } elsif ($opts{"w32mode"} eq "admin") {
+ if (win32() && !TeXLive::TLWinGoo::admin()) {
+ tlwarn("You don't have the permissions for --w32mode=admin\n");
+ return;
+ }
+ } else {
+ tlwarn("action postaction --w32mode can only be 'admin' or 'user'\n");
+ return;
+ }
+ }
+ my @todo;
+ if ($opts{"all"}) {
+ init_local_db();
+ @todo = $localtlpdb->list_packages;
+ } else {
+ if ($#ARGV < 0) {
+ tlwarn("action postaction: need either --all or a list of packages\n");
+ return;
+ }
+ init_local_db();
+ @todo = @ARGV;
+ @todo = $localtlpdb->expand_dependencies("-only-arch", $localtlpdb, @todo);
+ }
+ if ($type =~ m/^shortcut$/i) {
+ if (!win32()) {
+ tlwarn("action postaction shortcut only works on windows.\n");
+ return;
+ }
+ for my $p (@todo) {
+ my $tlp = $localtlpdb->get_package($p);
+ if (!defined($tlp)) {
+ tlwarn("$p is not installed, ignoring it.\n");
+ } else {
+ TeXLive::TLUtils::do_postaction($how, $tlp, 0, 1, 0);
+ }
+ }
+ } elsif ($type =~ m/^fileassoc$/i) {
+ if (!win32()) {
+ tlwarn("action postaction fileassoc only works on windows.\n");
+ return;
+ }
+ my $fa = $localtlpdb->option("file_assocs");
+ if ($opts{"fileassoc"}) {
+ if ($opts{"fileassoc"} < 1 || $opts{"fileassoc"} > 2) {
+ tlwarn("action postaction: value of --fileassoc can only be 1 or 2\n");
+ return;
+ }
+ $fa = $opts{"fileassoc"};
+ }
+ for my $p (@todo) {
+ my $tlp = $localtlpdb->get_package($p);
+ if (!defined($tlp)) {
+ tlwarn("$p is not installed, ignoring it.\n");
+ } else {
+ TeXLive::TLUtils::do_postaction($how, $tlp, $fa, 0, 0);
+ }
+ }
+ } elsif ($type =~ m/^script$/i) {
+ for my $p (@todo) {
+ my $tlp = $localtlpdb->get_package($p);
+ if (!defined($tlp)) {
+ tlwarn("$p is not installed, ignoring it.\n");
+ } else {
+ TeXLive::TLUtils::do_postaction($how, $tlp, 0, 0, 1);
+ }
+ }
+ } else {
+ tlwarn("action postaction needs one of 'shortcut', 'fileassoc', 'script'\n");
+ return;
+ }
+}
# Subroutines galore.
@@ -3547,6 +3654,14 @@ On W32 based systems it adds or removes the binary dir to the system or
user registry path entry, depending on being admin and the setting
$tlpdb->option("w32_multi_user").
+=head2 postaction [--w32mode=user|admin] [--fileassoc=1|2] [--all]
+ [install|remove] [shortcut|fileassoc|script] [<package> <package> ...]
+
+Carry out the postaction specified by C<--type> for each of the given
+C<<package>>, or for all packages if C<--all> is given. The direction
+(installing or removing) is given by the first obligatory argument, while
+the postaction to be carried out is given by the second obligatory
+argument.
=head2 paper