Date: Fri, 15 Jun 2007 06:33:58 GMT From: Ighighi <ighighi@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/113702: [PATCH]: bad output from "pkginfo -g" Message-ID: <200706150633.l5F6XwBe034996@www.freebsd.org> Resent-Message-ID: <200706150640.l5F6e1xq070704@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 113702 >Category: bin >Synopsis: [PATCH]: bad output from "pkginfo -g" >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jun 15 06:40:01 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Ighighi >Release: 6.2-STABLE >Organization: >Environment: FreeBSD orion 6.2-STABLE FreeBSD 6.2-STABLE #1: Tue Jun 12 20:39:04 VET 2007 root@orion:/usr/obj/usr/src/sys/CUSTOM i386 >Description: When multiple packages are processed by "pkginfo -g" to "show files that do not match the recorded checksum" and output is save to a file or to a pipe, error messages relative to a package are printed before the "Information for $PACKAGE:" line, thus confusing the user on the real package that is having problems. It doesn't happen when output is printed to a terminal because stdout is line-buffered in this case, else it is block buffered and any error messages could be written before the "Information for $PACKAGE:" line. The solution (contained in the attached patch) is an explicit fflush(stdout) after the printf() of the line above. There are 2 other functions that contains calls that print to stderr that I patched. The 3 modified functions are: show_index(), show_plist() & show_cksum() The file in question is src/usr.sbin/pkg_install/info/show.c Note: The very first function show_file() contains this line: printf("ERROR: show_file: Can't open '%s' for reading!\n", fname); Why not make most errors in this command print to stdout ? Anyway the attached patch preserves the current functionality (tested on 6.2-STABLE and -CURRENT) and just adds the fflush(stdout) after the information line for each package. >How-To-Repeat: # pkg_which /usr/local/lib/AbiWord-2.4/plugins/libAbiApplix.la abiword-plugins-2.4.6 # pkg_info -gx ^abiword Information for abiword-2.4.6: Mismatched Checksums: Information for abiword-plugins-2.4.6: Mismatched Checksums: pkg_info: /usr/local/lib/AbiWord-2.4/plugins/libAbiApplix.la doesn't exist pkg_info: /usr/local/lib/AbiWord-2.4/plugins/libAbiApplix.so doesn't exist # pkg_info -gx ^abiword >abiword.txt 2>&1 # cat abiword.txt pkg_info: /usr/local/lib/AbiWord-2.4/plugins/libAbiApplix.la doesn't exist pkg_info: /usr/local/lib/AbiWord-2.4/plugins/libAbiApplix.so doesn't exist Information for abiword-2.4.6: Mismatched Checksums: Information for abiword-plugins-2.4.6: Mismatched Checksums: >Fix: As root, download attached patch and run: patch -d /usr < /path/to/patch cd /usr/src/usr.sbin/pkg_install/info make clean make obj depend && make && make install Patch attached with submission follows: --- src/usr.sbin/pkg_install/info/show.c.orig Thu Feb 15 05:23:34 2007 +++ src/usr.sbin/pkg_install/info/show.c Fri Jun 15 02:15:47 2007 @@ -61,8 +61,11 @@ strlcpy(line, "???\n", sizeof(line)); - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } + fp = fopen(fname, "r"); if (fp == (FILE *) NULL) { warnx("show_file: can't open '%s' for reading", fname); @@ -88,8 +91,11 @@ Boolean ign = FALSE; char *prefix = NULL; - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } + p = plist->head; while (p) { if (p->type != type && showall != TRUE) { @@ -316,8 +322,10 @@ char *prefix = NULL; char tmp[FILENAME_MAX]; - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } for (p = plist->head; p != NULL; p = p->next) if (p->type == PLIST_CWD) { >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706150633.l5F6XwBe034996>