summaryrefslogtreecommitdiff
path: root/Master/tlpkg/etc/dev.usermode-tlmgr.patch
blob: 3d3aa4f75198f7635e32fe07038d4d69188a0593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Index: tlpkg/TeXLive/TLConfig.pm
===================================================================
--- tlpkg/TeXLive/TLConfig.pm	(revision 14488)
+++ tlpkg/TeXLive/TLConfig.pm	(working copy)
@@ -162,11 +162,13 @@
 
 our %TLPDBSettingType = (
   "platform"                => "s",
-  "available_architectures" => "l"
+  "available_architectures" => "l",
+  "usertree"                => "b"
 );
 our %TLPDBSettingDesc = (
   "platform"                => "Main platform for this computer",
-  "available_architectures" => "All available/installed architectures"
+  "available_architectures" => "All available/installed architectures",
+  "usertree"                => "This tree acts as user tree"
 );
 
 
Index: tlpkg/TeXLive/TLMedia.pm
===================================================================
--- tlpkg/TeXLive/TLMedia.pm	(revision 14488)
+++ tlpkg/TeXLive/TLMedia.pm	(working copy)
@@ -48,6 +48,8 @@
     }
     if (-d "$location/texmf/web2c") {
       $media = 'DVD';
+    } elsif (-d "$location/web2c") {
+      $media = 'DVD';
     } elsif (-d "$location/$Archive") {
       $media = 'CD';
     } else {
@@ -142,6 +144,7 @@
     my $opt_doc = $totlpdb->option("install_docfiles");
     my $real_opt_doc = $opt_doc;
     my $reloc = 1 if $tlpobj->relocated;
+    $reloc = 0 if $totlpdb->setting("usertree");
     my $container;
     my @installfiles;
     my $location = $self->location;
@@ -235,7 +238,7 @@
     }
     # if a package is relocatable we have to cancel the reloc prefix
     # before we save it to the local tlpdb
-    if ($tlpobj->relocated) {
+    if ($reloc) {
       $tlpobj->cancel_reloc_prefix;
     }
     # we have to write out the tlpobj file since it is contained in the
@@ -388,6 +391,7 @@
   my ($self, $pkg, $nopostinstall) = @_;
   my $localtlpdb = $self->tlpdb;
   my $tlp = $localtlpdb->get_package($pkg);
+  my $usertree = $localtlpdb->setting("usertree");
   if (!defined($tlp)) {
     tlwarn ("$pkg: package not present, cannot remove\n");
   } else {
@@ -413,9 +417,14 @@
     # in user mode we just remove the prefix, in normal mode we
     # replace it with texmf-dist
     # since we don't have user mode 
+
     if ($tlp->relocated) {
       for (@files) {
-        s:^$RelocPrefix/:$RelocTree/:;
+        if ($usertree) {
+          s:^$RelocPrefix/::;
+        } else {
+          s:^$RelocPrefix/:$RelocTree/:;
+        }
       }
     }
     #
Index: texmf/scripts/texlive/tlmgr.pl
===================================================================
--- texmf/scripts/texlive/tlmgr.pl	(revision 14493)
+++ texmf/scripts/texlive/tlmgr.pl	(working copy)
@@ -125,6 +125,8 @@
     "machine-readable" => 1,
     "package-logfiles" => "=s",
     "pause" => 1,
+    "usermode" => 1,
+    "usertree" => "=s",
     "version" => 1,
     "help|h|?" => 1);
 
@@ -287,13 +289,30 @@
     pod2usage(-msg => $msg, -exitstatus => 1, -verbose => 1, @noperldoc);
   }
 
