summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TeXCatalogue.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-10-03 19:59:53 +0000
committerKarl Berry <karl@freefriends.org>2009-10-03 19:59:53 +0000
commit56884b405c002dd61e7814cd0c79850af381883d (patch)
tree98770aead2651a1ac76d7c13156db0f3c483f46f /Master/tlpkg/TeXLive/TeXCatalogue.pm
parent685fa68b603d8e4f7f84371b8ec419240354946c (diff)
(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
Diffstat (limited to 'Master/tlpkg/TeXLive/TeXCatalogue.pm')
-rw-r--r--Master/tlpkg/TeXLive/TeXCatalogue.pm31
1 files changed, 31 insertions, 0 deletions
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 = @_;