summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/pkg_delete14
-rw-r--r--usr.sbin/pkg_add/pkg_info119
2 files changed, 76 insertions, 57 deletions
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index 51ca34c28a6..8ecbcbb8ea5 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.2 2003/10/19 18:42:55 espie Exp $
+# $OpenBSD: pkg_delete,v 1.3 2003/10/23 17:48:07 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -213,7 +213,7 @@ sub delete
my $opt_v = $state->{verbose};
my $opt_n = $state->{not};
my $pkgname = $state->{pkgname};
- print "Deinstall script: $dir",DEINSTALL ,"$pkgname DEINSTALL\n" if $opt_v or $opt_n;
+ print "Deinstall script: $dir",DEINSTALL ," $pkgname DEINSTALL\n" if $opt_v or $opt_n;
unless ($opt_n) {
chmod 0755, $dir.DEINSTALL;
system($dir.DEINSTALL, $pkgname, "DEINSTALL") == 0 or
@@ -295,6 +295,16 @@ do {
for my $pkgname (@ARGV) {
next if $done{$pkgname};
unless (is_installed($pkgname)) {
+ if (OpenBSD::PackageName::is_stem($pkgname)) {
+ my @l = OpenBSD::PackageName::findstem($pkgname, installed_packages());
+ if (@l == 1) {
+ $pkgname = $l[0];
+ } elsif (@l != 0) {
+ print "Ambiguous: $pkgname could be ", join(' ', @l),"\n";
+ }
+ }
+ }
+ unless (is_installed($pkgname)) {
print "$pkgname was not installed\n";
$done{$pkgname} = 1;
$removed++;
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info
index ddc64e0b5f7..d7bce4a0b43 100644
--- a/usr.sbin/pkg_add/pkg_info
+++ b/usr.sbin/pkg_add/pkg_info
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_info,v 1.2 2003/10/19 18:40:11 espie Exp $
+# $OpenBSD: pkg_info,v 1.3 2003/10/23 17:48:07 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -62,61 +62,11 @@ sub get_line
our ($opt_c, $opt_D, $opt_d, $opt_f, $opt_I, $opt_i, $opt_k, $opt_L, $opt_m,
$opt_p, $opt_q, $opt_R, $opt_r, $opt_v, $opt_h, $opt_e, $opt_l, $opt_a);
-getopts('cDdfIikLmpqRrvhe:l:a');
-
-if (defined $opt_e) {
- die "Error: -e is not yet supported";
-}
-
-unless ($opt_c || $opt_D || $opt_d || $opt_f || $opt_I || $opt_i ||
- $opt_k || $opt_L || $opt_m || $opt_p || $opt_R || $opt_r) {
- if (@ARGV == 0) {
- $opt_I = $opt_a = 1;
- } else {
- $opt_c = $opt_d = $opt_R = 1;
- }
-}
-
-if ($opt_v) {
- $opt_c = $opt_d = $opt_f = $opt_i = $opt_k = $opt_r = $opt_D =
- $opt_m = $opt_R = 1;
-}
-
-if (!defined $opt_p) {
- $opt_p = "";
-}
-
-if (@ARGV == 0 && !$opt_a) {
- die "Missing package name(s)";
-}
-
-if (@ARGV > 0 && $opt_a) {
- die "Can't specify package name(s) with -a";
-}
-
-if (@ARGV == 0) {
- @ARGV = sort(installed_packages());
-}
-
-for my $pkg (@ARGV) {
- my $dir = installed_info($pkg);
- unless (-d $dir) {
- if (OpenBSD::PackageName::is_stem($pkg)) {
- my @l = OpenBSD::PackageName::findstem($pkg, installed_packages());
- if (@l == 1) {
- $dir = installed_info($l[0]);
- } elsif (@l != 0) {
- print STDERR "$pkg: ambiguous (", join(" ",@l), ")\n";
- next;
- }
- }
- }
-
+sub print_info
+{
+ my ($pkg, $dir) = @_;
unless (-d $dir) {
- my $true_package = OpenBSD::PackageLocator->find($pkg);
- next unless $true_package;
- $dir = $true_package->info();
- $true_package->close();
+ print STDERR "Error printing info for $pkg: no info ?\n";
}
if ($opt_I) {
my $l = 20 - length($pkg);
@@ -184,3 +134,62 @@ for my $pkg (@ARGV) {
print $opt_p, "\n" unless $opt_q;
}
}
+
+getopts('cDdfIikLmpqRrvhe:l:a');
+
+if (defined $opt_e) {
+ die "Error: -e is not yet supported";
+}
+
+unless ($opt_c || $opt_D || $opt_d || $opt_f || $opt_I || $opt_i ||
+ $opt_k || $opt_L || $opt_m || $opt_p || $opt_R || $opt_r) {
+ if (@ARGV == 0) {
+ $opt_I = $opt_a = 1;
+ } else {
+ $opt_c = $opt_d = $opt_R = 1;
+ }
+}
+
+if ($opt_v) {
+ $opt_c = $opt_d = $opt_f = $opt_i = $opt_k = $opt_r = $opt_D =
+ $opt_m = $opt_R = 1;
+}
+
+if (!defined $opt_p) {
+ $opt_p = "";
+}
+
+if (@ARGV == 0 && !$opt_a) {
+ die "Missing package name(s)";
+}
+
+if (@ARGV > 0 && $opt_a) {
+ die "Can't specify package name(s) with -a";
+}
+
+if (@ARGV == 0) {
+ @ARGV = sort(installed_packages());
+}
+
+for my $pkg (@ARGV) {
+ if (is_installed($pkg)) {
+ print_info($pkg, installed_info($pkg));
+ next;
+ }
+ if (OpenBSD::PackageName::is_stem($pkg)) {
+ my @l = sort (OpenBSD::PackageName::findstem($pkg, installed_packages()));
+ if (@l != 0) {
+ for my $p (@l) {
+ print_info($p, installed_info($p));
+ }
+ next;
+ }
+ }
+
+ my $true_package = OpenBSD::PackageLocator->find($pkg);
+ next unless $true_package;
+ my $dir = $true_package->info();
+ $true_package->close();
+
+ print_info($pkg, $dir);
+}