diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-09 10:59:49 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-09 10:59:49 +0000 |
commit | e5704d7fa9572ad878b818220a4f0dd96ab08641 (patch) | |
tree | 13c55d3ce5c901bd7d454b3ccc9857aac841de51 /usr.sbin/pkg_add | |
parent | 8bf87ff0e6f51524a4ca44fe5b34eb426142cb7f (diff) |
move the code that recognizes /var/db/pkg as inst: into Repo::Local
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 14 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 22 |
2 files changed, 21 insertions, 15 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index d2ab5feaec7..5215985ca5c 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.79 2010/01/09 10:45:32 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.80 2010/01/09 10:59:48 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -45,22 +45,12 @@ if (defined $ENV{PKG_PATH}) { sub path_parse { - use OpenBSD::Paths; - my $pkg_db = $ENV{"PKG_DBDIR"} || OpenBSD::Paths->pkgdb; - my ($pkgname, $path) = (shift, './'); if ($pkgname =~ m/^(.*[\/\:])(.*)/) { ($pkgname, $path) = ($2, $1); } - my $repo; - - if ($path eq $pkg_db.'/') { - $repo = OpenBSD::PackageRepository::Installed->new; - } else { - $repo = OpenBSD::PackageRepository->new($path); - } - return ($repo, $path, $pkgname); + return (OpenBSD::PackageRepository->new($path), $path, $pkgname); } sub find diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 1a6444c8d3f..992a3f6e6e5 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.72 2010/01/09 10:44:41 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.73 2010/01/09 10:59:48 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -240,12 +240,28 @@ sub urlscheme return 'file'; } +my $pkg_db; + +sub pkg_db +{ + if (!defined $pkg_db) { + use OpenBSD::Paths; + $pkg_db = $ENV{"PKG_DBDIR"} || OpenBSD::Paths->pkgdb; + } + return $pkg_db; +} + sub parse_fullurl { my ($class, $_) = @_; - $class->strip_urlscheme(\$_); - return $class->parse_url($_); + my $r = $class->strip_urlscheme(\$_); + my $o = $class->parse_url($_); + if (!$r && $o->{path} eq $class->pkg_db()."/") { + return OpenBSD::PackageRepository::Installed->new; + } else { + return $o; + } } # wrapper around copy, that sometimes does not copy |