summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-10-15 10:45:48 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-10-15 10:45:48 +0000
commit79c5d277257cd0dd954ca3aea4805f704391bea8 (patch)
tree383d07ad5e5ee1fdeb1d3d51fe4c83350ec86efa /usr.sbin/pkg_add/OpenBSD
parent071c67a432b2772d433712002c7698df9ff0087f (diff)
let handle compute pkgnames correctly, simplifies code a bit
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm22
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Handle.pm45
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Replace.pm4
-rw-r--r--usr.sbin/pkg_add/OpenBSD/UpdateSet.pm8
4 files changed, 50 insertions, 29 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index cbc509ce014..e697b06a6ae 100644
--- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Dependencies.pm,v 1.71 2009/10/12 11:57:36 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.72 2009/10/15 10:45:47 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -227,10 +227,10 @@ sub add_todo
for my $set (@extra) {
for my $n ($set->newer) {
- $self->{to_install}->{OpenBSD::PackageName::url2pkgname($n->{pkgname})} = $set;
+ $self->{to_install}->{$n->pkgname} = $set;
}
for my $n ($set->older) {
- $self->{to_update}->{OpenBSD::PackageName::url2pkgname($n->{pkgname})} = $set;
+ $self->{to_update}->{$n->pkgname} = $set;
}
}
}
@@ -350,7 +350,7 @@ sub dump
print "Dependencies for ", $self->{set}->short_print,
" resolve to: ", join(', ', $self->dependencies);
print " (todo: ",
- join(',', (map {$_->handle->{pkgname}} @{$self->{deplist}})),
+ join(',', (map {$_->handle->pkgname} @{$self->{deplist}})),
")"
if @{$self->{deplist}} > 0;
print "\n";
@@ -362,7 +362,7 @@ sub register_dependencies
my ($self, $state) = @_;
require OpenBSD::RequiredBy;
- my $pkgname = $self->{set}->handle->{pkgname};
+ my $pkgname = $self->{set}->handle->pkgname;
my @l = $self->dependencies;
OpenBSD::Requiring->new($pkgname)->add(@l);
@@ -378,7 +378,7 @@ sub record_old_dependencies
my ($self, $state) = @_;
for my $o ($self->{set}->older_to_do) {
require OpenBSD::RequiredBy;
- my @wantlist = OpenBSD::RequiredBy->new($o->{pkgname})->list;
+ my @wantlist = OpenBSD::RequiredBy->new($o->pkgname)->list;
$o->{wantlist} = \@wantlist;
}
}
@@ -386,13 +386,13 @@ sub record_old_dependencies
sub adjust_old_dependencies
{
my ($self, $state) = @_;
- my $pkgname = $self->{set}->handle->{pkgname};
+ my $pkgname = $self->{set}->handle->pkgname;
for my $o ($self->{set}->older) {
next unless defined $o->{wantlist};
require OpenBSD::Replace;
require OpenBSD::RequiredBy;
- my $oldname = $o->{pkgname};
+ my $oldname = $o->pkgname;
print "Adjusting dependencies for $pkgname/$oldname\n"
if $state->{beverbose};
@@ -412,7 +412,7 @@ sub adjust_old_dependencies
sub repair_dependencies
{
my ($self, $state) = @_;
- my $pkgname = $self->{set}->handle->{pkgname};
+ my $pkgname = $self->{set}->handle->pkgname;
for my $pkg (installed_packages(1)) {
my $plist = OpenBSD::PackingList->from_installation($pkg,
\&OpenBSD::PackingList::DependOnly);
@@ -462,7 +462,7 @@ sub solve_wantlibs
next if $lib_finder->lookup($solver, $state,
$lib->{name});
OpenBSD::Error::Warn "Can't install ",
- $h->{pkgname}, ": lib not found ",
+ $h->pkgname, ": lib not found ",
$lib->{name}, "\n";
if ($okay) {
$solver->dump;
@@ -486,7 +486,7 @@ sub solve_tags
for my $tag (keys %{$h->{plist}->{tags}}) {
next if $tag_finder->lookup($solver, $state, $tag);
OpenBSD::Error::Warn "Can't install ",
- $h->{pkgname}, ": tag definition not found ",
+ $h->pkgname, ": tag definition not found ",
$tag, "\n";
if ($okay) {
$solver->dump;
diff --git a/usr.sbin/pkg_add/OpenBSD/Handle.pm b/usr.sbin/pkg_add/OpenBSD/Handle.pm
index 15701fee4bd..d45ae27c10c 100644
--- a/usr.sbin/pkg_add/OpenBSD/Handle.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Handle.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Handle.pm,v 1.1 2009/10/14 22:59:34 espie Exp $
+# $OpenBSD: Handle.pm,v 1.2 2009/10/15 10:45:47 espie Exp $
#
# Copyright (c) 2007-2009 Marc Espie <espie@openbsd.org>
#
@@ -35,6 +35,25 @@ sub new
return bless {}, $class;
}
+sub pkgname
+{
+ my $self = shift;
+ if (!defined $self->{pkgname}) {
+ if (defined $self->{plist}) {
+ $self->{pkgname} = $self->{plist}->pkgname;
+ } elsif (defined $self->{location}) {
+ $self->{pkgname} = $self->{location}->name;
+ } elsif (defined $self->{name}) {
+ require OpenBSD::PackageName;
+
+ $self->{pkgname} =
+ OpenBSD::PackageName::url2pkgname($self->{name});
+ }
+ }
+
+ return $self->{pkgname};
+}
+
sub set_error
{
my ($self, $error) = @_;
@@ -58,7 +77,7 @@ sub create_old
my ($class, $pkgname, $state) = @_;
my $self= $class->new;
- $self->{pkgname} = $pkgname;
+ $self->{name} = $pkgname;
require OpenBSD::PackageRepository::Installed;
@@ -74,6 +93,7 @@ sub create_old
$self->{plist} = $plist;
}
}
+
return $self;
}
@@ -81,7 +101,7 @@ sub create_new
{
my ($class, $pkg) = @_;
my $handle = $class->new;
- $handle->{pkgname} = $pkg;
+ $handle->{name} = $pkg;
$handle->{tweaked} = 0;
return $handle;
}
@@ -90,7 +110,6 @@ sub from_location
{
my ($class, $location) = @_;
my $handle = $class->new;
- $handle->{pkgname} = $location->name;
$handle->{location} = $location;
$handle->{tweaked} = 0;
return $handle;
@@ -101,7 +120,7 @@ sub get_plist
my ($handle, $state) = @_;
my $location = $handle->{location};
- my $pkg = $handle->{pkgname};
+ my $pkg = $handle->pkgname;
if ($state->{verbose}) {
print $state->deptree_header($pkg);
@@ -140,8 +159,7 @@ sub get_plist
return;
}
if ($pkg ne '-') {
- if (!defined $pkgname or
- OpenBSD::PackageName::url2pkgname($pkg) ne $pkgname) {
+ if (!defined $pkgname or $pkg ne $pkgname) {
print "Package name is not consistent ???\n";
$location->close_with_client_error;
$location->wipe_info;
@@ -158,26 +176,29 @@ sub complete
return if $handle->has_error;
- my $pkgname = $handle->{pkgname};
if (!defined $handle->{location}) {
- my $location = OpenBSD::PackageLocator->find($pkgname,
+ my $name = $handle->{name};
+
+ my $location = OpenBSD::PackageLocator->find($name,
$state->{arch});
if (!$location) {
- print $state->deptree_header($pkgname);
+ print $state->deptree_header($name);
$handle->set_error(NOT_FOUND);
$handle->{tweaked} =
- OpenBSD::Add::tweak_package_status($pkgname,
+ OpenBSD::Add::tweak_package_status($handle->pkgname,
$state);
if (!$handle->{tweaked}) {
- print "Can't find $pkgname\n";
+ print "Can't find $name\n";
}
return;
}
$handle->{location} = $location;
+ $handle->{pkgname} = $location->name;
}
if (!defined $handle->{plist}) {
$handle->get_plist($state);
}
}
+
1;
diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm
index 1fd88125925..8b65a2d344e 100644
--- a/usr.sbin/pkg_add/OpenBSD/Replace.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Replace.pm,v 1.50 2009/10/11 11:51:22 espie Exp $
+# $OpenBSD: Replace.pm,v 1.51 2009/10/15 10:45:47 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -432,7 +432,7 @@ sub save_old_libraries
for my $o ($set->older) {
- my $oldname = $o->{pkgname};
+ my $oldname = $o->pkgname;
my $libs = {};
my $p = {};
diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
index 432eebe79ee..ce651f2e8ac 100644
--- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
+++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: UpdateSet.pm,v 1.8 2009/10/14 22:59:34 espie Exp $
+# $OpenBSD: UpdateSet.pm,v 1.9 2009/10/15 10:45:47 espie Exp $
#
# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
#
@@ -131,7 +131,7 @@ sub add_older
{
my $self = shift;
for my $h (@_) {
- $self->{older}->{$h->{pkgname}} = $h;
+ $self->{older}->{$h->pkgname} = $h;
}
return $self;
}
@@ -157,7 +157,7 @@ sub older_names
sub newer_names
{
my $self =shift;
- return map {$_->{pkgname}} $self->newer;
+ return map {$_->pkgname} $self->newer;
}
sub older_to_do
@@ -169,7 +169,7 @@ sub older_to_do
require OpenBSD::PackageInfo;
my @l = ();
for my $h ($self->older) {
- if (OpenBSD::PackageInfo::is_installed($h->{pkgname})) {
+ if (OpenBSD::PackageInfo::is_installed($h->pkgname)) {
push(@l, $h);
}
}