summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-06-10 17:13:49 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-06-10 17:13:49 +0000
commit551d762abd6aacc099e0eabbb9fafa04380d61be (patch)
treed338d1fc5c8a2e11e3ce44cb99f7a963d900699b /usr.sbin
parent9416a78cc2c5656bfa7aff6fea6c9aed8dfd9628 (diff)
give repository/locations slightly more control over package names.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageLocation.pm15
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm19
2 files changed, 26 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm
index 91f44122cb7..1fc05ceab6e 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageLocation.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageLocation.pm,v 1.14 2007/06/10 15:24:36 espie Exp $
+# $OpenBSD: PackageLocation.pm,v 1.15 2007/06/10 17:13:48 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -27,10 +27,7 @@ sub new
{
my ($class, $repository, $name, $arch) = @_;
- if (defined $name) {
- $name =~ s/\.tgz$//o;
- }
- my $self = { repository => $repository, name => $name, arch => $arch};
+ my $self = { repository => $repository, name => $repository->canonicalize($name), arch => $arch};
bless $self, $class;
# print STDERR "Built location ", $self->url, "\n";
return $self;
@@ -48,7 +45,13 @@ sub url
{
my $self = shift;
- return $self->{repository}->url($self->{name});
+ return $self->{repository}->url($self->name);
+}
+
+sub name
+{
+ my $self = shift;
+ return $self->{name};
}
sub openArchive
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm
index b3515e4fbae..57463fd14d3 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Installed.pm,v 1.11 2007/05/30 11:04:31 espie Exp $
+# $OpenBSD: Installed.pm,v 1.12 2007/06/10 17:13:48 espie Exp $
#
# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
#
@@ -78,6 +78,16 @@ sub close_with_client_error
$self->close($object, 1);
}
+sub canonicalize
+{
+ my ($self, $name) = @_;
+
+ if (defined $name) {
+ $name =~ s/\.tgz$//o;
+ }
+ return $name;
+}
+
package OpenBSD::PackageRepository::Installed;
our @ISA = (qw(OpenBSD::PackageRepositoryBase));
@@ -108,6 +118,11 @@ sub close
{
}
+sub canonicalize
+{
+ my ($self, $name) = @_;
+ return installed_name($name);
+}
sub find
{
my ($repository, $name, $arch) = @_;
@@ -116,7 +131,7 @@ sub find
if (is_installed($name)) {
require OpenBSD::PackageLocation;
- $self = OpenBSD::PackageLocation->new($repository, installed_name($name));
+ $self = OpenBSD::PackageLocation->new($repository, $name);
$self->{dir} = installed_info($name);
}
return $self;