diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-08 16:42:57 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-08 16:42:57 +0000 |
commit | fafeb6e6bc1e1174c1da901a8295669be0ad8088 (patch) | |
tree | 61e054ec3c1d695341b94b6117a2e84b223fb39c /usr.sbin/pkg_add | |
parent | eb0398ca63772a6ca571c5ef6c0f08dcee53a686 (diff) |
stat objects with more than value (store symlinks eventually)
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/CollisionReport.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 66 | ||||
-rw-r--r-- | usr.sbin/pkg_add/TODO | 1 |
3 files changed, 62 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm b/usr.sbin/pkg_add/OpenBSD/CollisionReport.pm index 00df272e7e4..aec557ee572 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.29 2009/12/20 22:38:45 espie Exp $ +# $OpenBSD: CollisionReport.pm,v 1.30 2010/01/08 16:42:56 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -29,8 +29,8 @@ sub find_collisions my $bypkg = {}; for my $name (keys %$todo) { my $p = $state->vstat->exists($name); - if (ref $p) { - my $pkg = $$p; + if (defined $p && $p->value) { + my $pkg = $p->value; push(@{$bypkg->{$pkg}}, $name); delete $todo->{$name}; } diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index ab67914b81f..e4f48e92858 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.54 2010/01/05 11:00:57 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.55 2010/01/08 16:42:56 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -24,6 +24,59 @@ use strict; use warnings; +{ +package OpenBSD::Vstat::Object; +my $cache = {}; +my $x = undef; +my $dummy = bless \$x, __PACKAGE__; + +sub new +{ + my ($class, $value) = shift; + if (!defined $value) { + return $dummy; + } + if (!defined $cache->{$value}) { + $cache->{value} = bless \$value, $class; + } + return $cache->{value}; +} + +sub exists +{ + return 1; +} + +sub value +{ + my $self = shift; + return $$self; +} + +sub none +{ + return OpenBSD::Vstat::Object::None->new; +} + +} +{ +package OpenBSD::Vstat::Object::None; +our @ISA = qw(OpenBSD::Vstat::Object); + +my $x = undef; +my $none = bless \$x, __PACKAGE__; + +sub exists +{ + return 0; +} + +sub new +{ + return $none; +} +} + package OpenBSD::Vstat; use File::Basename; use OpenBSD::Paths; @@ -67,7 +120,7 @@ sub exists my ($self, $name) = @_; for my $v (@{$self->{v}}) { if (defined $v->{$name}) { - return $v->{$name}; + return $v->{$name}->exists; } } return -e $name; @@ -105,18 +158,15 @@ sub drop_changes sub add { my ($self, $name, $size, $value) = @_; - if (defined $value) { - $self->{v}[0]->{$name} = $value; - } else { - $self->{v}[0]->{$name} = 1; - } + $self->{v}[0]->{$name} = OpenBSD::Vstat::Object->new($value); + return defined($size) ? $self->account_for($name, $size) : undef; } sub remove { my ($self, $name, $size) = @_; - $self->{v}[0]->{$name} = 0; + $self->{v}[0]->{$name} = OpenBSD::Vstat::Object->none; return defined($size) ? $self->account_later($name, -$size) : undef; } diff --git a/usr.sbin/pkg_add/TODO b/usr.sbin/pkg_add/TODO index 7ef47a0f0d0..00a58fe247c 100644 --- a/usr.sbin/pkg_add/TODO +++ b/usr.sbin/pkg_add/TODO @@ -17,3 +17,4 @@ different but older. cases, we're going to install this package right away, so we should try to keep it open to avoid spurious ftp disconnects. - get an update path for libraries to be able to adjust dependencies correctly. +- provide a "smart" is it installed ? option. pkg_info -u package ? |