From 1d705097f209fa7e37dcb2cdc9e563c115212724 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Tue, 13 Sep 2005 20:03:30 +0000 Subject: Repository::Installed class, to provide uniform access to installed packages compared to other `repositories'. --- usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index cfa0d0e1de8..44684370f6e 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.27 2005/09/13 19:40:30 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.28 2005/09/13 20:03:29 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie # @@ -125,6 +125,43 @@ sub grabPlist return $self->grabPlist($name, $arch, $code); } +package OpenBSD::PackageRepository::Installed; +use OpenBSD::PackageInfo; + +sub find +{ + my ($repository, $name, $arch) = @_; + my $self; + + if (is_installed($name)) { + $self = OpenBSD::PackageLocation->new($repository, $name); + $self->{dir} = installed_info($name); + } + return $self; +} + +sub grabPlist +{ + my ($repository, $name, $arch, $code) = @_; + require OpenBSD::PackingList; + return OpenBSD::PackingList->from_installation($name, $code); +} + +sub available +{ + return installed_packages(); +} + +sub wipe_info +{ +} + +sub may_exist +{ + my ($self, $name) = @_; + return is_installed($name); +} + package OpenBSD::PackageRepository::SCP; our @ISA=qw(OpenBSD::PackageRepository OpenBSD::PackageRepository::FTPorSCP); -- cgit v1.2.3