summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-02-15 09:13:06 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-02-15 09:13:06 +0000
commit85aba7e461d0db1c7307b89afd2bb9acdee1dd78 (patch)
treebbc29c27be203adc980bf4fc48e39cd836058ad4 /usr.sbin/pkg_add
parent79644b2c9343a5d1c44298e22f16ad7805978fb4 (diff)
New command: pkg_mklocatedb, that can be used to create locate(1)-style
databases for packages (duh, isn't that obvious from the name ?) Tweaks based on comments from naddy/jmc.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/Makefile5
-rw-r--r--usr.sbin/pkg_add/TODO2
-rw-r--r--usr.sbin/pkg_add/pkg_mklocatedb72
-rw-r--r--usr.sbin/pkg_add/pkg_mklocatedb.162
4 files changed, 137 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile
index 04c4bcf7989..cd4fe8f8166 100644
--- a/usr.sbin/pkg_add/Makefile
+++ b/usr.sbin/pkg_add/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.18 2004/11/21 15:36:17 espie Exp $
+# $OpenBSD: Makefile,v 1.19 2005/02/15 09:13:05 espie Exp $
-MAN=pkg_add.1 pkg_info.1 pkg_create.1 pkg_delete.1 pkg.1
+MAN=pkg_add.1 pkg_info.1 pkg_create.1 pkg_delete.1 pkg.1 pkg_mklocatedb.1
PACKAGES= \
OpenBSD/Add.pm \
@@ -34,6 +34,7 @@ SCRIPTS= \
pkg_info \
pkg_create \
pkg_delete \
+ pkg_mklocatedb \
pkg
LIBBASE=/usr/libdata/perl5
diff --git a/usr.sbin/pkg_add/TODO b/usr.sbin/pkg_add/TODO
index 4c41ec9dab8..3d272984782 100644
--- a/usr.sbin/pkg_add/TODO
+++ b/usr.sbin/pkg_add/TODO
@@ -1,5 +1,3 @@
-- smart handling of .libs-*: pkg_add correctly discards potential conflicts.
-It doesn't handle yet actual conflicts with .libs-*.
- handle n-to-1 updates: mostly need to allow for a list of replaced packages.
The tricky part is that the replaced packages will often have
inter-dependencies, and we must ignore those inter-dependencies.
diff --git a/usr.sbin/pkg_add/pkg_mklocatedb b/usr.sbin/pkg_add/pkg_mklocatedb
new file mode 100644
index 00000000000..b6450212553
--- /dev/null
+++ b/usr.sbin/pkg_add/pkg_mklocatedb
@@ -0,0 +1,72 @@
+#! /usr/bin/perl
+# Copyright (c) 2005 Marc Espie <espie@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+use strict;
+use OpenBSD::PackageLocator;
+use OpenBSD::PackageInfo;
+use OpenBSD::PackingList;
+use OpenBSD::Getopt;
+use OpenBSD::Error;
+use File::Path;
+
+package OpenBSD::PackingElement;
+sub print_name {}
+
+package OpenBSD::PackingElement::FileObject;
+sub print_name
+{
+ my ($self, $fh, $pkgname) = @_;
+ print $fh $pkgname, ":", $self->fullname(), "\n";
+}
+
+package main;
+
+set_usage('pkg_mklocatedb -nq [pkgname ...]');
+
+our ($opt_n, $opt_q);
+
+try {
+ getopts('nq');
+} catchall {
+ Usage($_);
+};
+
+my $fh;
+my $MKLOCATEDB="/usr/libexec/locate.mklocatedb";
+
+if ($opt_n or -t STDOUT) {
+ $fh = \*STDOUT;
+} else {
+ open $fh, "|-", $MKLOCATEDB, $MKLOCATEDB or die "couldn't open pipe: $!";
+}
+
+if (@ARGV==0) {
+ for my $pkgname (installed_packages()) {
+ print STDERR "$pkgname\n" unless $opt_q;
+ my $plist = OpenBSD::PackingList->from_installation($pkgname);
+ $plist->visit('print_name', $fh, $plist->pkgname());
+ }
+} else {
+ for my $pkgname (@ARGV) {
+ print STDERR "$pkgname\n" unless $opt_q;
+ my $true_package = OpenBSD::PackageLocator->find($pkgname);
+ next unless $true_package;
+ my $dir = $true_package->info();
+ $true_package->close();
+ my $plist = OpenBSD::PackingList->fromfile($dir.CONTENTS);
+ $plist->visit('print_name', $fh, $plist->pkgname());
+ rmtree($dir);
+ }
+}
diff --git a/usr.sbin/pkg_add/pkg_mklocatedb.1 b/usr.sbin/pkg_add/pkg_mklocatedb.1
new file mode 100644
index 00000000000..cb9ac5575a6
--- /dev/null
+++ b/usr.sbin/pkg_add/pkg_mklocatedb.1
@@ -0,0 +1,62 @@
+.\" $OpenBSD: pkg_mklocatedb.1,v 1.1 2005/02/15 09:13:05 espie Exp $
+.\" Copyright (c) 2005 Marc Espie <espie@openbsd.org>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd February 17, 2005
+.Dt PKG_MKLOCATEDB 1
+.Os
+.Sh NAME
+.Nm pkg_mklocatedb
+.Nd create a locate database for packages
+.Sh SYNOPSIS
+.Nm pkg_mklocatedb
+.Op Fl nq
+.Op Ar pkg-name Op Ar ...
+.Sh DESCRIPTION
+The
+.Nm
+command is used to create
+.Xr locate 1 Ns -style
+databases adapted for packages.
+.Pp
+Entries created for each package will have the package name prepended:
+.Li kdelibs-3.3.2p2:/usr/local/bin/meinproc .
+.Pp
+.Nm
+will build database entries for every file object for each
+.Ar pkg-name
+given on the command line.
+If no package name is given,
+.Nm
+will build database entries for all currently installed packages.
+.Pp
+By default (unless standard output is a terminal),
+the list of names is fed to
+.Pa /usr/libexec/locate.mklocatedb
+and the end result should be redirected to a file.
+.Pp
+The options are as follows:
+.Bl -tag -width opt
+.It Fl n
+Do not pipe output to
+.Pa /usr/libexec/locate.mklocatedb
+(default if standard output is a terminal).
+.It Fl q
+Be quiet: do not report every package processed to standard error.
+.El
+.Sh SEE ALSO
+.Xr locate 1 ,
+.Xr pkg_info 1
+.Sh AUTHORS
+.An Marc Espie