From sean@farley.org  Sat Oct  8 20:41:26 2005
Return-Path: <sean@farley.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0504F16A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  8 Oct 2005 20:41:26 +0000 (GMT)
	(envelope-from sean@farley.org)
Received: from mail.farley.org (farley.org [67.64.95.201])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EEA8243D6D
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  8 Oct 2005 20:41:20 +0000 (GMT)
	(envelope-from sean@farley.org)
Received: from thor.farley.org (thor.farley.org [IPv6:2001:470:1f01:290:1::5])
	by mail.farley.org (8.13.1/8.13.1) with ESMTP id j98KgExB057010
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 8 Oct 2005 15:42:14 -0500 (CDT)
	(envelope-from sean@gw.farley.org)
Received: from thor.farley.org (localhost [127.0.0.1])
	by thor.farley.org (8.13.4/8.13.4) with ESMTP id j98KfjLt026830
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 8 Oct 2005 15:41:45 -0500 (CDT)
	(envelope-from sean@thor.farley.org)
Received: (from sean@localhost)
	by thor.farley.org (8.13.4/8.13.3/Submit) id j98Kfjg4026829;
	Sat, 8 Oct 2005 15:41:45 -0500 (CDT)
	(envelope-from sean)
Message-Id: <200510082041.j98Kfjg4026829@thor.farley.org>
Date: Sat, 8 Oct 2005 15:41:45 -0500 (CDT)
From: Sen Farley <sean-freebsd@farley.org>
Reply-To: Sen Farley <sean-freebsd@farley.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: pkg_version exits if the INDEX file is not found
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         87136
>Category:       bin
>Synopsis:       pkg_version exits if the INDEX file is not found
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    krion
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 08 20:50:13 GMT 2005
>Closed-Date:    Mon Oct 10 12:35:49 GMT 2005
>Last-Modified:  Mon Oct 10 12:35:49 GMT 2005
>Originator:     Sen Farley
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD thor.farley.org 5.4-STABLE FreeBSD 5.4-STABLE #0: Thu Sep 29 16:01:50 CDT 2005 root@thor.farley.org:/usr/obj/usr/src/sys/THOR i386

>Description:
pkg_version exits if the INDEX file is not found although the -I option,
which requires an INDEX file, was not given.

