summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-11-09 17:50:25 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-11-09 17:50:25 +0000
commit49e2be41ccf25aba23a3e4a103c2ccf3a0b510f8 (patch)
treeebcc5a93d57208b417949238ccf0062784c3d674 /usr.sbin/pkg_add
parent64d8991878c299e48cc774a7bf3f856b614af8f0 (diff)
okay, so updates become "true" updates: unless you say -F downgrade
then packages with an older version will be filtered out.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Search.pm22
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm5
2 files changed, 25 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Search.pm b/usr.sbin/pkg_add/OpenBSD/Search.pm
index d7a9cff1599..a1b6823aa31 100644
--- a/usr.sbin/pkg_add/OpenBSD/Search.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Search.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Search.pm,v 1.11 2009/10/11 18:04:41 espie Exp $
+# $OpenBSD: Search.pm,v 1.12 2009/11/09 17:50:24 espie Exp $
#
# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
#
@@ -189,6 +189,26 @@ sub filter_locations
return &{$self->{code}}($l);
}
+sub more_recent_than
+{
+ my ($class, $name) = @_;
+ require OpenBSD::PackageName;
+
+ my $f = OpenBSD::PackageName->from_string($name);
+
+ return $class->new(
+sub {
+ my $l = shift;
+ my $r = [];
+ for my $e (@$l) {
+ if ($f->{version}->compare($e->pkgname->{version}) < 0) {
+ push(@$r, $e);
+ }
+ }
+ return $r;
+ });
+}
+
sub keep_most_recent
{
my $class = shift;
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index e175e103f8e..6ddd417203b 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.89 2009/11/08 10:46:11 espie Exp $
+# $OpenBSD: Update.pm,v 1.90 2009/11/09 17:50:24 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -59,6 +59,9 @@ sub process_handle
my $found;
my $plist;
+ if (!$state->{defines}->{downgrade}) {
+ push(@search, OpenBSD::Search::FilterLocation->more_recent_than($pkgname));
+ }
push(@search, OpenBSD::Search::FilterLocation->new(
sub {
my $l = shift;