diff options
author | Bernd Ahlers <bernd@cvs.openbsd.org> | 2007-01-23 11:40:27 +0000 |
---|---|---|
committer | Bernd Ahlers <bernd@cvs.openbsd.org> | 2007-01-23 11:40:27 +0000 |
commit | b60756a18aa0f3f9e02f3e62886d40874fb4f9e7 (patch) | |
tree | b71b7b090c102c130bfa9fc6f87d59c2d2a3c4e6 /usr.sbin | |
parent | 16f332afc9a17f7ea1927e6b546b50b7c172e676 (diff) |
Introduce -Q option:
-Q query
Show all packages in $PKG_PATH which match the given query.
Example:
$ pkg_info -Q bogofilter
bogofilter-1.0.3-qdbm (installed)
bogofilter-1.0.3-db4
bogofilter-1.0.3-sqlite3
bogofilter-1.0.3
$
Manpage help from sturm@. ok sturm@, steven@, espie@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_info | 31 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_info.1 | 8 |
2 files changed, 33 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info index 926b66c6be5..4ddf7f40ba0 100644 --- a/usr.sbin/pkg_add/pkg_info +++ b/usr.sbin/pkg_add/pkg_info @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_info,v 1.39 2006/02/23 12:28:22 bernd Exp $ +# $OpenBSD: pkg_info,v 1.40 2007/01/23 11:40:26 bernd Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -206,8 +206,8 @@ sub find_by_path } our ($opt_c, $opt_D, $opt_d, $opt_f, $opt_I, $opt_i, $opt_k, $opt_K, $opt_L, - $opt_m, $opt_p, $opt_q, $opt_R, $opt_r, $opt_s, $opt_v, $opt_h, $opt_l, - $opt_a, $opt_M, $opt_U, $opt_A, $opt_S, $opt_P); + $opt_m, $opt_p, $opt_Q, $opt_q, $opt_R, $opt_r, $opt_s, $opt_v, $opt_h, + $opt_l, $opt_a, $opt_M, $opt_U, $opt_A, $opt_S, $opt_P); my $terse = 0; my $exit_code = 0; my $error_e = 0; @@ -316,11 +316,11 @@ sub print_info } } -set_usage('pkg_info [-cDdfIiKkLMPpqRrSsUv] [-E filename] [-e pkg-name] [-l str] pkg-name [...]', 'pkg_info [-Aa flags]'); +set_usage('pkg_info [-cDdfIiKkLMPpqRrSsUv] [-E filename] [-e pkg-name] [-l str] pkg-name [...]', 'pkg_info [-Aa flags]', 'pkg_info [-v] [-Q query]'); my $locked; try { - getopts('cDdfhIikKLmpPqRrsSUve:E:Ml:aA', + getopts('cDdfhIikKLmpPQ:qRrsSUve:E:Ml:aA', {'e' => sub { my $pat = shift; @@ -368,6 +368,27 @@ unless ($opt_c || $opt_M || $opt_U || $opt_d || $opt_f || $opt_I || $opt_i || } } +if ($opt_Q) { + require OpenBSD::PackageLocator; + + my $stemlist = OpenBSD::PackageName::available_stems(); + print "PKG_PATH=$ENV{PKG_PATH}\n" if $opt_v; + + for my $stem (sort keys %$stemlist) { + if ($stem =~ /\Q$opt_Q\E/i) { + for my $p (keys %{$stemlist->{$stem}}) { + my $text = "$p"; + if (is_installed($p)) { + $text .= " (installed)"; + } + print $text."\n"; + } + } + } + + exit 0; +} + if ($opt_v) { $opt_c = $opt_d = $opt_f = $opt_i = $opt_k = $opt_r = $opt_M = $opt_U = $opt_m = $opt_R = $opt_s = $opt_S = 1; diff --git a/usr.sbin/pkg_add/pkg_info.1 b/usr.sbin/pkg_add/pkg_info.1 index caf0fc77c7e..e7f19e531c9 100644 --- a/usr.sbin/pkg_add/pkg_info.1 +++ b/usr.sbin/pkg_add/pkg_info.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pkg_info.1,v 1.21 2006/01/30 17:27:29 miod Exp $ +.\" $OpenBSD: pkg_info.1,v 1.22 2007/01/23 11:40:26 bernd Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -34,6 +34,9 @@ .Ek .Nm pkg_info .Op Fl Aa Ar flags +.Nm pkg_info +.Op Fl v +.Op Fl Q Ar query .Sh DESCRIPTION The .Nm @@ -144,6 +147,9 @@ Show the pkgpath for each package. You can easily build a subdirlist with this. .It Fl p Show the installation prefix for each package. +.It Fl Q Ar query +Show all packages in $PKG_PATH which match the given +.Ar query . .It Fl q Be .Dq quiet |