I need pkg_version to not exit for my port manager (found here:
http://www.farley.org/?page=software#pm) script to function correctly.

>How-To-Repeat:
Run pkg_version with an installed port that has been removed from
/usr/ports.

>Fix:
Here is a patch to not exit if the INDEX file is not found and -I is not
given.  The result is that the package will be listed with a '?' as if
it was not found within the INDEX file.

The patch with and without whitespace changes can be found here:
http://www.farley.org/freebsd/tmp/pkg_version.patch
http://www.farley.org/freebsd/tmp/pkg_version-nows.patch

diff -ruw /usr/src/usr.sbin/pkg_install/version/perform.c pkg_install/version/perform.c
--- /usr/src/usr.sbin/pkg_install/version/perform.c	Wed Jun 22 17:49:17 2005
+++ pkg_install/version/perform.c	Sat Oct  8 15:26:06 2005
@@ -157,6 +157,10 @@
 	}
     }
     if (latest == NULL) {
+	/* Report package as not found in INDEX if the INDEX is not required. */
+	if (IndexFile == NULL && !UseINDEXOnly)
+	    show_version(plist.name, NULL, plist.origin);
+	else {
 	/* We only pull in the INDEX once, if needed. */
 	if (SLIST_EMPTY(&Index)) {
 	    if (!IndexFile)
@@ -222,6 +226,7 @@
 	    show_version(plist.name, NULL, plist.origin);
 	else
 	    show_version(plist.name, latest, "index");
+	}
     }
     if (latest != NULL)
 	free(latest);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->krion 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Oct 8 20:58:00 GMT 2005 
Responsible-Changed-Why:  
krion has been looking after the pkg_* tools IIRC. 

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

From: Kirill Ponomarew <krion@voodoo.bawue.com>
To: bug-followup@FreeBSD.org
Cc: sean-freebsd@farley.org
Subject: Re: bin/87136: pkg_version exits if the INDEX file is not found
Date: Sun, 9 Oct 2005 20:03:22 +0200

 May I ask you if ever tried to compile pkg_install/version with this
 patch ?
 
 -Kirill

From: =?ISO-8859-1?Q?Se=E1n_C=2E_Farley?= <sean-freebsd@farley.org>
To: Kirill Ponomarew <krion@voodoo.bawue.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/87136: pkg_version exits if the INDEX file is not found
Date: Sun, 9 Oct 2005 14:32:39 -0500 (CDT)

   This message is in MIME format.  The first part should be readable text,
   while the remaining parts are likely unreadable without MIME-aware tools.
 
 --0-817020212-1128886359=:42133
 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: QUOTED-PRINTABLE
 
 On Sun, 9 Oct 2005, Kirill Ponomarew wrote:
 
 > May I ask you if ever tried to compile pkg_install/version with this
 > patch ?
 
 Both patches work (patch and compile) for me on FreeBSD 5-STABLE.  What
 problems are you seeing?  Sometimes send-pr is not kind with patches.
 Try them directly from my website.
 
 Se=E1n
 --=20
 sean-freebsd@farley.org
 --0-817020212-1128886359=:42133--

From: Kirill Ponomarew <krion@voodoo.bawue.com>
To: "Se?n C. Farley" <sean-freebsd@farley.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/87136: pkg_version exits if the INDEX file is not found
Date: Sun, 9 Oct 2005 21:46:53 +0200

 On Sun, Oct 09, 2005 at 02:32:39PM -0500, Se?n C. Farley wrote:
 > On Sun, 9 Oct 2005, Kirill Ponomarew wrote:
 > 
 > >May I ask you if ever tried to compile pkg_install/version with this
 > >patch ?
 > 
 > Both patches work (patch and compile) for me on FreeBSD 5-STABLE.  What
 > problems are you seeing?  Sometimes send-pr is not kind with patches.
 > Try them directly from my website.
 
 It shouldn't be GNATS problem:
 
 perform.c: In function `pkg_do':
 perform.c:170: error: incompatible type for argument 1 of `show_version'
 *** Error code 1
 
 Changing show_version(plist.name, NULL, plist.origin); to
 show_version(plist, NULL, plist.origin); fixes it.
 	     ^^^^^
 
 We have now in 6.x:
 
 static void show_version(Package, const char *, const char *);
 
 -Kirill

From: =?ISO-8859-1?Q?Se=E1n_C=2E_Farley?= <sean-freebsd@farley.org>
To: Kirill Ponomarew <krion@voodoo.bawue.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/87136: pkg_version exits if the INDEX file is not found
Date: Sun, 9 Oct 2005 19:41:33 -0500 (CDT)

   This message is in MIME format.  The first part should be readable text,
   while the remaining parts are likely unreadable without MIME-aware tools.
 
 --0-546913267-1128904893=:44926
 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: QUOTED-PRINTABLE
 
 On Sun, 9 Oct 2005, Kirill Ponomarew wrote:
 
 > On Sun, Oct 09, 2005 at 02:32:39PM -0500, Se?n C. Farley wrote:
 >> On Sun, 9 Oct 2005, Kirill Ponomarew wrote:
 >>
 >>> May I ask you if ever tried to compile pkg_install/version with this
 >>> patch ?
 >>
 >> Both patches work (patch and compile) for me on FreeBSD 5-STABLE.
 >> What problems are you seeing?  Sometimes send-pr is not kind with
 >> patches.  Try them directly from my website.
 >
 > It shouldn't be GNATS problem:
 >
 > perform.c: In function `pkg_do':
 > perform.c:170: error: incompatible type for argument 1 of `show_version'
 > *** Error code 1
 >
 > Changing show_version(plist.name, NULL, plist.origin); to
 > show_version(plist, NULL, plist.origin); fixes it.
 > =09     ^^^^^
 >
 > We have now in 6.x:
 >
 > static void show_version(Package, const char *, const char *);
 
 I see the problem.  I was on revision 1.10.4.1.  1.10.4.2, which you
 just checked into CVS changed from plist.name to plist.
 
 Se=E1n
 --=20
 sean-freebsd@farley.org
 --0-546913267-1128904893=:44926--
State-Changed-From-To: open->closed 
State-Changed-By: krion 
State-Changed-When: Mon Oct 10 12:35:39 GMT 2005 
State-Changed-Why:  
The proposed patch is committed, thanks! 

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