summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pkg_info
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-10 11:59:58 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-10 11:59:58 +0000
commitdaa19e6179ba3a585b7996362fb461ec5c47814a (patch)
tree652dd14435b5c56fbcbe4db1a5f0c4a5ccaaf570 /usr.sbin/pkg_add/pkg_info
parent049bbdb33618503eb5e9143ecd873badd9ab292a (diff)
trick: I can actually recognize specs easily, so why not allow them without
-e ?
Diffstat (limited to 'usr.sbin/pkg_add/pkg_info')
-rw-r--r--usr.sbin/pkg_add/pkg_info37
1 files changed, 29 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info
index 4ad5ef146bd..55f24f9d990 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.90 2010/01/09 15:10:17 espie Exp $
+# $OpenBSD: pkg_info,v 1.91 2010/01/10 11:59:57 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -83,14 +83,35 @@ sub find_pkg_in
return 1;
}
}
- my $pkg = $repo->find($pkgname);
- if (defined $pkg) {
- &$code($pkgname, $pkg);
- $pkg->close_now;
- $pkg->wipe_info;
- return 1;
+ # okay, so we're actually a spec in disguise
+ if ($pkgname =~ m/[\*\<\>\=]/) {
+ require OpenBSD::Search;
+ my $s = OpenBSD::Search::PkgSpec->new($pkgname);
+ if (!$s->is_valid) {
+ print STDERR "Invalid spec: $pkgname\n";
+ return 0;
+ }
+ my $r = $repo->match_locations($s);
+ if (@$r == 0) {
+ return 0;
+ } else {
+ for my $pkg (@$r) {
+ &$code($pkgname, $pkg);
+ $pkg->close_now;
+ $pkg->wipe_info;
+ }
+ return 1;
+ }
+ } else {
+ my $pkg = $repo->find($pkgname);
+ if (defined $pkg) {
+ &$code($pkgname, $pkg);
+ $pkg->close_now;
+ $pkg->wipe_info;
+ return 1;
+ }
+ return 0;
}
- return 0;
}
sub find_pkg