summaryrefslogtreecommitdiff
path: root/Master/tlpkg/archive/applied.use-autopatterns-from-dedicated-tlpsrc-files.patch
blob: 3f9dad59c2fd05359b6bf2aa1f9b009287244f23 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396

This patch adds the ability to change the auto generated patterns by
adding one tlpsrc file named
	00texlive.autopatterns.tlpsrc
and within these files the relevant src/bin/doc/run patterns, but the FIRST
word in the pattern is the category to which the pattern applies.

The included 00texlive.autopatterns.tlpsrc adds the necessary patterns
to get the exact same behaviour as before.

tlpsrc2tlpdb also gets a command line --no-autopatterns if you want
to disable loading of auto patterns.

Warning: This change will make the description for maintaining separate
repositories a bit outdated, since now also these autopattern files
have to be added, or patterns themselves have to be specified.

Index: tlpkg/TeXLive/TLPSRC.pm
===================================================================
--- tlpkg/TeXLive/TLPSRC.pm	(revision 11079)
+++ tlpkg/TeXLive/TLPSRC.pm	(working copy)
@@ -201,7 +201,11 @@
 #
 sub make_tlpobj
 {
-  my ($self,$tltree) = @_;
+  my ($self,$tltree,$defaultpatterns) = @_;
+  my %patterns;
+  if (defined($defaultpatterns)) {
+    %patterns = %{$defaultpatterns};
+  }
   my $tlp = TeXLive::TLPOBJ->new;
   $tlp->name($self->name);
   $tlp->category($self->category);
@@ -212,124 +216,67 @@
   $tlp->depends(@{$self->{'depends'}}) if (defined($self->{'depends'}));
   $tlp->revision(0);
   my $filemax;
-  my $usedefault = 1;
+  my $usedefault;
   my @allpospats;
   my @allnegpats;
+  my $pkgname = $self->name;
   #
-  # runpatterns
+  # src/run/doc patterns
   #
-  foreach my $p (@{$self->{'runpatterns'}}) {
-    if ($p =~ m/^\+!(.*)$/) {
-      push @allnegpats, $1;
-    } elsif ($p =~ m/^\+(.*)$/) {
-      push @allpospats, $1;
-    } elsif ($p =~ m/^!(.*)$/) {
-      push @allnegpats, $1;
-      $usedefault = 0;
-    } else {
-      push @allpospats, $p;
-      $usedefault = 0;
+  # WARNING WARNING WARNING
+  # the "bin" must be last since we drop through for further dealing
+  # with specialities of the bin patterns!!!!
+  for my $pattype (qw/src run doc bin/) {
+    @allpospats = ();
+    @allnegpats = ();
+    $usedefault = 1;
+    foreach my $p (@{$self->{${pattype} . 'patterns'}}) {
+      if ($p =~ m/^\+!(.*)$/) {
+        push @allnegpats, $1;
+      } elsif ($p =~ m/^\+(.*)$/) {
+        push @allpospats, $1;
+      } elsif ($p =~ m/^!(.*)$/) {
+        push @allnegpats, $1;
+        $usedefault = 0;
+      } else {
+        push @allpospats, $p;
+        $usedefault = 0;
+      }
     }
-  }
-  if ($usedefault) {
-    if ($self->category eq "Package") {
-      foreach my $md (qw/bibtex context dvips fonts makeindex metafont
-                metapost mft omega scripts tex vtex/) {
-        # mark the default pattern with a leading * so that
-        # we do not warn a missing hit on a default pattern
-        push @allpospats, "*t texmf-dist $md $self->{'name'}";
+    if ($usedefault && defined($patterns{$pattype})) {
+      for my $p (@{$patterns{$pattype}}) {
+        # replace the string %NAME% with the actual package name
+        # we have to make a copy of $p otherwise we change it in the
+        # hash once and for all
+        (my $pp = $p) =~ s/%NAME%/$pkgname/g;
+        # sort through the patterns, and make sure that * are added to 
+        # tag the default patterns
+        if ($pp =~ m/^!(.*)$/) {
+          push @allnegpats, "*$1";
+        } else {
+          push @allpospats, "*$pp";
+        }
       }
     }
-  }
-  foreach my $p (@allpospats) {
-    $self->_do_normal_pattern($p,$tlp,$tltree,'run');
-  }
-  foreach my $p (@allnegpats) {
-    $self->_do_normal_pattern($p,$tlp,$tltree,'run',1);
-  }
-  #
-  # srcpatterns
-  #
-  @allpospats = ();
-  @allnegpats = ();
-  $usedefault = 1;
-  foreach my $p (@{$self->{'srcpatterns'}}) {
-    if ($p =~ m/^\+!(.*)$/) {
-      push @allnegpats, $1;
-    } elsif ($p =~ m/^\+(.*)$/) {
-      push @allpospats, $1;
-    } elsif ($p =~ m/^!(.*)$/) {
-      push @allnegpats, $1;
-      $usedefault = 0;
-    } else {
-      push @allpospats, $p;
-      $usedefault = 0;
+    # at this point we do NOT do the actual pattern matching for 
+    # bin patterns, since we have some specialities to do
+    last if ($pattype eq "bin");
+    # for all other patterns we create the list and add the files
+    foreach my $p (@allpospats) {
+      ddebug("pos pattern $p\n");
+      $self->_do_normal_pattern($p,$tlp,$tltree,$pattype);
     }
-  }
-  if ($usedefault) {
-    # default patterns for srcfiles
-    if ($self->category eq "Package") {
-      push @allpospats, "*t texmf-dist source $self->{'name'}";
-    } elsif ($self->category eq "Documentation") {
-      push @allpospats, "*t texmf-doc source $self->{'name'}";
+    foreach my $p (@allnegpats) {
+      ddebug("neg pattern $p\n");
+      $self->_do_normal_pattern($p,$tlp,$tltree,$pattype,1);
     }
   }
-  foreach my $p (@allpospats) {
-    $self->_do_normal_pattern($p,$tlp,$tltree,'src');
-  }
-  foreach my $p (@allnegpats) {
-    $self->_do_normal_pattern($p,$tlp,$tltree,'src',1);
-  }
   #
-  # docpatterns
-  #
-  @allpospats = ();
-  @allnegpats = ();
-  $usedefault = 1;
-  foreach my $p (@{$self->{'docpatterns'}}) {
-    if ($p =~ m/^\+!(.*)$/) {
-      push @allnegpats, $1;
-    } elsif ($p =~ m/^\+(.*)$/) {
-      push @allpospats, $1;
-    } elsif ($p =~ m/^!(.*)$/) {
-      push @allnegpats, $1;
-      $usedefault = 0;
-    } else {
-      push @allpospats, $p;
-      $usedefault = 0;
-    }
-  }
-  if ($usedefault) {
-    # default patterns for docfiles
-    if ($self->category eq "Package") {
-      push @allpospats, "*t texmf-dist doc $self->{'name'}";
-    } elsif ($self->category eq "Documentation") {
-      push @allpospats, "*t texmf-doc doc $self->{'name'}";
-    }
-  }
-  foreach my $p (@allpospats) {
-    $self->_do_normal_pattern($p,$tlp,$tltree,'doc');
-  }
-  foreach my $p (@allnegpats) {
-    $self->_do_normal_pattern($p,$tlp,$tltree,'doc',1);
-  }
-  #
   # binpatterns
   #
-  # no default patterns for binfiles
-  @allpospats = ();
-  @allnegpats = ();
-  foreach my $p (@{$self->{'binpatterns'}}) {
-    if ($p =~ m/^\+!(.*)$/) {
-      push @allnegpats, $1;
-    } elsif ($p =~ m/^\+(.*)$/) {
-      push @allpospats, $1;
-    } elsif ($p =~ m/^!(.*)$/) {
-      push @allnegpats, $1;
-    } else {
-      push @allpospats, $p;
-    }
-  }
+  # mind that @allpospats and @allnegpats have already been set up
+  # in the above loop. We only have to deal with the specialities of
+  # the bin patterns
   foreach my $p (@allpospats) {
     my @todoarchs = $tltree->architectures;
     my $finalp = $p;
@@ -472,17 +419,29 @@
 sub srcpatterns {
   my $self = shift;
   if (@_) { @{ $self->{'srcpatterns'} } = @_ }
-  return @{ $self->{'srcpatterns'} };
+  if (defined($self->{'srcpatterns'})) {
+    return @{ $self->{'srcpatterns'} };
+  } else {
+    return;
+  }
 }
 sub docpatterns {
   my $self = shift;
   if (@_) { @{ $self->{'docpatterns'} } = @_ }
-  return @{ $self->{'docpatterns'} };
+  if (defined($self->{'docpatterns'})) {
+    return @{ $self->{'docpatterns'} };
+  } else {
+    return;
+  }
 }
 sub binpatterns {
   my $self = shift;
   if (@_) { @{ $self->{'binpatterns'} } = @_ }
-  return @{ $self->{'binpatterns'} };
+  if (defined($self->{'binpatterns'})) {
+    return @{ $self->{'binpatterns'} };
+  } else {
+    return;
+  }
 }
 sub depends {
   my $self = shift;
@@ -492,7 +451,11 @@
 sub runpatterns {
   my $self = shift;
   if (@_) { @{ $self->{'runpatterns'} } = @_ }
-  return @{ $self->{'runpatterns'} };
+  if (defined($self->{'runpatterns'})) {
+    return @{ $self->{'runpatterns'} };
+  } else {
+    return;
+  }
 }
 sub executes {
   my $self = shift;
@@ -746,7 +709,9 @@
 
 If a given pattern section is empty or B<all> the provided patterns have
 the prefix C<+> (e.g., C<+f ...>), then the following patterns, listed
-by type are I<automatically> added at expansion time:
+by type are I<automatically> added at expansion time. Note that this list
+is not definitive, but is taken from the patterns of tlpsrc files
+named C<00texlive.autopatterns.>I<Category>C<.tlpsrc>.
 
 =over 4
 
Index: tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc
===================================================================
--- tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc	(revision 0)
+++ tlpkg/tlpsrc/00texlive.autopatterns.tlpsrc	(revision 0)
@@ -0,0 +1,21 @@
+name 00texlive.autopatterns
+category TLCore
+shortdesc Defines the automatically generated patterns
+# auto patterns for category Package
+runpattern Package t texmf-dist bibtex %NAME%
+runpattern Package t texmf-dist context %NAME%
+runpattern Package t texmf-dist dvips %NAME%
+runpattern Package t texmf-dist fonts %NAME%
+runpattern Package t texmf-dist makeindex %NAME%
+runpattern Package t texmf-dist metafont %NAME%
+runpattern Package t texmf-dist metapost %NAME%
+runpattern Package t texmf-dist mft %NAME%
+runpattern Package t texmf-dist omega %NAME%
+runpattern Package t texmf-dist scripts %NAME%
+runpattern Package t texmf-dist tex %NAME%
+runpattern Package t texmf-dist vtex %NAME%
+srcpattern Package t texmf-dist source %NAME%
+docpattern Package t texmf-dist doc %NAME%
+# auto patterns for category Documentation
+srcpattern Documentation t texmf-doc source %NAME%
+docpattern Documentation t texmf-doc doc %NAME%
Index: tlpkg/bin/tlpsrc2tlpdb
===================================================================
--- tlpkg/bin/tlpsrc2tlpdb	(revision 11079)
+++ tlpkg/bin/tlpsrc2tlpdb	(working copy)
@@ -31,6 +31,7 @@
 my $opt_nobinsplit = 0;
 my $opt_winwarning;
 my $opt_fromfiles = 0;
+my $opt_noautopatterns = 0;
 
 TeXLive::TLUtils::process_logging_options();
 GetOptions(
@@ -38,6 +39,7 @@
     "master=s" => \$opt_master,	# location of the TL tree
     "catalogue=s" => \$opt_catalogue, # location of the TeX Catalogue
     "no-bin-split!" => \$opt_nobinsplit,
+    "no-autopatterns" => \$opt_noautopatterns,
     "from-files" => \$opt_fromfiles,
     "with-win-pattern-warning" => \$opt_winwarning,
     "help|?" => \$help) or pod2usage(1);
@@ -63,9 +65,66 @@
     $tlc = TeXLive::TeXCatalogue->new ("location" => $opt_catalogue);
   }
 
+  my $tlpsrc_dir = "$opt_master/tlpkg/tlpsrc";
+
+  # get the default patterns
+  my %autopatterns;
+  if (! $opt_noautopatterns) {
+    my $apfile = "$tlpsrc_dir/00texlive.autopatterns.tlpsrc";
+    if (! -r $apfile) {
+      if (! $opt_noautopatterns) {
+        tlwarn ("No autopatterns tlpsrc 00texlive.autopatterns.tlpsrc found.\n");
+        tlwarn ("Stopping here. If you want to continue either add the above file\n");
+        tlwarn ("or call tlpsrc with --no-autopatterns.\n");
+        exit 1;
+      }
+    }
+    my $tlsrc = new TeXLive::TLPSRC;
+    $tlsrc->from_file ( $apfile );
+    if ($tlsrc->binpatterns) {
+      for my $p ($tlsrc->binpatterns) {
+        my ($cat, @rest) = split ' ', $p;
+        push @{$autopatterns{$cat}{"bin"}}, join(' ', @rest);
+      }
+    }
+    if ($tlsrc->srcpatterns) {
+      for my $p ($tlsrc->srcpatterns) {
+        my ($cat, @rest) = split ' ', $p;
+        push @{$autopatterns{$cat}{"src"}}, join(' ', @rest);
+      }
+    }
+    if ($tlsrc->docpatterns) {
+      for my $p ($tlsrc->docpatterns) {
+        my ($cat, @rest) = split ' ', $p;
+        push @{$autopatterns{$cat}{"doc"}}, join(' ', @rest);
+      }
+    }
+    if ($tlsrc->runpatterns) {
+      for my $p ($tlsrc->runpatterns) {
+        my ($cat, @rest) = split ' ', $p;
+        push @{$autopatterns{$cat}{"run"}}, join(' ', @rest);
+      }
+    }
+
+    for my $cat (keys %autopatterns) {
+      debug ("Category $cat\n");
+      for my $d (@{$autopatterns{$cat}{"bin"}}) {
+        debug ("Found auto bin pattern $d\n");
+      }
+      for my $d (@{$autopatterns{$cat}{"src"}}) {
+        debug ("Found auto src pattern $d\n");
+      }
+      for my $d (@{$autopatterns{$cat}{"doc"}}) {
+        debug ("Found auto doc pattern $d\n");
+      }
+      for my $d (@{$autopatterns{$cat}{"run"}}) {
+        debug ("Found auto run pattern $d\n");
+      }
+    }
+  } # end of if (! $opt_noautopatterns)
+
   # if we're regenerating the whole thing, get all our tlpsrc files.
   if ($opt_all) {
-    my $tlpsrc_dir = "$opt_master/tlpkg/tlpsrc";
     chdir ($tlpsrc_dir) || die "chdir($tlpsrc_dir) failed: $!";
     @ARGV = glob ("*.tlpsrc");
   }
@@ -82,11 +141,16 @@
   my $tldb = TeXLive::TLPDB->new;
   my $src_count = 0;
   foreach my $f (@ARGV) {
+    next if ($f =~ m/^00texlive\.autopatterns/);
     $src_count++ if $opt_all;
 
     my $tlsrc = new TeXLive::TLPSRC;
     $tlsrc->from_file ($f);
-    my $tlp = $tlsrc->make_tlpobj ($tltree);
+    my $patternref;
+    if (defined($autopatterns{$tlsrc->category})) {
+      $patternref = $autopatterns{$tlsrc->category};
+    }
+    my $tlp = $tlsrc->make_tlpobj ($tltree, $autopatterns{$tlsrc->category});
 
     (my $base_f = $f) =~ s/\.tlpsrc$//;
     warn "$f: package name " . $tlp->name . " does not match filename\n"