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.
This commit is contained in:
jlam 2003-09-13 05:48:50 +00:00
parent ec5dc2be24
commit 1732738842
3 changed files with 58 additions and 15 deletions

View File

@ -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 @@ __RCSID("$NetBSD: main.c,v 1.39 2003/09/08 22:11:12 jlam Exp $");
#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 @@ lspattern_fn(const char *pkg, void *vp)
{
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 @@ int
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 @@ main(int argc, char *argv[])
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 @@ main(int argc, char *argv[])
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 @@ main(int argc, char *argv[])
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 @@ main(int argc, char *argv[])
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,6 +575,9 @@ main(int argc, char *argv[])
err(EXIT_FAILURE, "getcwd");
p = findbestmatchingname(cwd, base);
if (p) {
if (show_basename_only)
printf("%s\n", p);
else
printf("%s/%s\n", cwd, p);
free(p);
}
@ -631,7 +657,7 @@ main(int argc, char *argv[])
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"

View File

@ -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 @@ Packages System.
.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 @@ Columns are printed for the keyfield used in the pkgdb - the filename -,
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.

View File

@ -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_ */