Subject: pkg/26583: "pkg_admin check" should be less verbose
To: None <gnats-bugs@gnats.netbsd.org>
From: Roland Illig <roland.illig@gmx.de>
List: pkgsrc-bugs
Date: 08/07/2004 18:08:56
>Number:         26583
>Category:       pkg
>Synopsis:       "pkg_admin check" should be less verbose
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 07 16:39:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Roland Illig
>Release:        
>Organization:
>Environment:
System: Linux wwid 2.4.22-1-k7 #5 Sat Oct 4 14:11:12 EST 2003 i686 GNU/Linux
Architecture: i686

	
>Description:
"pkg_admin check" outputs lots of dots when processing the installed
packages. I find this looks ugly. :)
	
>How-To-Repeat:
$ pkg_admin check
>Fix:
--- pkgtools/pkg_install/files/admin/main.c	6 Aug 2004 16:57:03 -0000	1.15
+++ pkgtools/pkg_install/files/admin/main.c	7 Aug 2004 16:02:09 -0000
@@ -73,18 +73,20 @@
 
 #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:s:v";
 
 int     filecnt;
 int     pkgcnt;
 
+static int verbose_flag = FALSE;
+
 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] [-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"
@@ -345,7 +347,9 @@
 #ifdef PKGDB_DEBUG
 		printf("%s\n", de->d_name);
 #else
-		printf(".");
+		if (verbose_flag) {
+			printf(".");
+		}
 #endif
 
 		filecnt += add1pkg(de->d_name);
@@ -387,7 +391,9 @@
 		chdir(de->d_name);
 
 		check1pkg(de->d_name);
-		printf(".");
+		if (verbose_flag) {
+			printf(".");
+		}
 
 		chdir("..");
 	}
@@ -395,7 +401,9 @@
 	pkgdb_close();
 
 
-	printf("\n");
+	if (verbose_flag) {
+		printf("\n");
+	}
 	printf("Checked %d file%s from %d package%s.\n",
 	    filecnt, (filecnt == 1) ? "" : "s",
 	    pkgcnt, (pkgcnt == 1) ? "" : "s");
@@ -411,7 +419,9 @@
 		err(EXIT_FAILURE, "Cannot chdir to %s/%s", _pkgdb_getPKGDB_DIR(), pkg);
 
 	check1pkg(pkg);
-	printf(".");
+	if (verbose_flag) {
+		printf(".");
+	}
 
 	chdir("..");
 
@@ -478,6 +488,10 @@
 			use_default_sfx = FALSE;
 			break;
 
+		case 'v':
+			verbose_flag = TRUE;
+			break;
+
 		default:
 			usage(prog);
 			/* NOTREACHED */
@@ -554,7 +568,9 @@
 						}
 					} else {
 						check1pkg(*argv);
-						printf(".");
+						if (verbose_flag) {
+							printf(".");
+						}
 
 						chdir("..");
 					}
@@ -563,14 +579,18 @@
 				argv++;
 			}
 
-			printf("\n");
+			if (verbose_flag) {
+				printf("\n");
+			}
 			printf("Checked %d file%s from %d package%s.\n",
 			    filecnt, (filecnt == 1) ? "" : "s",
 			    pkgcnt, (pkgcnt == 1) ? "" : "s");
 		} else {
 			checkall();
 		}
-		printf("Done.\n");
+		if (verbose_flag) {
+			printf("Done.\n");
+		}
 
 	} else if (strcasecmp(argv[0], "lsall") == 0) {
 		int saved_wd;
>Release-Note:
>Audit-Trail:
>Unformatted: