From Dom.Mitchell@palmerharvey.co.uk Mon Nov 29 03:55:53 1999
Return-Path: <Dom.Mitchell@palmerharvey.co.uk>
Received: from mail.palmerharvey.co.uk (mail.palmerharvey.co.uk [62.172.109.58])
	by hub.freebsd.org (Postfix) with ESMTP
	id DCB8B14A01; Mon, 29 Nov 1999 03:55:07 -0800 (PST)
	(envelope-from Dom.Mitchell@palmerharvey.co.uk)
Received: from ho-nt-01.pandhm.co.uk (unverified) by mail.palmerharvey.co.uk
 (Content Technologies SMTPRS 4.0.1) with ESMTP id <B3eac6d3a48cfd3a845@mail.palmerharvey.co.uk>;
 Mon, 29 Nov 1999 11:53:20 +0000
Received: from ADMIN ([10.100.1.20]) by ho-nt-01.pandhm.co.uk with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0)
	id XVAC4GK2; Mon, 29 Nov 1999 11:51:45 -0000
Received: from [10.100.35.12] (helo=voodoo.pandhm.co.uk)
	by admin with esmtp (Exim 1.92 #1)
	id 11sPOa-0006xS-00; Mon, 29 Nov 1999 11:55:04 +0000
Received: by voodoo.pandhm.co.uk (Postfix, from userid 104)
	id 1ED91211; Mon, 29 Nov 1999 11:55:03 +0000 (GMT)
Message-Id: <19991129115503.1ED91211@voodoo.pandhm.co.uk>
Date: Mon, 29 Nov 1999 11:55:03 +0000 (GMT)
From: Dom.Mitchell@palmerharvey.co.uk
Reply-To: dom@palmerharvey.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Cc: bmah@CS.Sandia.GOV, billf@FreeBSD.ORG
Subject: New option for pkg_version(1).
X-Send-Pr-Version: 3.2

>Number:         15162
>Category:       bin
>Synopsis:       New option for pkg_version(1).
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    billf
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 29 04:00:01 PST 1999
>Closed-Date:    Thu Dec 2 22:30:06 PST 1999
>Last-Modified:  Thu Dec  2 22:30:24 PST 1999
>Originator:     Dominic Mitchell
>Release:        FreeBSD 3.3-STABLE i386
>Organization:
Palmer & Harvey McLane Ltd.
>Environment:

FreeBSD voodoo.pandhm.co.uk 3.3-STABLE FreeBSD 3.3-STABLE #4: Thu Nov 18 09:01:45 GMT 1999     root@voodoo.pandhm.co.uk:/usr/src/sys/compile/VOODOO  i386

>Description:

	I thought it would be useful to limit the output of pkg_version
	to one or more matching status flags.  The attached patch
	implements this option.

	In particular, this lets get the commands to update merely the
	out of date ports with ease:

	% pkg_version -c -l '<'
#
#  less
#  needs updating (index has 340)
#
cd /usr/ports/misc/less
make
pkg_delete -f less-337
make install

#
#  vim
#  needs updating (index has 5.5.38)
#
cd /usr/ports/editors/vim5
make
pkg_delete -f vim-5.5.37
make install

>How-To-Repeat:

	Apply patch.

>Fix:
	
	Here's the patch:

diff -urP /usr/src/usr.sbin/pkg_install/version/pkg_version.1 version/pkg_version.1
--- /usr/src/usr.sbin/pkg_install/version/pkg_version.1	Fri Nov 26 22:04:49 1999
+++ version/pkg_version.1	Mon Nov 29 11:53:31 1999
@@ -33,6 +33,7 @@
 .Sh SYNOPSIS
 .Nm pkg_version
 .Op Fl cdhv
+.Op Fl l Ar limchar
 .Op Ar index
 .Sh DESCRIPTION
 The
@@ -75,6 +76,15 @@
 Enable debugging output.
 .It Fl h
 Print help message.
+.It Fl l
+Limit the output to those packages whose status flag matches
+.Ar limchar .
+You may specify more than one character to match in
+.Ar limchar .  
+Note that because some of the status flag characters are also special
+to the shell, it is best to quote
+.Ar limchar
+with single quotes.
 .It Fl v
 Enable verbose output.  Verbose output includes some English-text
 interpretations of the version number comparisons, as well as the
Binary files /usr/src/usr.sbin/pkg_install/version/pkg_version.1.gz and version/pkg_version.1.gz differ
diff -urP /usr/src/usr.sbin/pkg_install/version/pkg_version.pl version/pkg_version.pl
--- /usr/src/usr.sbin/pkg_install/version/pkg_version.pl	Fri Nov 26 22:04:49 1999
+++ version/pkg_version.pl	Mon Nov 29 11:37:24 1999
@@ -47,6 +47,7 @@
 $DebugFlag = 0;
 $VerboseFlag = 0;
 $CommentChar = "#";
+$LimitFlag = "";
 
 #
 # CompareVersions
@@ -124,6 +125,7 @@
 -c              Show commands to update installed packages
 -d debug	Debugging output (debug controls level of output)
 -h		Help (this message)
+-l limchar	Limit output
 -v		Verbose output
 index		URL or filename of index file
 		(Default is $IndexFile)
@@ -133,7 +135,7 @@
 #
 # Parse command-line arguments, deal with them
 #
-if (!getopts('cdhv') || ($opt_h)) {
+if (!getopts('cdhl:v') || ($opt_h)) {
     &PrintHelp();
     exit;
 }
@@ -143,6 +145,9 @@
 if ($opt_d) {
     $DebugFlag = $opt_d;
 }
+if ($opt_l) {
+    $LimitFlag = $opt_l;
+}
 if ($opt_v) {
     $VerboseFlag = 1;
 }
@@ -258,7 +263,11 @@
 	$Comment = "unknown in index";
     }
 
-    write;
+    if ($LimitFlag) {
+	write if $versionCode =~ m/[$LimitFlag]/o;
+    } else {
+	write;
+    }
 }
 
 exit 0;


-- 
**********************************************************************
This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. 
The email has been swept by MIMEsweeper for the presence of computer viruses.

www.palmerharvey.co.uk
**********************************************************************

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->billf 
Responsible-Changed-By: billf 
Responsible-Changed-When: Mon Nov 29 10:41:10 PST 1999 
Responsible-Changed-Why:  
I'm the proxy between the author and the repository, I'll wait 
for his review of the patch. 
State-Changed-From-To: open->closed 
State-Changed-By: billf 
State-Changed-When: Thu Dec 2 22:30:06 PST 1999 
State-Changed-Why:  
Committed and merged, thanks 
>Unformatted:
