diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-25 13:18:58 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-25 13:18:58 +0000 |
commit | e8006e4acb50c05164729e3a07e489752b478add (patch) | |
tree | 65ea4131ade77ba545d62ba04b3a7183ddc63979 /usr.sbin/pkg_add/OpenBSD | |
parent | 0e8feb75e7a7dec6f1126e1ef06a0931e179fd77 (diff) |
start cleaning up the mess that is error-handling when installing packages.
Mid-Term, we want to manipulate true `handles' that encapsulate package
locations.
For now, we create this handle externally, and just use it to record
errors, in duplicate...
Once handles are ready, they should be agregated into UpdateSets, to make
replacement of packages more explicit and flexible.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index 682b33ff93e..e50380a7364 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.20 2007/05/22 10:11:59 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.21 2007/05/25 13:18:57 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -230,4 +230,57 @@ sub cleanup OpenBSD::SharedItems::cleanup($self, $state); } +# fairly non-descriptive name. Used to store various package information +# during installs and updates. +package OpenBSD::Handle; + +use constant { + NOT_FOUND => 0, + BAD_PACKAGE => 1, + CANT_INSTALL => 2 +}; + +sub new +{ + my $class = shift; + return bless {}, $class; +} + +sub set_error +{ + my ($self, $error) = @_; + $self->{error} = $error; +} + +sub has_error +{ + my ($self, $error) = @_; + if (!defined $self->{error}) { + return 0; + } + if (defined $error) { + return $self->{error} eq $error; + } + return 1; +} + +package OpenBSD::UpdateSet; +sub new +{ + my $class = shift; + return bless {}, $class; +} + +sub add_newer +{ + my ($self, @handles) = @_; + push(@{$self->{newer}}, @handles); +} + +sub add_older +{ + my ($self, @handles) = @_; + push(@{$self->{older}}, @handles); +} + 1; |