summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-14 10:00:09 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-14 10:00:09 +0000
commit4eb45a02d3106a414c165c9bbf9d188474aaa8df (patch)
tree4a7fc95d68fe3712dd19ebcd4c30cad3be1c75fc /usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
parent9f3ff678da304f25a7b5583c667e4dff7d39f58e (diff)
maintain stemlist for installed packages dynamically
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageInfo.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageInfo.pm16
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
index e9c47f0316c..acdd0dd9d87 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageInfo.pm,v 1.25 2007/05/14 09:49:27 espie Exp $
+# $OpenBSD: PackageInfo.pm,v 1.26 2007/05/14 10:00:08 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -19,7 +19,7 @@ use strict;
use warnings;
package OpenBSD::PackageInfo;
our @ISA=qw(Exporter);
-our @EXPORT=qw(installed_packages installed_info installed_name info_names is_info_name
+our @EXPORT=qw(installed_packages installed_info installed_name info_names is_info_name installed_stems
lock_db unlock_db
add_installed delete_installed is_installed borked_package CONTENTS COMMENT DESC INSTALL DEINSTALL REQUIRE MODULE
REQUIRED_BY REQUIRING DISPLAY UNDISPLAY MTREE_DIRS);
@@ -42,7 +42,7 @@ use constant {
use Fcntl qw/:flock/;
my $pkg_db = $ENV{"PKG_DBDIR"} || '/var/db/pkg';
-my $list;
+my ($list, $stemlist);
our @info = (CONTENTS, COMMENT, DESC, REQUIRE, INSTALL, DEINSTALL, REQUIRED_BY, REQUIRING, DISPLAY, UNDISPLAY, MTREE_DIRS, MODULE);
@@ -57,11 +57,12 @@ for my $i (@info) {
sub _init_list
{
$list = {};
+ $stemlist = OpenBSD::PackageName::compile_stemlist();
opendir(my $dir, $pkg_db) or die "Bad pkg_db: $!";
while (my $e = readdir($dir)) {
next if $e eq '.' or $e eq '..';
- $list->{$e} = 1;
+ add_installed($e);
}
close($dir);
}
@@ -73,6 +74,7 @@ sub add_installed
}
for my $p (@_) {
$list->{$p} = 1;
+ $stemlist->add($p);
}
}
@@ -83,10 +85,16 @@ sub delete_installed
}
for my $p (@_) {
delete $list->{$p};
+ $stemlist->delete($p);
}
}
+sub installed_stems
+{
+ return $stemlist;
+}
+
sub installed_packages(;$)
{
if (!defined $list) {