summaryrefslogtreecommitdiff
path: root/Master/tlpkg/etc/dev.allow-disabling-formats-and-maps-in-local-cfg-file.patch
blob: 0e919f7af2ac80a3504fd09716d24a8ea22b4168 (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
Index: tlpkg/TeXLive/TLPDB.pm
===================================================================
--- tlpkg/TeXLive/TLPDB.pm	(revision 14688)
+++ tlpkg/TeXLive/TLPDB.pm	(working copy)
@@ -1221,6 +1221,9 @@
 The function C<fmtutil_cnf_lines> returns the list of a fmtutil.cnf file
 containing only those formats present in the installation.
 
+Every format listed in the tlpdb but listed in the arguments
+will not be included in the list of lines returned.
+
 =cut
 sub fmtutil_cnf_lines {
   my $self = shift;
@@ -1228,16 +1231,19 @@
   foreach my $p ($self->list_packages) {
     my $obj = $self->get_package ($p);
     die "$0: No TeX Live package named $p, strange" if ! $obj;
-    push @lines, $obj->fmtutil_cnf_lines;
+    push @lines, $obj->fmtutil_cnf_lines(@_);
   }
   return(@lines);
 }
 
-=item C<< $tlpdb->updmap_cfg_lines >>
+=item C<< $tlpdb->updmap_cfg_lines ( [@disabled_maps] ) >>
 
 The function C<updmap_cfg_lines> returns the list of a updmap.cfg file
 containing only those maps present in the installation.
 
+A map file mentioned in the tlpdb but listed in the arguments will not 
+be included in the list of lines returned.
+
 =cut
 sub updmap_cfg_lines {
   my $self = shift;
@@ -1245,16 +1251,19 @@
   foreach my $p ($self->list_packages) {
     my $obj = $self->get_package ($p);
     die "$0: No TeX Live package named $p, strange" if ! $obj;
-    push @lines, $obj->updmap_cfg_lines;
+    push @lines, $obj->updmap_cfg_lines(@_);
   }
   return(@lines);
 }
 
-=item C<< $tlpdb->language_dat_lines >>
+=item C<< $tlpdb->language_dat_lines ( [@disabled_hyphen_names] )>>
 
 The function C<language_dat_lines> returns the list of all
 lines for language.dat that can be generated from the tlpdb.
 
+Every hyphenation pattern listed in the tlpdb but listed in the arguments
+will not be included in the list of lines returned.
+
 =cut
 
 sub language_dat_lines {
@@ -1263,16 +1272,19 @@
   foreach my $p ($self->list_packages) {
     my $obj = $self->get_package ($p);
     die "$0: No TeX Live package named $p, strange" if ! $obj;
-    push @lines, $obj->language_dat_lines;
+    push @lines, $obj->language_dat_lines(@_);
   }
   return(@lines);
 }
 
-=item C<< $tlpdb->language_def_lines >>
+=item C<< $tlpdb->language_def_lines ( [@disabled_hyphen_names] )>>
 
 The function C<language_def_lines> returns the list of all
 lines for language.def that can be generated from the tlpdb.
 
+Every hyphenation pattern listed in the tlpdb but listed in the arguments
+will not be included in the list of lines returned.
+
 =cut
 
 sub language_def_lines {
@@ -1281,7 +1293,7 @@
   foreach my $p ($self->list_packages) {
     my $obj = $self->get_package ($p);
     die "$0: No TeX Live package named $p, strange" if ! $obj;
-    push @lines, $obj->language_def_lines;
+    push @lines, $obj->language_def_lines(@_);
   }
   return(@lines);
 }
Index: tlpkg/TeXLive/TLPOBJ.pm
===================================================================
--- tlpkg/TeXLive/TLPOBJ.pm	(revision 14688)
+++ tlpkg/TeXLive/TLPOBJ.pm	(working copy)
@@ -938,6 +938,7 @@
 #
 sub fmtutil_cnf_lines {
   my $obj = shift;
+  my @disabled = @_;
   my @fmtlines = ();
   my $first = 1;
   my $pkg = $obj->name;
@@ -952,6 +953,7 @@
         $first = 0;
       }
       my $mode = ($r{"mode"} ? "" : "#! ");
+      $mode = "#! " if TeXLive::TLUtils::member ($r{'name'}, @disabled);
       push @fmtlines, "$mode$r{'name'} $r{'engine'} $r{'patterns'} $r{'options'}\n";
     }
   }
