Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/pkg_install Update pkg_install to version 20030912....
details: https://anonhg.NetBSD.org/src/rev/d61a1c46ca5b
branches: trunk
changeset: 551851:d61a1c46ca5b
user: jlam <jlam%NetBSD.org@localhost>
date: Sat Sep 13 05:48:50 2003 +0000
description:
Update pkg_install to version 20030912. Changes from 200230907 are
adding two new options to pkg_admin(1) to simply using this utility to
list the bare package names that match patterns when looking in PKG_DBDIR:
-b Print only the basenames when matching package names for
lsall and lsbest.
-d lsdir
Set lsdir as the path to the directory in which to find
matching package names for lsall and lsbest.
diffstat:
usr.sbin/pkg_install/admin/main.c | 44 +++++++++++++++++++++++++++------
usr.sbin/pkg_install/admin/pkg_admin.1 | 25 ++++++++++++++++---
usr.sbin/pkg_install/lib/version.h | 4 +-
3 files changed, 58 insertions(+), 15 deletions(-)
diffs (185 lines):
diff -r 1ac2b873a531 -r d61a1c46ca5b usr.sbin/pkg_install/admin/main.c
--- a/usr.sbin/pkg_install/admin/main.c Sat Sep 13 04:18:00 2003 +0000
+++ b/usr.sbin/pkg_install/admin/main.c Sat Sep 13 05:48:50 2003 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: main.c,v 1.39 2003/09/08 22:11:12 jlam Exp $ */
+/* $NetBSD: main.c,v 1.40 2003/09/13 05:48:50 jlam Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.39 2003/09/08 22:11:12 jlam Exp $");
+__RCSID("$NetBSD: main.c,v 1.40 2003/09/13 05:48:50 jlam Exp $");
#endif
/*
@@ -49,7 +49,7 @@
#define DEFAULT_SFX ".t[bg]z" /* default suffix for ls{all,best} */
-static const char Options[] = "K:s:V";
+static const char Options[] = "bd:K:s:V";
void usage(void);
@@ -364,7 +364,13 @@
{
char *data = vp;
printf("%s/%s\n", data, pkg);
-
+ return 0;
+}
+
+static int
+lsbasepattern_fn(const char *pkg, void *vp)
+{
+ printf("%s\n", pkg);
return 0;
}
@@ -372,8 +378,11 @@
main(int argc, char *argv[])
{
int ch;
+ char lsdir[FILENAME_MAX];
+ char *lsdirp = NULL;
char sfx[FILENAME_MAX];
Boolean use_default_sfx = TRUE;
+ Boolean show_basename_only = FALSE;
setprogname(argv[0]);
@@ -382,6 +391,15 @@
while ((ch = getopt(argc, argv, Options)) != -1)
switch (ch) {
+ case 'b':
+ show_basename_only = TRUE;
+ break;
+
+ case 'd':
+ (void) strlcpy(lsdir, optarg, sizeof(lsdir));
+ lsdirp = lsdir;
+ break;
+
case 'K':
_pkgdb_setPKGDB_DIR(optarg);
break;
@@ -501,7 +519,7 @@
char cwd[MAXPATHLEN];
char base[FILENAME_MAX];
- dir = dirname_of(*argv);
+ dir = lsdirp ? lsdirp : dirname_of(*argv);
basep = basename_of(*argv);
snprintf(base, sizeof(base), "%s%s", basep, sfx);
@@ -512,7 +530,12 @@
if (getcwd(cwd, sizeof(cwd)) == NULL)
err(EXIT_FAILURE, "getcwd");
- if (findmatchingname(cwd, base, lspattern_fn, cwd) == -1)
+
+ if (show_basename_only)
+ rc = findmatchingname(cwd, base, lsbasepattern_fn, cwd);
+ else
+ rc = findmatchingname(cwd, base, lspattern_fn, cwd);
+ if (rc == -1)
errx(EXIT_FAILURE, "Error in findmatchingname(\"%s\", \"%s\", ...)",
cwd, base);
@@ -539,7 +562,7 @@
char base[FILENAME_MAX];
char *p;
- dir = dirname_of(*argv);
+ dir = lsdirp ? lsdirp : dirname_of(*argv);
basep = basename_of(*argv);
snprintf(base, sizeof(base), "%s%s", basep, sfx);
@@ -552,7 +575,10 @@
err(EXIT_FAILURE, "getcwd");
p = findbestmatchingname(cwd, base);
if (p) {
- printf("%s/%s\n", cwd, p);
+ if (show_basename_only)
+ printf("%s\n", p);
+ else
+ printf("%s/%s\n", cwd, p);
free(p);
}
@@ -631,7 +657,7 @@
void
usage(void)
{
- printf("usage: pkg_admin [-V] [-s sfx] command args ...\n"
+ printf("usage: pkg_admin [-b] [-d lsdir] [-V] [-s sfx] command args ...\n"
"Where 'commands' and 'args' are:\n"
" rebuild - rebuild pkgdb from +CONTENTS files\n"
" check [pkg ...] - check md5 checksum of installed files\n"
diff -r 1ac2b873a531 -r d61a1c46ca5b usr.sbin/pkg_install/admin/pkg_admin.1
--- a/usr.sbin/pkg_install/admin/pkg_admin.1 Sat Sep 13 04:18:00 2003 +0000
+++ b/usr.sbin/pkg_install/admin/pkg_admin.1 Sat Sep 13 05:48:50 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_admin.1,v 1.24 2003/09/08 08:57:42 wiz Exp $
+.\" $NetBSD: pkg_admin.1,v 1.25 2003/09/13 05:48:50 jlam Exp $
.\"
.\" Copyright (c) 1999-2002 Hubert Feyrer. All rights reserved.
.\"
@@ -51,6 +51,18 @@
.Sh OPTIONS
The following command-line options are supported:
.Bl -tag -width indent
+.It Fl b
+Print only the basenames when matching package names for
+.Cm lsall
+and
+.Cm lsbest .
+.It Fl d Ar lsdir
+Set
+.Ar lsdir
+as the path to the directory in which to find matching package names for
+.Cm lsall
+and
+.Cm lsbest .
.It Fl K Ar pkg_dbdir
Set
.Ar pkg_dbdir
@@ -104,12 +116,17 @@
and the data field - the package the file belongs to.
.It Cm lsall Ar /dir/pkgpattern
.It Cm lsbest Ar /dir/pkgpattern
-List all/best package matching pattern in the given directory.
+List all/best package matching pattern in the given directory
+.Pa /dir .
+If the
+.Fl d
+flag is given, then that directory path overrides
+.Pa /dir .
Can be used to work around limitations of /bin/sh and other
filename globbing mechanisms.
This option implements matching of
-pkg-wildcards against arbitrary files, useful mainly in the build
-system itself.
+pkg-wildcards against arbitrary files and directories, useful mainly in
+the build system itself.
See
.Xr pkg_info 1
for a description of the pattern.
diff -r 1ac2b873a531 -r d61a1c46ca5b usr.sbin/pkg_install/lib/version.h
--- a/usr.sbin/pkg_install/lib/version.h Sat Sep 13 04:18:00 2003 +0000
+++ b/usr.sbin/pkg_install/lib/version.h Sat Sep 13 05:48:50 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.30 2003/09/08 07:13:29 jlam Exp $ */
+/* $NetBSD: version.h,v 1.31 2003/09/13 05:48:51 jlam Exp $ */
/*
* Copyright (c) 2001 Thomas Klausner. All rights reserved.
@@ -33,6 +33,6 @@
#ifndef _INST_LIB_VERSION_H_
#define _INST_LIB_VERSION_H_
-#define PKGTOOLS_VERSION "20030907"
+#define PKGTOOLS_VERSION "20030912"
#endif /* _INST_LIB_VERSION_H_ */
Home |
Main Index |
Thread Index |
Old Index