bin/87136: pkg_version exits if the INDEX file is not found

Seán Farley sean-freebsd at farley.org
Sat Oct 8 13:50:15 PDT 2005


>Number:         87136
>Category:       bin
>Synopsis:       pkg_version exits if the INDEX file is not found
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 08 20:50:13 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Seán 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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list