summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgDelete.pm22
-rw-r--r--usr.sbin/pkg_add/pkg_delete.18
2 files changed, 23 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm
index 9dc8d5d2f65..b7b1f22fc6d 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgDelete.pm,v 1.26 2011/11/25 23:58:40 espie Exp $
+# $OpenBSD: PkgDelete.pm,v 1.27 2011/12/02 12:00:32 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -99,8 +99,8 @@ sub tracker
sub handle_options
{
my $state = shift;
- $state->SUPER::handle_options('',
- '[-acinqsvx] [-B pkg-destdir] [-D name[=value]] pkg-name [...]');
+ $state->SUPER::handle_options('X',
+ '[-acinqsvxX] [-B pkg-destdir] [-D name[=value]] pkg-name [...]');
my $base = $state->opt('B') // $ENV{'PKG_DESTDIR'} // '';
if ($base ne '') {
@@ -114,6 +114,7 @@ sub handle_options
} else {
$state->{destdirname} = '${PKG_DESTDIR}';
}
+ $state->{exclude} = $state->opt('X');
}
sub stem2location
@@ -211,7 +212,7 @@ sub process_parameters
my $inst = $state->repo->installed;
if (@ARGV == 0) {
- if (!$state->{automatic}) {
+ if (!$state->{automatic} || $state->{exclude}) {
$state->fatal("No packages to delete");
}
} else {
@@ -379,6 +380,19 @@ sub main
{
my ($self, $state) = @_;
+ if ($state->{exclude}) {
+ my $names = {};
+ for my $l (@{$state->{setlist}}) {
+ for my $n ($l->older_names) {
+ $names->{$n} = 1;
+ }
+ }
+ $state->{setlist} = [];
+ my $inst = $state->repo->installed;
+ for my $l (@{$inst->locations_list}) {
+ $self->add_location($state, $l) if !$names->{$l->name};
+ }
+ }
if ($state->{automatic}) {
if (!defined $state->{setlist}) {
my $inst = $state->repo->installed;
diff --git a/usr.sbin/pkg_add/pkg_delete.1 b/usr.sbin/pkg_add/pkg_delete.1
index d5e8304fca4..7c8a746e7e2 100644
--- a/usr.sbin/pkg_add/pkg_delete.1
+++ b/usr.sbin/pkg_add/pkg_delete.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_delete.1,v 1.43 2011/11/25 09:30:08 espie Exp $
+.\" $OpenBSD: pkg_delete.1,v 1.44 2011/12/02 12:00:32 espie Exp $
.\"
.\" Documentation and design originally from FreeBSD. All the code has
.\" been rewritten since. We keep the documentation's notice:
@@ -15,7 +15,7 @@
.\" Jordan K. Hubbard
.\"
.\"
-.Dd $Mdocdate: November 25 2011 $
+.Dd $Mdocdate: December 2 2011 $
.Dt PKG_DELETE 1
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Nd delete software package distributions
.Sh SYNOPSIS
.Nm pkg_delete
-.Op Fl acimnqsvx
+.Op Fl acimnqsvxX
.Op Fl B Ar pkg-destdir
.Op Fl D Ar name Ns Op = Ns Ar value
.Ar pkg-name Op Ar ...
@@ -136,6 +136,8 @@ shows most internal computations apart from individual file/directory
additions, and
.Fl vvvvv
shows everything.
+.It Fl X
+Delete everything, except the list of packages that follow.
.It Fl x
Disable progress meter.
.El