summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2003-09-13 05:50:23 +0000
committerjlam <jlam@pkgsrc.org>2003-09-13 05:50:23 +0000
commit06768a3ab42ae00f1795ca28b2bc05fa57d67f0f (patch)
treef0875ca1e7b3fc2e03bb675ff74620d944606b51 /pkgtools
parent058716ce451cba29848687cee74a772f45f76ad7 (diff)
downloadpkgsrc-06768a3ab42ae00f1795ca28b2bc05fa57d67f0f.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/admin/main.c44
-rw-r--r--pkgtools/pkg_install/files/admin/pkg_admin.125
-rw-r--r--pkgtools/pkg_install/files/admin/pkg_admin.cat119
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
4 files changed, 72 insertions, 20 deletions
diff --git a/pkgtools/pkg_install/files/admin/main.c b/pkgtools/pkg_install/files/admin/main.c
index f7dc8cd09f1..90afb224378 100644
--- a/pkgtools/pkg_install/files/admin/main.c
+++ b/pkgtools/pkg_install/files/admin/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.11 2003/09/09 13:34:18 jlam Exp $ */
+/* $NetBSD: main.c,v 1.12 2003/09/13 05:50:26 jlam Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -8,7 +8,7 @@
#include <sys/cdefs.h>
#endif
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.11 2003/09/09 13:34:18 jlam Exp $");
+__RCSID("$NetBSD: main.c,v 1.12 2003/09/13 05:50:26 jlam Exp $");
#endif
/*
@@ -73,7 +73,7 @@ __RCSID("$NetBSD: main.c,v 1.11 2003/09/09 13:34:18 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);
@@ -388,7 +388,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;
}
@@ -396,8 +402,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]);
@@ -406,6 +415,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;
@@ -525,7 +543,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);
@@ -536,7 +554,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);
@@ -563,7 +586,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);
@@ -576,7 +599,10 @@ main(int argc, char *argv[])
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);
}
@@ -655,7 +681,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"
diff --git a/pkgtools/pkg_install/files/admin/pkg_admin.1 b/pkgtools/pkg_install/files/admin/pkg_admin.1
index 86682c94bd5..344ceb08900 100644
--- a/pkgtools/pkg_install/files/admin/pkg_admin.1
+++ b/pkgtools/pkg_install/files/admin/pkg_admin.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_admin.1,v 1.3 2003/09/09 13:34:18 jlam Exp $
+.\" $NetBSD: pkg_admin.1,v 1.4 2003/09/13 05:50:26 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.
diff --git a/pkgtools/pkg_install/files/admin/pkg_admin.cat1 b/pkgtools/pkg_install/files/admin/pkg_admin.cat1
index cb4665f31a0..756caab87a3 100644
--- a/pkgtools/pkg_install/files/admin/pkg_admin.cat1
+++ b/pkgtools/pkg_install/files/admin/pkg_admin.cat1
@@ -13,6 +13,13 @@ DDEESSCCRRIIPPTTIIOONN
OOPPTTIIOONNSS
The following command-line options are supported:
+ --bb Print only the basenames when matching package names for llssaallll
+ and llssbbeesstt.
+
+ --dd _l_s_d_i_r
+ Set _l_s_d_i_r as the path to the directory in which to find matching
+ package names for llssaallll and llssbbeesstt.
+
--KK _p_k_g___d_b_d_i_r
Set _p_k_g___d_b_d_i_r as the package database directory. If this option
isn't specified, then the package database directory is taken
@@ -59,11 +66,13 @@ OOPPTTIIOONNSS
llssaallll _/_d_i_r_/_p_k_g_p_a_t_t_e_r_n
llssbbeesstt _/_d_i_r_/_p_k_g_p_a_t_t_e_r_n
- List all/best package matching pattern in the given directory.
- Can be used to work around limitations of /bin/sh and other file-
- name globbing mechanisms. This option implements matching of
- pkg-wildcards against arbitrary files, useful mainly in the build
- system itself. See pkg_info(1) for a description of the pattern.
+ List all/best package matching pattern in the given directory
+ _/_d_i_r. If the --dd flag is given, then that directory path over-
+ rides _/_d_i_r. 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 and directo-
+ ries, useful mainly in the build system itself. See pkg_info(1)
+ for a description of the pattern.
Example:
diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index f370873ce14..bdff55b7805 100644
--- a/pkgtools/pkg_install/files/lib/version.h
+++ b/pkgtools/pkg_install/files/lib/version.h
@@ -1,4 +1,4 @@
-/* $NetBSD: version.h,v 1.12 2003/09/09 13:34:21 jlam Exp $ */
+/* $NetBSD: version.h,v 1.13 2003/09/13 05:50:26 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_ */