summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-14 19:35:56 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-14 19:35:56 +0000
commitcc3600e4c630070aa7df32116f9327caa3c2513c (patch)
tree58b5d181ed70d822bcbaff02191f6d9d367d3a18 /usr.sbin/pkg_add/OpenBSD
parent8b3a22705b77505490f2a3fef0fc9de84536e8f6 (diff)
fix new vstat, and make it useful, for instance for -n.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm8
-rw-r--r--usr.sbin/pkg_add/OpenBSD/CollisionReport.pm19
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Vstat.pm20
3 files changed, 29 insertions, 18 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 283855b8edd..9b6adcc709b 100644
--- a/usr.sbin/pkg_add/OpenBSD/Add.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Add.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.103 2010/01/03 19:55:35 espie Exp $
+# $OpenBSD: Add.pm,v 1.104 2010/01/14 19:35:55 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -369,7 +369,7 @@ sub prepare_for_addition
$state->{problems}++;
return;
}
- my $s = $state->vstat->add($fname, $self->{size}, \$pkgname);
+ my $s = $state->vstat->add($fname, $self->{size}, $pkgname);
return unless defined $s;
if ($s->ro) {
$s->report_ro($state, $fname);
@@ -490,7 +490,7 @@ sub prepare_for_addition
return;
}
my $size = $self->{copyfrom}->{size};
- my $s = $state->vstat->add($fname, $size, \$pkgname);
+ my $s = $state->vstat->add($fname, $size, $pkgname);
return unless defined $s;
if ($s->ro) {
$s->report_ro($state, $fname);
@@ -674,7 +674,7 @@ sub prepare_for_addition
$s2->report_noexec($state, $cname);
}
}
- my $s = $state->vstat->add($fname, $self->{size}, \$pkgname);
+ my $s = $state->vstat->add($fname, $self->{size}, $pkgname);
return unless defined $s;
if ($s->ro) {
$s->report_ro($state, $fname);
diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
index aec557ee572..6b5a96ddd40 100644
--- a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
+++ b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: CollisionReport.pm,v 1.30 2010/01/08 16:42:56 espie Exp $
+# $OpenBSD: CollisionReport.pm,v 1.31 2010/01/14 19:35:55 espie Exp $
#
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
#
@@ -28,9 +28,8 @@ sub find_collisions
my $verbose = $state->verbose >= 3;
my $bypkg = {};
for my $name (keys %$todo) {
- my $p = $state->vstat->exists($name);
- if (defined $p && $p->value) {
- my $pkg = $p->value;
+ my $pkg = $state->vstat->value($state->{destdir}.$name);
+ if (defined $pkg) {
push(@{$bypkg->{$pkg}}, $name);
delete $todo->{$name};
}
@@ -94,16 +93,18 @@ sub collision_report($$)
if (%todo) {
for my $item (sort keys %todo) {
- if (defined $todo{$item}) {
- my $old = $todo{$item};
+ my $old = $todo{$item};
+ $state->errprint("\t$item");
+ if (defined $old && -f $destdir.$item) {
my $d = $old->new($destdir.$item);
+
if ($d->equals($old)) {
- $state->errsay("\t$item (same checksum)");
+ $state->errsay("(same checksum)");
} else {
- $state->errsay("\t$item (different checksum)");
+ $state->errsay("(different checksum)");
}
} else {
- $state->errsay("\t$item");
+ $state->errsay("");
}
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
index e4f48e92858..ad58d5c693f 100644
--- a/usr.sbin/pkg_add/OpenBSD/Vstat.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Vstat.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Vstat.pm,v 1.55 2010/01/08 16:42:56 espie Exp $
+# $OpenBSD: Vstat.pm,v 1.56 2010/01/14 19:35:55 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -32,14 +32,14 @@ my $dummy = bless \$x, __PACKAGE__;
sub new
{
- my ($class, $value) = shift;
+ my ($class, $value) = @_;
if (!defined $value) {
return $dummy;
}
if (!defined $cache->{$value}) {
- $cache->{value} = bless \$value, $class;
+ $cache->{$value} = bless \$value, $class;
}
- return $cache->{value};
+ return $cache->{$value};
}
sub exists
@@ -126,6 +126,17 @@ sub exists
return -e $name;
}
+sub value
+{
+ my ($self, $name) = @_;
+ for my $v (@{$self->{v}}) {
+ if (defined $v->{$name}) {
+ return $v->{$name}->value;
+ }
+ }
+ return undef;
+}
+
sub synchronize
{
my $self = shift;
@@ -159,7 +170,6 @@ sub add
{
my ($self, $name, $size, $value) = @_;
$self->{v}[0]->{$name} = OpenBSD::Vstat::Object->new($value);
-
return defined($size) ? $self->account_for($name, $size) : undef;
}