summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2004-11-10 09:55:43 +0000
committerespie <espie@openbsd.org>2004-11-10 09:55:43 +0000
commit737fdd9b7e728a842c8418a9eaf0429e0ce7ff0a (patch)
tree293411acab8dab72890c79e97fd1f3f37078acf6
parentresurrect -e, document that it uses packages-specs now. (diff)
downloadwireguard-openbsd-737fdd9b7e728a842c8418a9eaf0429e0ce7ff0a.tar.xz
wireguard-openbsd-737fdd9b7e728a842c8418a9eaf0429e0ce7ff0a.zip
use ExtraInfo, finally: allows pkg_info to report packages according to
PKGPATH, e.g., pkg_info -e x11/kde/base3 will tell you which version (if any) of kdebase is installed. Necessary for achieving updates.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm16
-rw-r--r--usr.sbin/pkg_add/pkg_info46
-rw-r--r--usr.sbin/pkg_add/pkg_info.113
3 files changed, 68 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index 9532dbd0de7..53e62485447 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingList.pm,v 1.31 2004/11/09 10:30:26 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.32 2004/11/10 09:55:43 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -118,6 +118,20 @@ sub DependOnly
}
}
+sub ExtraInfoOnly
+{
+ my ($fh, $cont) = @_;
+ local $_;
+ while (<$fh>) {
+ # XXX optimization
+ if (m/^\@arch\b/) {
+ return;
+ }
+ next unless m/^\@(?:name\b|comment\s+subdir\=)/;
+ &$cont($_);
+ }
+}
+
sub ConflictOnly
{
my ($fh, $cont) = @_;
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info
index 2e4345c9963..821855ed1ad 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.13 2004/11/10 09:41:16 espie Exp $
+# $OpenBSD: pkg_info,v 1.14 2004/11/10 09:55:43 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -46,6 +46,40 @@ sub get_line
return $c;
}
+sub find_by_spec
+{
+ my $pat = shift;
+
+ require OpenBSD::PkgSpec;
+
+ return sort(OpenBSD::PkgSpec::match($pat, installed_packages()));
+}
+
+my $all_plists;
+
+sub find_by_path
+{
+ my $pat = shift;
+
+ if (!defined $all_plists) {
+ require OpenBSD::PackingOld;
+ require OpenBSD::PackingList;
+
+ $all_plists = [];
+ for my $pkg (installed_packages()) {
+ push(@$all_plists,
+ OpenBSD::PackingList->fromfile(installed_info($pkg).CONTENTS, \&OpenBSD::PackingList::ExtraInfoOnly));
+ }
+ }
+ my @result = ();
+ for my $plist (@$all_plists) {
+ if ($plist->{extrainfo}->{subdir} eq $pat) {
+ push(@result, $plist->pkgname());
+ }
+ }
+ return @result;
+}
+
our ($opt_c, $opt_D, $opt_d, $opt_f, $opt_I, $opt_i, $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);
@@ -154,10 +188,12 @@ getopts('cDdfIikLmpqRrsvhe:MU:l:a',
{'e' =>
sub {
my $pat = shift;
- require OpenBSD::PkgSpec;
-
- my @list = sort(OpenBSD::PkgSpec::match($pat,
- installed_packages()));
+ my @list;
+ if ($pat =~ m/\//) {
+ @list = find_by_path($pat);
+ } else {
+ @list = find_by_spec($pat);
+ }
if (@list == 0) {
$exit_code = 1;
}
diff --git a/usr.sbin/pkg_add/pkg_info.1 b/usr.sbin/pkg_add/pkg_info.1
index 2ba39bb43a7..84627954baf 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.6 2004/11/10 09:41:16 espie Exp $
+.\" $OpenBSD: pkg_info.1,v 1.7 2004/11/10 09:55:43 espie Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -81,6 +81,17 @@ For example,
will match versions 1.3 and later of the
.Pa name
package.
+.It Fl e Ar pkg-path
+Another variant of this option that uses a package path instead.
+A package path is a location within the ports tree, as described
+in
+.Ev FULLPKGPATH
+in
+.Xr bsd.port.mk 5 .
+For example,
+.Ic pkg_info -e x11/kde/base3
+will match any package that was compiled according to
+.Pa ${PORTSDIR}/x11/kde/base3 .
.It Fl f
Show the packing list instructions for each package.
.It Fl I