Add a -q switch to pkg_admin, which allows it to work in a quiet manner.

Fixes the change request in PR 26583, but in a different manner,
preserving existing behaviour and making the new behaviour dependent
upon a command line option.
This commit is contained in:
agc 2004-08-13 13:28:46 +00:00
parent d91b03bd13
commit 50a555ad6a
2 changed files with 33 additions and 11 deletions

View File

@ -1,8 +1,8 @@
/* $NetBSD: main.c,v 1.44 2004/05/10 19:59:59 kleink Exp $ */
/* $NetBSD: main.c,v 1.45 2004/08/13 13:28:46 agc Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: main.c,v 1.44 2004/05/10 19:59:59 kleink Exp $");
__RCSID("$NetBSD: main.c,v 1.45 2004/08/13 13:28:46 agc Exp $");
#endif
/*
@ -49,18 +49,20 @@ __RCSID("$NetBSD: main.c,v 1.44 2004/05/10 19:59:59 kleink Exp $");
#define DEFAULT_SFX ".t[bg]z" /* default suffix for ls{all,best} */
static const char Options[] = "K:SVbd:s:";
static const char Options[] = "K:SVbd:qs:";
int filecnt;
int pkgcnt;
static int quiet;
static int checkpattern_fn(const char *, void *);
/* print usage message and exit */
static void
usage(const char *prog)
{
(void) fprintf(stderr, "usage: %s [-b] [-d lsdir] [-V] [-s sfx] command args ...\n"
(void) fprintf(stderr, "usage: %s [-b] [-d lsdir] [-V] [-q] [-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"
@ -321,7 +323,9 @@ rebuild(void)
#ifdef PKGDB_DEBUG
printf("%s\n", de->d_name);
#else
printf(".");
if (!quiet) {
printf(".");
}
#endif
filecnt += add1pkg(de->d_name);
@ -363,7 +367,9 @@ checkall(void)
chdir(de->d_name);
check1pkg(de->d_name);
printf(".");
if (!quiet) {
printf(".");
}
chdir("..");
}
@ -387,7 +393,9 @@ checkpattern_fn(const char *pkg, void *vp)
err(EXIT_FAILURE, "Cannot chdir to %s/%s", _pkgdb_getPKGDB_DIR(), pkg);
check1pkg(pkg);
printf(".");
if (!quiet) {
printf(".");
}
chdir("..");
@ -449,6 +457,10 @@ main(int argc, char *argv[])
lsdirp = lsdir;
break;
case 'q':
quiet = 1;
break;
case 's':
(void) strlcpy(sfx, optarg, sizeof(sfx));
use_default_sfx = FALSE;
@ -530,7 +542,9 @@ main(int argc, char *argv[])
}
} else {
check1pkg(*argv);
printf(".");
if (!quiet) {
printf(".");
}
chdir("..");
}
@ -546,7 +560,9 @@ main(int argc, char *argv[])
} else {
checkall();
}
printf("Done.\n");
if (!quiet) {
printf("Done.\n");
}
} else if (strcasecmp(argv[0], "lsall") == 0) {
int saved_wd;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pkg_admin.1,v 1.30 2004/02/13 17:56:18 wiz Exp $
.\" $NetBSD: pkg_admin.1,v 1.31 2004/08/13 13:28:46 agc Exp $
.\"
.\" Copyright (c) 1999-2002 Hubert Feyrer. All rights reserved.
.\"
@ -36,7 +36,7 @@
.Nd perform various administrative tasks to the pkg system
.Sh SYNOPSIS
.Nm
.Op Fl bSV
.Op Fl bSVq
.Nb -words
.Op Fl d Ar lsdir
.Bk -words
@ -74,6 +74,12 @@ taken from the value of the environment variable
.Ev PKG_DBDIR
if it's set, otherwise it defaults to
.Pa /var/db/pkg .
.It Fl q
Perform checks in a quiet manner.
In normal operation,
.Nm
prints a '.' to standard output to indicate progress.
This option suppresses this progress indicator.
.It Fl S
Set the shell glob pattern for package suffixes when matching package
names for