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
|
Allow more than one repository in the tlpdb/option-location field
The format is:
repo1[#tag] repo2[#tag] ...
the tags are optional.
This patch only adds support for a new action "repository" that lists,
adds, removes, sets repositories according to this format.
It does not change tlmgr to allow actually working with it.
---
texmf/scripts/texlive/tlmgr.pl | 99 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
Index: Master/texmf/scripts/texlive/tlmgr.pl
===================================================================
--- Master.orig/texmf/scripts/texlive/tlmgr.pl 2010-05-02 01:31:56.000000000 +0900
+++ Master/texmf/scripts/texlive/tlmgr.pl 2010-05-02 01:32:12.000000000 +0900
@@ -455,6 +455,9 @@
} elsif ($action =~ m/^option$/i) {
action_option();
finish(0);
+ } elsif ($action =~ m/^repository$/i) {
+ action_repository();
+ finish(0);
} elsif ($action =~ m/^list$/i) {
action_list();
finish(0);
@@ -2839,6 +2842,102 @@
return;
}
+# REPOSITORY
+#
+# this action manages the list of repositories
+# tlmgr repository list -> lists repositories
+# tlmgr repository add path [tag] -> add repository with optional tag
+# tlmgr repository remove [path|tag] -> removes repository or tag
+# tlmgr repository set path[#tag] [path[#tag] ...] -> sets the list
+#
+
+sub array_to_repository {
+ my %r = @_;
+ my @ret;
+ for my $k (keys %r) {
+ my $v = $r{$k};
+ if ($k eq $v) {
+ push @ret, $k;
+ } else {
+ push @ret, "$v#$k";
+ }
+ }
+ return "@ret";
+}
+sub repository_to_array {
+ my $r = shift;
+ my %r;
+ for my $rr (split ' ', $r) {
+ if ($rr =~ m/^([^#]+)#(.*)$/) {
+ $r{$2} = $1;
+ } else {
+ $r{$rr} = $rr;
+ }
+ }
+ return %r;
+}
+sub action_repository {
+ init_local_db();
+ my $what = shift @ARGV;
+ my %repos = repository_to_array($localtlpdb->option("location"));
+ if ($what =~ m/^list$/i) {
+ print "List of repositories (with tags if set):\n";
+ for my $k (keys %repos) {
+ my $v = $repos{$k};
+ print "\t$v";
+ if ($k ne $v) {
+ print " ($k)";
+ }
+ print "\n";
+ }
+ return;
+ }
+ if ($what eq "add") {
+ my $p = shift @ARGV;
+ if (!defined($p)) {
+ tlwarn("You need to give a new repository aas argument to add\n");
+ return;
+ }
+ my $t = shift @ARGV;
+ $t = $p if (!defined($t));
+ if (defined($repos{$t})) {
+ tlwarn("This repository or its tag is already defined, no action\n");
+ return;
+ }
+ # TODO more checks needed?
+ $repos{$t} = $p;
+ $localtlpdb->option("location", array_to_repository(%repos));
+ $localtlpdb->save;
+ return;
+ }
+ if ($what eq "remove") {
+ my $p = shift @ARGV;
+ if (!defined($p)) {
+ tlwarn("Which repository should be removed?\n");
+ return;
+ }
+ my $found = 0;
+ for my $k (keys %repos) {
+ if ($k eq $p || $repos{$k} eq $p) {
+ $found = 1;
+ delete $repos{$k};
+ }
+ }
+ if (!$found) {
+ tlwarn("Cannot find the repository $p\n");
+ } else {
+ $localtlpdb->option("location", array_to_repository(%repos));
+ $localtlpdb->save;
+ }
+ return;
+ }
+ if ($what eq "set") {
+ %repos = repository_to_array("@ARGV");
+ $localtlpdb->option("location", array_to_repository(%repos));
+ $localtlpdb->save;
+ }
+}
+
# OPTION
#
|