@@ -961,6 +963,7 @@
 
 sub updmap_cfg_lines {
   my $obj = shift;
+  my @disabled = @_;
   my %maps;
   foreach my $e ($obj->executes) {
     if ($e =~ m/addMap (.*)$/) {
@@ -972,6 +975,7 @@
   }
   my @updmaplines;
   foreach (sort keys %maps) {
+    next if TeXLive::TLUtils::member($_, @disabled);
     if ($maps{$_} == 2) {
       push @updmaplines, "MixedMap $_\n";
     } else {
@@ -983,24 +987,29 @@
 
 
 sub language_dat_lines {
+  my $self = shift;
+  local @disabled = @_;
   sub make_dat_lines {
     my ($name, $lhm, $rhm, $file, @syn) = @_;
     my @ret;
+    return if TeXLive::TLUtils::member($name, @disabled);
     push @ret, "$name $file\n";
     foreach (@syn) {
       push @ret, "=$_\n";
     }
     return(@ret);
   }
-  my $self = shift;
   my @lines = $self->_parse_hyphen_execute(\&make_dat_lines);
   return(@lines);
 }
 
 
 sub language_def_lines {
+  my $self = shift;
+  local @disabled = @_;
   sub make_def_lines {
     my ($name, $lhm, $rhm, $file, @syn) = @_;
+    return if TeXLive::TLUtils::member($name, @disabled);
     my $exc = "";
     my @ret;
     push @ret, "\\addlanguage\{$name\}\{$file\}\{$exc\}\{$lhm\}\{$rhm\}\n";
@@ -1011,7 +1020,6 @@
     }
     return(@ret);
   }
-  my $self = shift;
   my @lines = $self->_parse_hyphen_execute(\&make_def_lines);
   return(@lines);
 }
Index: tlpkg/TeXLive/TLUtils.pm
===================================================================
--- tlpkg/TeXLive/TLUtils.pm	(revision 14688)
+++ tlpkg/TeXLive/TLUtils.pm	(working copy)
@@ -2297,22 +2297,45 @@
 
 =cut
 
+#
+# get_disabled_local_configs
+# returns the list of disabled formats/hyphenpatterns/maps
+# disabling is done by putting
+#    #!NAME
+# into the respective XXXX-local.cnf/cfg file
+# 
+# WARNING this is only supported for updmap.cfg and fmtutil.cnf, since
+# WARNING those files use # as comment char and have line oriented structure
+#
+sub get_disabled_local_configs {
+  my $localconf = shift;
+  if (-r "$localconf") {
+    open FOO, "<$localconf"
+      or die "strange, -r ok but cannot open $localconf: $!";
+    my @tmp = <FOO>;
+    close(FOO) || warn("Closing $localconf did not succeed: $!");
+    my @disabled = map { if (m/^#!(\S+)\s*$/) { $1 } else { }} @tmp;
+    return @disabled;
+  }
+}
+
 sub create_fmtutil {
   my ($tlpdb,$dest,$localconf) = @_;
-  my @lines = $tlpdb->fmtutil_cnf_lines;
+  my @lines = $tlpdb->fmtutil_cnf_lines(get_disabled_local_configs($localconf));
   _create_config_files($tlpdb, "texmf/web2c/fmtutil-hdr.cnf", $dest,
                        $localconf, 0, '#', \@lines);
 }
 
 sub create_updmap {
   my ($tlpdb,$dest,$localconf) = @_;
-  my @lines = $tlpdb->updmap_cfg_lines;
+  my @lines = $tlpdb->updmap_cfg_lines(get_disabled_local_configs($localconf));
   _create_config_files($tlpdb, "texmf/web2c/updmap-hdr.cfg", $dest,
                        $localconf, 0, '#', \@lines);
 }
 
 sub create_language_dat {
   my ($tlpdb,$dest,$localconf) = @_;
+  # no checking for disabled stuff for language.dat and .def
   my @lines = $tlpdb->language_dat_lines;
   _create_config_files($tlpdb, "texmf/tex/generic/config/language.us", $dest,
                        $localconf, 0, '%', \@lines);
@@ -2320,6 +2343,7 @@
 
 sub create_language_def {
   my ($tlpdb,$dest,$localconf) = @_;
+  # no checking for disabled stuff for language.dat and .def
   my @lines = $tlpdb->language_def_lines;
   my @postlines;
   push @postlines, "%%% No changes may be made beyond this point.\n";