summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-10-04 09:39:01 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-10-04 09:39:01 +0000
commitc56128759d653dbccb268315e12a54b806e7e9d3 (patch)
treee48cee5101538735f6db63cbfc3469be59f797e2 /usr.sbin/pkg_add
parentec0109e3524dc5ee6e85f5be0f21d13c342b6f52 (diff)
tighter specs (tested for ages locally)
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgSpec.pm35
1 files changed, 11 insertions, 24 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm
index ea1b19b8184..c136064cb8a 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PkgSpec.pm,v 1.16 2007/06/09 11:16:54 espie Exp $
+# $OpenBSD: PkgSpec.pm,v 1.17 2008/10/04 09:39:00 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -18,6 +18,7 @@
use strict;
use warnings;
package OpenBSD::PkgSpec;
+use OpenBSD::PackageName;
# all the shit that does handle package specifications
sub compare_pseudo_numbers
@@ -151,41 +152,27 @@ sub subpattern_match
my ($p, $list) = @_;
local $_;
- my ($stemspec, $vspec, $flavorspec);
-
-
- # then, guess at where the version number is if any,
-
- # this finds patterns like -<=2.3,>=3.4.p1-
- # the only constraint is that the actual number
- # - must start with a digit,
- # - not contain - or ,
- if ($p =~ m/^(.*?)\-((?:\>|\>\=|\<|\<\=)?\d[^-]*)(.*)$/o) {
- ($stemspec, $vspec, $flavorspec) = ($1, $2, $3);
- # `any version' matcher
- } elsif ($p =~ m/^(.*?)\-\*(.*)$/o) {
- ($stemspec, $vspec, $flavorspec) = ($1, '*', $2);
- # okay, so no version marker. Assume no flavor spec.
- } else {
- ($stemspec, $vspec, $flavorspec) = ($p, '', '');
+ # let's try really hard to find the stem and the flavors
+ unless ($p =~ m/^(.*?)\-((?:(?:\>|\>\=|\<|\<\=|\=)?\d|\*)[^-]*)(.*)$/) {
+ die "Invalid spec $p";
}
+ my ($stemspec, $vspec, $flavorspec) = ($1, $2, $3);
+
$stemspec =~ s/\./\\\./go;
$stemspec =~ s/\+/\\\+/go;
$stemspec =~ s/\*/\.\*/go;
$stemspec =~ s/\?/\./go;
$stemspec =~ s/^(\\\.libs)\-/$1\\d*\-/go;
+
+ # First trim down the list
+ my @l = grep {/^$stemspec-.*$/} @$list;
+
$vspec =~ s/\./\\\./go;
$vspec =~ s/\+/\\\+/go;
$vspec =~ s/\*/\.\*/go;
$vspec =~ s/\?/\./go;
- $p = $stemspec;
- $p.="-.*" if $vspec ne '';
-
- # First trim down the list
- my @l = grep {/^$p$/} @$list;
-
my @result = ();
# Now, have to extract the version number, and the flavor...
for (@l) {