From 73643db0802a9d08263d2a70b7069ecf5a70024c Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 29 Oct 2008 00:24:42 +0000 Subject: factor out auto patterns to a separate tlpsrc file git-svn-id: svn://tug.org/texlive/trunk@11100 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLPSRC.pm | 187 +++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 111 deletions(-) (limited to 'Master/tlpkg/TeXLive/TLPSRC.pm') diff --git a/Master/tlpkg/TeXLive/TLPSRC.pm b/Master/tlpkg/TeXLive/TLPSRC.pm index 521c75124e1..0a0eb0faeb4 100644 --- a/Master/tlpkg/TeXLive/TLPSRC.pm +++ b/Master/tlpkg/TeXLive/TLPSRC.pm @@ -201,7 +201,11 @@ sub writeout # 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 @@ sub make_tlpobj $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 catalogue { 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 depends { 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 @@ package. If a given pattern section is empty or B the provided patterns have the prefix C<+> (e.g., C<+f ...>), then the following patterns, listed -by type are I added at expansion time: +by type are I added at expansion time. Note that this list +is not definitive, but is taken from the patterns of tlpsrc files +named C<00texlive.autopatterns.>IC<.tlpsrc>. =over 4 -- cgit v1.2.3