diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2003-11-06 17:49:32 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2003-11-06 17:49:32 +0000 |
commit | d6c500a243aecc271b6a050d902fdc8f84c4e2b3 (patch) | |
tree | 49925fb0eb872fa6f9ad3b670cc1d15c81d3f4cc /usr.sbin/pkg_add | |
parent | 3eb00852c75a69f5eb0ed8d716454ac20af3d42a (diff) |
Allow the use of full paths to refer to installed packages, so that
pkg_delete /var/db/pkg/zsh-*/ works.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 19 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 4 |
2 files changed, 18 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index e562aa00450..9833c0f6a86 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm @@ -1,4 +1,4 @@ -# $OpenBSD: PackageInfo.pm,v 1.1 2003/10/16 17:43:34 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.2 2003/11/06 17:49:31 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -27,7 +27,7 @@ use strict; use warnings; package OpenBSD::PackageInfo; our @ISA=qw(Exporter); -our @EXPORT=qw(installed_packages installed_info info_names is_info_name +our @EXPORT=qw(installed_packages installed_info installed_name info_names is_info_name add_installed is_installed CONTENTS COMMENT DESC INSTALL DEINSTALL REQUIRE REQUIRED_BY DISPLAY MTREE_DIRS); @@ -89,7 +89,12 @@ sub installed_packages() sub installed_info($) { my $name = shift; - return "$pkg_db/$name/"; + + if ($name =~ m|^\Q$pkg_db\E/?|) { + return "$name/"; + } else { + return "$pkg_db/$name/"; + } } sub is_installed($) @@ -101,6 +106,14 @@ sub is_installed($) return $dir; } +sub installed_name($) +{ + my $name = shift; + $name =~ s|/$||; + $name =~ s|^\Q$pkg_db\E/?||; + return $name; +} + sub info_names() { return @info; diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index 635d38e880b..47546600625 100644 --- a/usr.sbin/pkg_add/pkg_delete +++ b/usr.sbin/pkg_add/pkg_delete @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_delete,v 1.9 2003/11/04 17:55:17 espie Exp $ +# $OpenBSD: pkg_delete,v 1.10 2003/11/06 17:49:31 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -333,7 +333,7 @@ for my $pkgname (@ARGV) { } } next unless is_installed($pkgname); - push(@realnames, $pkgname); + push(@realnames, installed_name($pkgname)); } # Then check that dependencies are okay |