Bug 15162

Summary: New option for pkg_version(1).
Product: Base System Reporter: Dom Mitchell <Dom.Mitchell>
Component: binAssignee: bill fumerola <billf>
Status: Closed FIXED    
Severity: Affects Only Me CC: bmah
Priority: Normal    
Version: 3.3-STABLE   
Hardware: Any   
OS: Any   

Description Dom Mitchell 1999-11-29 12:00:01 UTC
	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

Fix: Here's the patch:



-- 
**********************************************************************
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
**********************************************************************--49LbopeVTntTRl9oO3yANRsJTrggz4mbQVYaGMMTSmgbzF3N
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

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;
How-To-Repeat: 
	Apply patch.
Comment 1 bill fumerola freebsd_committer freebsd_triage 1999-11-29 18:41:10 UTC
Responsible Changed
From-To: freebsd-bugs->billf

I'm the proxy between the author and the repository, I'll wait 
for his review of the patch. 
Comment 2 bill fumerola freebsd_committer freebsd_triage 1999-12-03 06:30:06 UTC
State Changed
From-To: open->closed

Committed and merged, thanks