From pirzyk@home.pirzyk.org  Thu Apr 26 16:38:41 2012
Return-Path: <pirzyk@home.pirzyk.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 25C5C106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Apr 2012 16:38:41 +0000 (UTC)
	(envelope-from pirzyk@home.pirzyk.org)
Received: from mail.vagrantaristocrat.net (mail.vagrantaristocrat.net [50.56.204.87])
	by mx1.freebsd.org (Postfix) with ESMTP id EA62F8FC12
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Apr 2012 16:38:40 +0000 (UTC)
Received: from 209-6-36-209.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.36.209]:56059 helo=amigo.home.pirzyk.org)
	by hargrave.vagrantaristocrat.net with esmtpsa (TLSv1:AES256-SHA:256)
	(Exim 4.77)
	(envelope-from <pirzyk@home.pirzyk.org>)
	id 1SNR0m-00046O-9m
	for FreeBSD-gnats-submit@freebsd.org; Thu, 26 Apr 2012 10:53:40 -0500
Received: from freebsd.home.pirzyk.org (freebsd.home.pirzyk.org [192.168.1.4])
	by amigo.home.pirzyk.org (8.14.4/8.14.4) with ESMTP id q3QFrcZa044089
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 26 Apr 2012 11:53:38 -0400 (EDT)
	(envelope-from pirzyk@freebsd.home.pirzyk.org)
Received: (from pirzyk@localhost)
	by freebsd.home.pirzyk.org (8.14.5/8.14.5/Submit) id q3QFrchr013728;
	Thu, 26 Apr 2012 11:53:38 -0400 (EDT)
	(envelope-from pirzyk)
Message-Id: <201204261553.q3QFrchr013728@freebsd.home.pirzyk.org>
Date: Thu, 26 Apr 2012 11:53:38 -0400 (EDT)
From: Jim Pirzyk <pirzyk@freebsd.org>
Reply-To: Jim Pirzyk <pirzyk@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: pkg_info can't determine what package a missing file is related to
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         167336
>Category:       bin
>Synopsis:       pkg_info(1) can't determine what package a missing file is related to
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 26 16:40:10 UTC 2012
>Closed-Date:    Sun Apr 20 00:13:36 UTC 2014
>Last-Modified:  Sun Apr 20 00:13:36 UTC 2014
>Originator:     Jim Pirzyk
>Release:        FreeBSD 9.0-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD freebsd.home.pirzyk.org 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64

>Description:
	Can't programmatically determine the package that is related to the 'pkg_info -g' output like:

/usr/local/foo/bar/baz.txt doesn't exist

	This is because the "doesn't exist" line was written out using STDERR whereas the lines:

Information for pkg-1.2.3:

	was written out using STDOUT.  If you combine the output streams in a perl script ala:

open ($FP, "/usr/sbin/pkg_info -a -g 2>&1 |" ) ...

	then the order is undefined and you can't associate the "doesn't exist" line with the "Information for" line.
	Furthermore if you try to use the -W option on pkg_info, it does not process the file and just gives you the error:

pkg_info: /usr/local/foo/bar/baz.txt: file cannot be found

>How-To-Repeat:
	Remove a file from a package and then run:

pkg_info -a -g | cat

	and try to determine which package the missing file is from.  Then run:

pkg_info -W <DELETED_FILE>

>Fix:

--- ./pkg_install/info/show.c.orig	2012-01-02 22:25:51.000000000 -0500
+++ ./pkg_install/info/show.c	2012-04-26 11:21:58.039342463 -0400
@@ -330,7 +330,7 @@
 	} else if (p->type == PLIST_FILE) {
 	    snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name);
 	    if (!fexists(tmp))
-		warnx("%s doesn't exist", tmp);
+		printf("%s doesn't exist\n", tmp);
 	    else if (p->next && p->next->type == PLIST_COMMENT &&
 	             (strncmp(p->next->name, "MD5:", 4) == 0)) {
 		char *cp = NULL, buf[33];
--- ./pkg_install/info/perform.c.orig	2012-01-02 22:25:51.000000000 -0500
+++ ./pkg_install/info/perform.c	2012-04-26 11:44:29.951086716 -0400
@@ -359,8 +359,6 @@
 	    }
 	    free(tmp);
 	}
-	if (wp->skip == TRUE)
-	    warnx("%s: %s", wp->file, msg);
     }
 
     installed = matchinstalled(MATCH_ALL, NULL, &errcode);
@@ -390,8 +388,6 @@
 		cwd = itr->name;
 	    } else if (itr->type == PLIST_FILE) {
 		TAILQ_FOREACH(wp, which_list, next) {
-		    if (wp->skip == TRUE)
-			continue;
 		    if (!cmp_path(wp->file, itr->name, cwd))
 			continue;
 		    if (wp->package[0] != '\0') {


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->portmgr 
Responsible-Changed-By: miwi 
Responsible-Changed-When: Thu May 17 15:41:39 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167336 

From: Baptiste Daroussin <bapt@freebsd.org>
To: bug-followup@freebsd.org, pirzyk@freebsd.org
Cc:  
Subject: Re: bin/167336: pkg_info can&#39;t determine what package a missing
 file is related to
Date: Wed, 19 Sep 2012 00:29:35 +0200

 Should be fixed in current another way
 now stdout is flushed  so that if you 2>&1 the order is predictable
 
 Does that do the trick for you?
 
 regards,
 Bapt
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sun Apr 20 00:12:27 UTC 2014 
State-Changed-Why:  
19 Sep 2012 email from bapt states that it has been fixed a different way. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167336 
>Unformatted:
