summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-09-04 22:47:57 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-09-04 22:47:57 +0000
commit2491e24fbcb5bf7f102559b04685505a55540a40 (patch)
treeadf517bc59741fd86b70ae1478ebd17ed891f00b /usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
parentdb2b33c1ae5ac54b7cf4811c71ed9a875ec2490d (diff)
* New -i interactive option, that can ask obnoxious questions.
* move the signature code to a packing-list method, prepend the pkgname. * depend on distant listings, cache these systematically. * cut the PKG_PATH at :/ systematically, much simpler than parsing URLs. People should get used to trailing /s. * let pkg_add -u actually run the update. * check for signature in more places, for instance, let pkg_add installed_stuff be a void operation. * grab enough stuff during updates to check signatures, so that pkg_add -u can report updates that are not needed right away, instead of waiting for the more confusing `trying to update' * beginning of @module support. * @pkgpath support, including updates. * systematically expand stems when applicable. * use visitors systematically in pkg_info. * pkg_info -S reports signature. * remove hardcoding of categories in PackingList, so that future modules will be able to expand them. * add @updateset and @incompatibility keywords.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackageInfo.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageInfo.pm53
1 files changed, 50 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
index f0873940f5a..a82351f4e35 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.17 2005/01/16 11:16:23 espie Exp $
+# $OpenBSD: PackageInfo.pm,v 1.18 2005/09/04 22:47:56 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -21,13 +21,14 @@ package OpenBSD::PackageInfo;
our @ISA=qw(Exporter);
our @EXPORT=qw(installed_packages installed_info installed_name info_names is_info_name
lock_db unlock_db
- add_installed delete_installed is_installed borked_package CONTENTS COMMENT DESC INSTALL DEINSTALL REQUIRE
+ add_installed delete_installed is_installed borked_package CONTENTS COMMENT DESC INSTALL DEINSTALL REQUIRE MODULE
REQUIRED_BY REQUIRING DISPLAY UNDISPLAY MTREE_DIRS);
use OpenBSD::PackageName;
use constant {
CONTENTS => '+CONTENTS',
COMMENT => '+COMMENT',
+ MODULE => '+MODULE.pm' ,
DESC => '+DESC',
INSTALL => '+INSTALL',
DEINSTALL => '+DEINSTALL',
@@ -43,13 +44,14 @@ my $pkg_db = $ENV{"PKG_DBDIR"} || '/var/db/pkg';
our $list;
-our @info = (CONTENTS, COMMENT, DESC, REQUIRE, INSTALL, DEINSTALL, REQUIRED_BY, REQUIRING, DISPLAY, UNDISPLAY, MTREE_DIRS);
+our @info = (CONTENTS, COMMENT, DESC, REQUIRE, INSTALL, DEINSTALL, REQUIRED_BY, REQUIRING, DISPLAY, UNDISPLAY, MTREE_DIRS, MODULE);
our %info = ();
for my $i (@info) {
my $j = $i;
$j =~ s/\+/F/;
$info{$i} = $j;
+ $info{'+MODULE.pm'} = 'FMODULE';
}
sub _init_list
@@ -193,4 +195,49 @@ sub unlock_db()
}
}
+
+sub solve_installed_names
+{
+ my ($old, $new, $msg, $state) = @_;
+
+ my $installed;
+ my $bad = 0;
+
+ for my $pkgname (@$old) {
+ $pkgname =~ s/\.tgz$//;
+ if (is_installed($pkgname)) {
+ push(@$new, installed_name($pkgname));
+ } else {
+ if (OpenBSD::PackageName::is_stem($pkgname)) {
+ if (!defined $installed) {
+ $installed = OpenBSD::PackageName::compile_stemlist(installed_packages());
+ }
+ my @l = $installed->findstem($pkgname);
+ if (@l == 0) {
+ print "Can't resolve $pkgname to an installed package name\n";
+ $bad = 1;
+ } elsif (@l == 1) {
+ push(@$new, $l[0]);
+ } elsif (@l != 0) {
+ print "Ambiguous: $pkgname could be ", join(' ', @l),"\n";
+ if ($state->{forced}->{ambiguous}) {
+ print "$msg\n";
+ push(@$new, @l);
+ } else {
+ if ($state->{interactive}) {
+ require OpenBSD::ProgressMeter;
+
+ my $result = OpenBSD::ProgressMeter::ask_list('Choose one package', 1, ("<None>", sort @l));
+ push(@$new, $result) if $result ne '<None>';
+ } else {
+ $bad = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ return $bad;
+}
+
1;