From 56884b405c002dd61e7814cd0c79850af381883d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 3 Oct 2009 19:59:53 +0000 Subject: (quest4texlive): new fn to get Catalogue id mappings; from Alexander Cherepanov, 03 Oct 2009 22:56:09. git-svn-id: svn://tug.org/texlive/trunk@15623 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TeXCatalogue.pm | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Master') diff --git a/Master/tlpkg/TeXLive/TeXCatalogue.pm b/Master/tlpkg/TeXLive/TeXCatalogue.pm index 3ac22876c93..10ca161ff83 100644 --- a/Master/tlpkg/TeXLive/TeXCatalogue.pm +++ b/Master/tlpkg/TeXLive/TeXCatalogue.pm @@ -169,6 +169,7 @@ sub new { bless $self, $class; if (defined($self->{'location'})) { $self->initialize(); + $self->quest4texlive(); } return $self; } @@ -191,11 +192,41 @@ sub initialize { chdir($cwd) || die ("Cannot change back to $cwd: $!"); } +# Copy every catalogue $entry under the name $entry->{'texlive'} +# if it makes sense. +# +sub quest4texlive +{ + my $self = shift; + + # The catalogue has a partial mapping from catalogue entries to + # texlive packages: $id --> $texcat->{$id}{'texlive'} + my $texcat = $self->{'entries'}; + + # Try to build the inverse mapping: + my (%inv, %count); + for my $id (keys %{$texcat}) { + if (defined($texcat->{$id}{'texlive'})) { + $count{$texcat->{$id}{'texlive'}}++; + $inv{$texcat->{$id}{'texlive'}} = $id; + } + } + # Go through texlive names + for my $name (keys %inv) { + # If this name is free and there is only one corresponding catalogue + # entry then copy the entry under this name + if (!exists($texcat->{$name}) && $count{$name} == 1) { + $texcat->{$name} = $texcat->{$inv{$name}}; + } + } +} + sub location { my $self = shift; if (@_) { $self->{'location'} = shift } return $self->{'location'}; } + sub entries { my $self = shift; my %newentries = @_; -- cgit v1.2.3