summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-05-16 18:29:19 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-05-16 18:29:19 +0000
commit0a0719236d7b2bb296dc6b3d3ee1fd4d9bbba5a9 (patch)
tree063f608305b48355e5dc14e06108fb8c2557b925 /usr.sbin
parent8d336b00e6c6298b024d185ae5bceef6d9bd6fa9 (diff)
add a -d repository option in order not to have to specify all pkgnames.
as noticed by naddy and ajacoutot, we now have enough packages that this stresses shell limits if we specify everything on the command line. ;-)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/pkg_mklocatedb18
-rw-r--r--usr.sbin/pkg_add/pkg_mklocatedb.116
2 files changed, 27 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/pkg_mklocatedb b/usr.sbin/pkg_add/pkg_mklocatedb
index 8034ecab89b..52dc3454b9b 100644
--- a/usr.sbin/pkg_add/pkg_mklocatedb
+++ b/usr.sbin/pkg_add/pkg_mklocatedb
@@ -34,9 +34,9 @@ sub print_name
package main;
-set_usage('pkg_mklocatedb [-anPq] [-p portsdir] [-r release] [-s src] [-x X11src] [pkg-name [...]]');
+set_usage('pkg_mklocatedb [-anPq] [-p portsdir] [-d repository] [-r release] [-s src] [-x X11src] [pkg-name [...]]');
-our ($opt_a, $opt_n, $opt_q, $opt_s, $opt_x, $opt_r, $opt_p, $opt_P);
+our ($opt_a, $opt_n, $opt_q, $opt_s, $opt_x, $opt_r, $opt_p, $opt_P, $opt_d);
sub info
{
@@ -69,7 +69,7 @@ sub tag
}
try {
- getopts('anqs:x:r:p:P');
+ getopts('ad:nqs:x:r:p:P');
} catchall {
Usage($_);
};
@@ -160,7 +160,17 @@ if ($opt_p) {
close($in);
}
-elsif (@ARGV==0) {
+elsif ($opt_d) {
+ require File::Find;
+ die "Bad argument: $opt_d is not a directory" unless -d $opt_d;
+ File::Find::find(
+ sub {
+ return unless -f $_;
+ my $plist = OpenBSD::PackageLocator->grabPlist($File::Find::name);
+ return unless defined $plist;
+ $plist->print_name($fh, info($plist));
+ }, $opt_d);
+} elsif (@ARGV==0) {
for my $pkgname (installed_packages()) {
my $plist = OpenBSD::PackingList->from_installation($pkgname);
next unless defined $plist;
diff --git a/usr.sbin/pkg_add/pkg_mklocatedb.1 b/usr.sbin/pkg_add/pkg_mklocatedb.1
index dd0caa8edf1..a5b0800ade8 100644
--- a/usr.sbin/pkg_add/pkg_mklocatedb.1
+++ b/usr.sbin/pkg_add/pkg_mklocatedb.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_mklocatedb.1,v 1.8 2007/05/31 19:20:26 jmc Exp $
+.\" $OpenBSD: pkg_mklocatedb.1,v 1.9 2008/05/16 18:29:18 espie Exp $
.\" Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@@ -13,7 +13,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: May 16 2008 $
.Dt PKG_MKLOCATEDB 1
.Os
.Sh NAME
@@ -22,6 +22,7 @@
.Sh SYNOPSIS
.Nm pkg_mklocatedb
.Op Fl anPq
+.Op Fl d Ar repository
.Op Fl p Ar portsdir
.Op Fl r Ar release
.Op Fl s Ar src
@@ -47,7 +48,12 @@ Otherwise,
.Nm
will build database entries for every file object for each
.Ar pkg-name
-given on the command line.
+given on the command line,
+or for every package in a
+.Ar repository
+specified as the
+.Fl d
+option.
If no package name is given,
.Nm
will build database entries for all currently installed packages.
@@ -67,6 +73,10 @@ The options are as follows:
.Bl -tag -width Ds
.It Fl a
Prepend file names with pkgpath information and package names.
+.It Fl d Ar repository
+Scan directory
+.Ar repository
+for packages.
.It Fl n
Do not pipe output to
.Pa /usr/libexec/locate.mklocatedb