+  #
+  # the main tree we will be working on
+  $::maintree = $Master;
+  if ($opts{"usermode"}) {
+    # we could also try to detect that we don't have write permissions
+    # and switch to user mode automatically
+    if (defined($opts{"usertree"})) {
+      $::maintree = $opts{"usertree"};
+    } else {
+      chomp($::maintree = `kpsewhich -var-value TEXMFHOME`);
+    }
+  }
+
   # besides doing normal logging if -logfile is specified, we try to log
   # package related actions (install, remove, update) to
   # the package-log file TEXMFSYSVAR/web2c/tlmgr.log
   $packagelogged = 0;  # how many msgs we logged
   chomp (my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`);
   $packagelogfile = $opts{"package-logfile"};
-  $packagelogfile ||= "$texmfsysvar/web2c/tlmgr.log";
+  if ($opts{"usermode"}) {
+    $packagelogfile ||= "$::maintree/web2c/tlmgr.log";
+  } else {
+    $packagelogfile ||= "$texmfsysvar/web2c/tlmgr.log";
+  }
   #
   # Try to open the packagelog file, but do NOT die when that does not work
   if (!open(PACKAGELOG, ">>$packagelogfile")) {
@@ -416,6 +435,9 @@
   } elsif ($action =~ m/^show$/i) {
     action_show();
     finish(0);
+  } elsif ($action =~ m/^init-usertree$/i) {
+    action_init_usertree();
+    finish(0);
   } elsif ($action =~ m/^remove$/i) {
     action_remove();
   } elsif ($action =~ /^paper$/) {
@@ -1988,16 +2010,18 @@
   $opts{"no-depends"} = 1 if $opts{"no-depends-at-all"};
   init_tlmedia();
 
-  # check for updates to tlmgr itself, and die unless --force is given
-  if (check_for_critical_updates( $localtlpdb, $tlmediatlpdb)) {
-    if ($opts{"force"}) {
-      tlwarn("Continuing due to --force\n");
-    } else {
-      if ($::gui_mode) {
-        # return here and don't do any updates
-        return;
+  if (!$opts{"usermode"}) {
+    # check for updates to tlmgr itself, and die unless --force is given
+    if (check_for_critical_updates( $localtlpdb, $tlmediatlpdb)) {
+      if ($opts{"force"}) {
+        tlwarn("Continuing due to --force\n");
       } else {
-        die "tlmgr: Not continuing, please see warning above!\n";
+        if ($::gui_mode) {
+          # return here and don't do any updates
+          return;
+        } else {
+          die "tlmgr: Not continuing, please see warning above!\n";
+        }
       }
     }
   }
@@ -3119,6 +3143,34 @@
 
 
 #
+# action init_user_tree
+# sets up TEXMFHOME or --usertree argument for user mode tlmgr
+# by creating a minimal tlpdb
+#
+sub action_init_usertree {
+  init_local_db();
+  my $tlpdb = TeXLive::TLPDB->new;
+  my $usertree;
+  if ($opts{"usertree"}) {
+    $usertree = $opts{"usertree"};
+  } else {
+    chomp($usertree = `kpsewhich -var-value TEXMFHOME`);
+  }
+  $tlpdb->root($usertree);
+  my $inst = TeXLive::TLPOBJ->new;
+  $inst->name("00texlive.installation");
+  $inst->category("TLCore");
+  my @deps;
+  push @deps, "opt_location:$location";
+  push @deps, "setting_available_architectures:";
+  push @deps, "setting_usertree:1";
+  $inst->depends(@deps);
+  $tlpdb->add_tlpobj($inst);
+  $tlpdb->save;
+}
+
+
+#
 # action conf
 # tries to mimick texconfig conf but probably will add some more things
 #
@@ -3182,10 +3234,10 @@
   # stuff changed via the GUI
   return if defined $localtlmedia;
   return if defined $localtlpdb;
-  $localtlmedia = TeXLive::TLMedia->new ( $Master );
-  die("cannot setup TLMedia in $Master") unless (defined($localtlmedia));
+  $localtlmedia = TeXLive::TLMedia->new ( $::maintree );
+  die("cannot setup TLMedia in $::maintree") unless (defined($localtlmedia));
   $localtlpdb = $localtlmedia->tlpdb;
-  die("cannot find tlpdb in $Master") unless (defined($localtlpdb));
+  die("cannot find tlpdb in $::maintree") unless (defined($localtlpdb));
   # setup the programs, for w32 we need the shipped wget/xz etc, so we
   # pass the location of these files to setup_programs.
   if (!setup_programs("$Master/tlpkg/installer", $localtlmedia->platform)) {