summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2010-10-19 17:58:46 +0000
committerNorbert Preining <preining@logic.at>2010-10-19 17:58:46 +0000
commit9884b82724a9a0425a4a0361304567f4b2b83f74 (patch)
treeb3de3f4408c511695c42b019ef8e090d376b4b1a /Master/texmf
parent099a7eb7059c2d88a5e672854ee06aa72ddde77c (diff)
first start on supporting tlmgr search --taxonomy
git-svn-id: svn://tug.org/texlive/trunk@20142 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl97
1 files changed, 84 insertions, 13 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index 7a8411dced5..9c3cf4a4583 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -165,7 +165,8 @@ sub main {
"force" => 1 },
"search" => { "global" => 1,
"word" => 1,
- "file" => 1 },
+ "file" => 1,
+ "taxonomy" => 1 },
"show" => { "list" => 1 },
"uninstall" => { "force" => 1 },
"update" => { "no-depends" => 1,
@@ -1124,15 +1125,42 @@ sub action_path {
# SEARCH
#
+sub load_taxonomy_datafile {
+ init_local_db();
+ my $taxonomy;
+ my $fpath = $localtlpdb->root . "/texmf/scripts/texlive/tc-dump";
+ if (! -r $fpath) {
+ tlwarn("tlmgr: taxonomy file $fpath not readable.\n");
+ return;
+ }
+ my $foo = `cat $fpath`;
+ no strict "vars";
+ # the no strict "vars" is *ABSOLUT* necessary otherwise the file is not
+ # evaluated, no idea why!
+ eval "$foo";
+ use strict "vars";
+ return $taxonomy;
+}
+
sub action_search {
my $r = shift @ARGV;
my $ret = "";
my $tlpdb;
+ my $taxonomy;
#
if (!defined($r) || !$r) {
tlwarn("tlmgr: nothing to search for.\n");
return;
}
+ if ($opts{"extended"}) {
+ tlwarn("tlmgr: sorry, extended searching not implemented by now.\n");
+ return;
+ }
+ # check the arguments
+ if (exists($opts{"file"}) && exists($opts{"taxonomy"})) {
+ tlwarn("tlmgr: please specify only one thing to search for!\n");
+ return;
+ }
init_local_db();
if ($opts{"global"}) {
init_tlmedia();
@@ -1140,6 +1168,13 @@ sub action_search {
} else {
$tlpdb = $localtlpdb;
}
+ if ($opts{"taxonomy"}) {
+ $taxonomy = load_taxonomy_datafile();
+ if (!defined($taxonomy)) {
+ tlwarn("tlmgr: Cannot load taxonomy file, searching for taxonomies not supported.\n");
+ return;
+ }
+ }
foreach my $pkg ($tlpdb->list_packages) {
my $tlp = $tlpdb->get_package($pkg);
if ($opts{"file"}) {
@@ -1156,16 +1191,32 @@ sub action_search {
}
} else {
next if ($pkg =~ m/\./);
- my $t = $tlpdb->get_package($pkg)->shortdesc;
- $t |= "";
- my $lt = $tlpdb->get_package($pkg)->longdesc;
- $lt |= "";
+ # the other searching is done together
+ my $t = "";
+ if ($opts{"taxonomy"}) {
+ $t = "$t" . join('\n', @{$taxonomy->{'by-package'}{'keyword'}{$pkg}})
+ if (defined($taxonomy->{'by-package'}{'keyword'}{$pkg}));
+ $t = "$t$taxonomy->{'by-package'}{'primary'}{$pkg}\n"
+ if (defined($taxonomy->{'by-package'}{'primary'}{$pkg}));
+ $t = "$t$taxonomy->{'by-package'}{'secondary'}{$pkg}\n"
+ if (defined($taxonomy->{'by-package'}{'secondary'}{$pkg}));
+ $t = "$t" . join('\n', @{$taxonomy->{'by-package'}{'function'}{$pkg}})
+ if (defined($taxonomy->{'by-package'}{'function'}{$pkg}));
+ } else {
+ $t = "$pkg\n";
+ $t = "$t" . $tlp->shortdesc . "\n"
+ if (defined($tlp->shortdesc));
+ $t = "$t" . $tlp->longdesc . "\n"
+ if (defined($tlp->longdesc));
+ }
+ my $shortdesc = $tlp->shortdesc;
+ $shortdesc |= "";
my $pat = $r;
if ($opts{"word"}) {
$pat = '\W' . $r . '\W';
}
- if (($pkg =~ m/$pat/) || ($t =~ m/$pat/) || ($lt =~ m/$pat/)) {
- $ret .= " $pkg - $t\n";
+ if ($t =~ m/$pat/) {
+ $ret .= " $pkg - " . $shortdesc . "\n";
}
}
}
@@ -5371,17 +5422,19 @@ Print the TeX Live identifier for the detected platform
C<--print-arch> is a synonym.
-=head2 search [I<option>]... I<what>
+=head2 search [I<options>] I<what>
+
+=head2 search [I<options>] --file I<what>
+
+=head2 search [I<options>] --taxonomy I<what>
By default searches the names, short and long descriptions of all
locally installed packages for the given argument (interpreted as
-regexp). Options:
-
-=over 4
+regexp).
-=item B<--file>
+Options:
-List all filenames containing I<what>.
+=over 4
=item B<--global>
@@ -5396,6 +5449,24 @@ the the word C<tables> unless they also contain the word C<table>.
=back
+Other search options are selected by adding either B<--file> or B<--taxonomy>.
+
+=over 4
+
+=item B<--file>
+
+List all filenames containing I<what>.
+
+=item B<--taxonomy>
+
+Searches in the list of keywords, and its characterization and functional
+specifications (MORE DETAILS NEEDED) instead of the package descriptions.
+
+=item B<--extended>
+
+Not implemented yet.
+
+=back
=head2 show [--list] I<pkg>...