[tldistro] Whether/how to ship tlmgr

Ken Brown kbrow1i at gmail.com
Sun Mar 27 23:53:32 CEST 2016


Up to now I haven't shipped tlmgr with my build of TeX Live for the 
Cygwin distribution, primarily out of laziness.  But I would like to 
start shipping it, with modifications, so that users can install, 
remove, and update packages (in user mode), independent of Cygwin's 
package manager.  There are also other actions (such as managing paper 
size) that would be useful.

I noticed that Debian ships tlmgr but only allows it to run in user 
mode.  This rules out 'tlmgr paper', among other things.  I'm thinking 
of a less restrictive modification, in which certain actions are allowed 
only in user mode, others are allowed only in system mode, and so on. 
The attached patch (only lightly tested so far) gives an idea of what I 
have in mind.

Does anyone see any problems with this?  What do other distros do?

Ken
-------------- next part --------------
--- tlmgr.pl.orig	2016-01-06 21:44:29.000000000 -0500
+++ tlmgr.pl	2016-03-27 14:13:41.584791500 -0400
@@ -145,6 +145,9 @@
   "help" => 1,
   "h|?" => 1);
 
+my $USER_OK = 1;
+my $SYS_OK = 2;
+
 my %action_specification = (
   '_include_tlpobj' => {
     "run-post" => 0,
@@ -158,7 +161,8 @@
       "dry-run|n" => 1
     },
     "run-post" => 1,
-    "function" => \&action_backup
+    "function" => \&action_backup,
+    "cygwin_allowed" => $USER_OK
   },
   "candidates" => {
     "run-post" => 0,
@@ -198,7 +202,8 @@
   "gui" => { 
     "options"  => { "load" => 1 },
     "run-post" => 1,
-    "function" => \&action_gui
+    "function" => \&action_gui,
+    "cygwin_allowed" => 0
   },
   "info" => { 
     "options"  => { "list" => 1, "only-installed" => 1 },
@@ -221,11 +226,13 @@
       "with-src" => 1,
     },
     "run-post" => 1,
-    "function" => \&action_install
+    "function" => \&action_install,
+    "cygwin_allowed" => $USER_OK
   },
   "option" => { 
     "run-post" => 1,
-    "function" => \&action_option
+    "function" => \&action_option,
+    "cygwin_allowed" => $USER_OK
   },
   "paper" => { 
     "options"  => { "list" => 1 },
@@ -235,7 +242,8 @@
   "path" => {
     "options"  => { "w32mode" => "=s" },
     "run-post" => 0,
-    "function" => \&action_path
+    "function" => \&action_path,
+    "cygwin_allowed" => 0
   },
   "pinning" => { 
     "options"  => { "all" => 1 },
@@ -245,7 +253,8 @@
   "platform" => { 
     "options"  => { "dry-run|n" => 1 },
     "run-post" => 1,
-    "function" => \&action_platform
+    "function" => \&action_platform,
+    "cygwin_allowed" => 0
   },
   "postaction" => {
     "options" => {
@@ -254,7 +263,8 @@
       "fileassocmode" => "=i"
     },
     "run-post" => 0,
-    "function" => \&action_postaction
+    "function" => \&action_postaction,
+    "cygwin_allowed" => 0
   },
   "recreate-tlpdb" => { 
     "options"  => { "platform|arch" => "=s" },
@@ -269,12 +279,14 @@
       "dry-run|n" => 1
     },
     "run-post" => 1,
-    "function" => \&action_remove
+    "function" => \&action_remove,
+    "cygwin_allowed" => $USER_OK
   },
   repository => {
     "options"  => { "with-platforms" => 1 },
     "run-post" => 1,
-    "function" => \&action_repository
+    "function" => \&action_repository,
+    "cygwin_allowed" => $USER_OK
   },
   "restore" => {
     "options"  => {
@@ -284,7 +296,8 @@
       "force" => 1
     },
     "run-post" => 1,
-    "function" => \&action_restore
+    "function" => \&action_restore,
+    "cygwin_allowed" => $USER_OK
   },
   "search" => {
     "options"  => {
@@ -299,7 +312,8 @@
   "uninstall" => {
     "options"  => { "force" => 1 },
     "run-post" => 0,
-    "function" => \&action_uninstall
+    "function" => \&action_uninstall,
+    "cygwin_allowed" => $USER_OK
   },
   "update" => {
     "options"  => {
@@ -318,7 +332,8 @@
       "dry-run|n" => 1
     },
     "run-post" => 1,
-    "function" => \&action_update
+    "function" => \&action_update,
+    "cygwin_allowed" => $USER_OK
   },
   "version" => { }, # handled separately
 );
@@ -524,6 +539,26 @@
     exit ($F_ERROR);
   }
 
+  # bail out if the action is disabled on Cygwin
+  if (defined($action_specification{$action}{'cygwin_allowed'})
+      && !$action_specification{$action}{'cygwin_allowed'}) {
+    tlwarn("$prg: action disabled on Cygwin: $action\n");
+    exit ($F_ERROR);
+  }
+  if $opts{"usermode"} {
+    if (defined($action_specification{$action}{'cygwin_allowed'})
+        && !($action_specification{$action}{'cygwin_allowed'} & $USER_OK)) {
+      tlwarn("$prg: action disabled in user mode on Cygwin: $action\n");
+      exit ($F_ERROR);
+    }
+  } else {
+    if (defined($action_specification{$action}{'cygwin_allowed'})
+        && !($action_specification{$action}{'cygwin_allowed'} & $SYS_OK)) {
+      tlwarn("$prg: action only allowed in user mode on Cygwin: $action\n");
+      exit ($F_ERROR);
+    }
+  }
+
   # check on supported arguments
   #
   my %suppargs;


More information about the tldistro mailing list