From roam@orbitel.bg  Tue Sep 26 11:19:39 2000
Return-Path: <roam@orbitel.bg>
Received: from sentinel.office1.bg (sentinel.office1.bg [195.24.48.182])
	by hub.freebsd.org (Postfix) with SMTP id 7498237B424
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Sep 2000 11:19:25 -0700 (PDT)
Received: (qmail 420 invoked by uid 1001); 26 Sep 2000 18:19:17 -0000
Message-Id: <20000926181917.419.qmail@ringwraith.office1>
Date: 26 Sep 2000 18:19:17 -0000
From: "Peter Pentchev" <roam@orbitel.bg>
Reply-To: "Peter Pentchev" <roam@orbitel.bg>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [PATCH] pkg_version -v confuzzled by multiple versions
X-Send-Pr-Version: 3.2

>Number:         21567
>Category:       bin
>Synopsis:       [PATCH] pkg_version -v confuzzled by multiple versions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bmah
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 26 11:20:01 PDT 2000
>Closed-Date:    Wed Oct 25 14:36:54 PDT 2000
>Last-Modified:  Wed Oct 25 14:38:30 PDT 2000
>Originator:     "Peter Pentchev" <roam@orbitel.bg>
>Release:        FreeBSD 4.1.1-STABLE i386
>Organization:
Orbitel JSCo.
>Environment:

a RELENG_4 as of today

>Description:

When there are multiple versions of a package in the INDEX file,
pkg_version does not even try to check if you have one of the listed
versions (which would theoretically imply no need for upgrade).

Attached is a proposed patch to add a -m option, which checks if
the installed version is amongst the versions in the package, and if so,
reports it as "up-to-date (index has .....)".

Note: this functionality is ONLY explicitly enabled by specifying the -m
option on the command line; the default action is still to report the package
as '*' (multiple versions), so existing grep -v up-to-date scripts do not
break.

>How-To-Repeat:

Install e.g. vim or XFree86; run pkg_version -v; see it not attempt to
give any judgement on the package.

With the proposed patch, pkg_version -vm lists it as up-to-date.

>Fix:

diff -urN src/usr.sbin/pkg_install/version/pkg_version.1 mysrc/usr.sbin/pkg_install/version/pkg_version.1
--- src/usr.sbin/pkg_install/version/pkg_version.1	Wed Sep 20 15:15:53 2000
+++ mysrc/usr.sbin/pkg_install/version/pkg_version.1	Thu Sep 21 21:15:37 2000
@@ -32,7 +32,7 @@
 .Nd summarize installed versions of packages
 .Sh SYNOPSIS
 .Nm pkg_version
-.Op Fl cdhv
+.Op Fl cdhmv
 .Op Fl l Ar limchar
 .Op Ar index
 .Sh DESCRIPTION
@@ -93,6 +93,9 @@
 to the shell, it is best to quote
 .Ar limchar
 with single quotes.
+.It Fl m
+Even if multiple versions are present, report a match if the installed
+version is among those in the INDEX.
 .It Fl v
 Enable verbose output.  Verbose output includes some English-text
 interpretations of the version number comparisons, as well as the
diff -urN src/usr.sbin/pkg_install/version/pkg_version.pl mysrc/usr.sbin/pkg_install/version/pkg_version.pl
--- src/usr.sbin/pkg_install/version/pkg_version.pl	Wed Sep 20 15:15:53 2000
+++ mysrc/usr.sbin/pkg_install/version/pkg_version.pl	Thu Sep 21 21:14:07 2000
@@ -48,6 +48,7 @@
 $VerboseFlag = 0;
 $CommentChar = "#";
 $LimitFlag = "";
+$MultipleFlag = 0;
 
 #
 # CompareNumbers
@@ -206,7 +207,7 @@
 #
 # Parse command-line arguments, deal with them
 #
-if (!getopts('cdhl:v') || ($opt_h)) {
+if (!getopts('cdhl:mv') || ($opt_h)) {
     &PrintHelp();
     exit;
 }
@@ -219,6 +220,9 @@
 if ($opt_l) {
     $LimitFlag = $opt_l;
 }
+if ($opt_m) {
+    $MultipleFlag = 1;
+}
 if ($opt_v) {
     $VerboseFlag = 1;
 }
@@ -309,6 +313,17 @@
 	    $versionCode = "*";
 	    $Comment = "multiple versions (index has $indexVersion)";
 	    $Comment =~ s/\|/,/g;
+
+	    if ($MultipleFlag) {
+		@iVer = split(/\|/, $indexVersion);
+		foreach $ver (@iVer) {
+		    if (&CompareVersions($currentVersion, $ver) == 0) {
+			$versionCode = "=";
+			$Comment = "up-to-date (index has $indexVersion)";
+			$Comment =~ s/\|/,/g;
+		    }
+		}
+	    }
 	}
 	else {
 

>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@orbitel.bg>
To: FreeBSD-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/21567: [PATCH] pkg_version -v confuzzled by multiple versions
Date: Wed, 27 Sep 2000 12:00:59 +0300

 Hmmm as nbm suggested in a -ports discussion, this PR only does a small
 amount of the work needed on pkg_version; guess it can be closed, or maybe
 left open as a reminder for all of you pkg_install people :P
 
 G'luck,
 Peter
 
 -- 
 Hey, out there - is it *you* reading me, or is it someone else?
 
Responsible-Changed-From-To: freebsd-bugs->bmah 
Responsible-Changed-By: bmah 
Responsible-Changed-When: Mon Oct 2 13:31:44 PDT 2000 
Responsible-Changed-Why:  
This isn't quite the right answer, but so many people have asked 
for some sort of solution to this problem that I'll grab the 
PR as a reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21567 
State-Changed-From-To: open->closed 
State-Changed-By: bmah 
State-Changed-When: Wed Oct 25 14:36:54 PDT 2000 
State-Changed-Why:  
I've committed a more workable solution to -CURRENT, relying 
on some other Ports Tree infrastructure enhancements by sobomax. 
Thanks for submitting your code though! 

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