Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pkgviews]: src/usr.sbin/pkg_install/admin Add an option "-s sfx_pattern"...
details: https://anonhg.NetBSD.org/src/rev/92c56221de02
branches: pkgviews
changeset: 534249:92c56221de02
user: jlam <jlam%NetBSD.org@localhost>
date: Thu Jul 31 19:17:36 2003 +0000
description:
Add an option "-s sfx_pattern" to pkg_admin(1) to allow specifying the
package suffix when matching package names for the `lsall' and `lsbest'
commands. The sfx_pattern defaults to ".t[bg]z" to match the existing
behaviour.
We can now use pkg_admin(1) in ${DEPOTBASE} to find the best version of
a package if multiple versions are installed:
# cd /usr/pkg/packages
# ls png-*
png-1.2.1
png-1.2.4
png-1.2.5nb2
# pkg_admin -s "" lsall 'png>=1.2.4'
/usr/pkg/packages/png-1.2.4
/usr/pkg/packages/png-1.2.5nb2
# pkg_admin -s "" lsbest 'png>=1.2.4'
/usr/pkg/packages/png-1.2.5nb2
diffstat:
usr.sbin/pkg_install/admin/main.c | 64 ++++++++++++++++++++++-----------
usr.sbin/pkg_install/admin/pkg_admin.1 | 24 +++++++++---
2 files changed, 59 insertions(+), 29 deletions(-)
diffs (223 lines):
diff -r d8c4678fa384 -r 92c56221de02 usr.sbin/pkg_install/admin/main.c
--- a/usr.sbin/pkg_install/admin/main.c Thu Jul 31 17:34:45 2003 +0000
+++ b/usr.sbin/pkg_install/admin/main.c Thu Jul 31 19:17:36 2003 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: main.c,v 1.28.2.2 2003/07/31 17:34:45 jlam Exp $ */
+/* $NetBSD: main.c,v 1.28.2.3 2003/07/31 19:17:36 jlam Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.28.2.2 2003/07/31 17:34:45 jlam Exp $");
+__RCSID("$NetBSD: main.c,v 1.28.2.3 2003/07/31 19:17:36 jlam Exp $");
#endif
/*
@@ -47,6 +47,10 @@
#include "lib.h"
+#define DEFAULT_SFX ".t[bg]z" /* default suffix for ls{all,best} */
+
+static const char Options[] = "s:V";
+
void usage(void);
int filecnt;
@@ -338,21 +342,40 @@
int
main(int argc, char *argv[])
{
+ int ch;
+ char sfx[FILENAME_MAX];
+ Boolean use_default_sfx = TRUE;
+
setprogname(argv[0]);
if (argc < 2)
usage();
- if (strcmp(argv[1], "-V") == 0) {
+ while ((ch = getopt(argc, argv, Options)) != -1)
+ switch (ch) {
+ case 's':
+ (void) strlcpy(sfx, optarg, sizeof(sfx));
+ use_default_sfx = FALSE;
+ break;
+
+ case 'V':
+ show_version();
+ /* NOTREACHED */
- show_version();
- /* NOTREACHED */
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ argc -= optind;
+ argv += optind;
- } else if (strcasecmp(argv[1], "pmatch") == 0) {
+ if (use_default_sfx)
+ (void) snprintf(sfx, sizeof(sfx), "%s", DEFAULT_SFX);
+
+ if (strcasecmp(argv[0], "pmatch") == 0) {
char *pattern, *pkg;
- argv++; /* argv[0] */
argv++; /* "pmatch" */
pattern = argv[0];
@@ -368,14 +391,13 @@
return 1;
}
- } else if (strcasecmp(argv[1], "rebuild") == 0) {
+ } else if (strcasecmp(argv[0], "rebuild") == 0) {
rebuild();
printf("Done.\n");
- } else if (strcasecmp(argv[1], "check") == 0) {
+ } else if (strcasecmp(argv[0], "check") == 0) {
- argv++; /* argv[0] */
argv++; /* "check" */
if (*argv != NULL) {
@@ -429,10 +451,9 @@
}
printf("Done.\n");
- } else if (strcasecmp(argv[1], "lsall") == 0) {
+ } else if (strcasecmp(argv[0], "lsall") == 0) {
int saved_wd;
- argv++; /* argv[0] */
argv++; /* "lsall" */
/* preserve cwd */
@@ -449,7 +470,7 @@
dir = dirname_of(*argv);
basep = basename_of(*argv);
- snprintf(base, sizeof(base), "%s.t[bg]z", basep);
+ snprintf(base, sizeof(base), "%s%s", basep, sfx);
fchdir(saved_wd);
rc = chdir(dir);
@@ -467,10 +488,9 @@
close(saved_wd);
- } else if (strcasecmp(argv[1], "lsbest") == 0) {
+ } else if (strcasecmp(argv[0], "lsbest") == 0) {
int saved_wd;
- argv++; /* argv[0] */
argv++; /* "lsbest" */
/* preserve cwd */
@@ -488,7 +508,7 @@
dir = dirname_of(*argv);
basep = basename_of(*argv);
- snprintf(base, sizeof(base), "%s.t[bg]z", basep);
+ snprintf(base, sizeof(base), "%s%s", basep, sfx);
fchdir(saved_wd);
rc = chdir(dir);
@@ -508,15 +528,15 @@
close(saved_wd);
- } else if (strcasecmp(argv[1], "list") == 0 ||
- strcasecmp(argv[1], "dump") == 0) {
+ } else if (strcasecmp(argv[0], "list") == 0 ||
+ strcasecmp(argv[0], "dump") == 0) {
pkgdb_dump();
}
#ifdef PKGDB_DEBUG
- else if (strcasecmp(argv[1], "del") == 0 ||
- strcasecmp(argv[1], "delete") == 0) {
+ else if (strcasecmp(argv[0], "del") == 0 ||
+ strcasecmp(argv[0], "delete") == 0) {
int rc;
@@ -533,7 +553,7 @@
pkgdb_close();
- } else if (strcasecmp(argv[1], "add") == 0) {
+ } else if (strcasecmp(argv[0], "add") == 0) {
int rc;
@@ -568,7 +588,7 @@
void
usage(void)
{
- printf("usage: pkg_admin [-V] command args ...\n"
+ printf("usage: pkg_admin [-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 d8c4678fa384 -r 92c56221de02 usr.sbin/pkg_install/admin/pkg_admin.1
--- a/usr.sbin/pkg_install/admin/pkg_admin.1 Thu Jul 31 17:34:45 2003 +0000
+++ b/usr.sbin/pkg_install/admin/pkg_admin.1 Thu Jul 31 19:17:36 2003 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_admin.1,v 1.16.4.1 2003/07/13 09:45:22 jlam Exp $
+.\" $NetBSD: pkg_admin.1,v 1.16.4.2 2003/07/31 19:17:37 jlam Exp $
.\"
.\" Copyright (c) 1999-2002 Hubert Feyrer. All rights reserved.
.\"
@@ -37,6 +37,9 @@
.Sh SYNOPSIS
.Nm
.Op Fl V
+.Bk -words
+.Op Fl s Ar sfx_pattern
+.Ek
.Ar command Op args ...
.Sh DESCRIPTION
This command performs various administrative tasks around the
@@ -47,6 +50,13 @@
.Bl -tag -width check
.It Fl V
Print version number and exit.
+.It Fl s Ar sfx_pattern
+Set the shell glob pattern for package suffices when matching package
+names for
+.Cm lsall
+and
+.Cm lsbest .
+The default pattern is ".t[bg]z".
.It Cm check Op Ar pkg ...
Use this command to check the files belonging to some or all of the
packages installed on the local machine against their MD5 checksum
@@ -84,15 +94,15 @@
yui# ls unzip*
unzip-5.40.tgz unzip-5.41.tgz
yui# pkg_admin lsall 'unzip*'
-unzip-5.40.tgz
-unzip-5.41.tgz
+/usr/pkgsrc/packages/i386ELF/All/unzip-5.40.tgz
+/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz
yui# pkg_admin lsall 'unzip\*[Ge]5.40'
-unzip-5.40.tgz
-unzip-5.41.tgz
+/usr/pkgsrc/packages/i386ELF/All/unzip-5.40.tgz
+/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz
yui# pkg_admin lsall 'unzip\*[Ge]5.41'
-unzip-5.41.tgz
+/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz
yui# pkg_admin lsbest 'unzip\*[Ge]5.40'
-unzip-5.41.tgz
+/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz
yui# pkg_admin lsall /usr/pkgsrc/packages/i386ELF/All/'{mit,unproven}-pthread*'
/usr/pkgsrc/packages/i386ELF/All/mit-pthreads-1.60b6.tgz
/usr/pkgsrc/packages/i386ELF/All/unproven-pthreads-0.15.tgz
Home |
Main Index |
Thread Index |
Old Index