NetBSD Problem Report #30893

From lukem@mewburn.net  Tue Aug  2 11:43:25 2005
Return-Path: <lukem@mewburn.net>
Received: from home.mewburn.net (home.mewburn.net [150.101.166.131])
	by narn.netbsd.org (Postfix) with ESMTP id CC93663B400
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  2 Aug 2005 11:43:24 +0000 (UTC)
Message-Id: <20050802114318.34B842BDE2@home.mewburn.net>
Date: Tue,  2 Aug 2005 21:43:18 +1000 (EST)
From: lukem@NetBSD.org
Reply-To: lukem@NetBSD.org
To: gnats-bugs@netbsd.org
Subject: pkg_chk tag support needs work
X-Send-Pr-Version: 3.95

>Number:         30893
>Category:       pkg
>Synopsis:       pkg_chk tag support needs work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    abs
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 02 11:44:00 +0000 2005
>Last-Modified:  Thu Aug 04 19:59:16 +0000 2005
>Originator:     Luke Mewburn
>Release:        NetBSD 3.0_BETA
>Organization:
>Environment:
>Description:
	pkg_chk supports the ability to add and remove tags to the
	current machine's set [of tags] to control how entries
	will be matched from pkgchk.conf.

	There's two problems with this.

    1.	The tag "*" is documented to match any tag.
	However, invoking
		pkg_chk -D '*' ...
	or
		env PKGCHK_TAGS='*' pkgchk ...
	doesn't work due to the `*' being expanded by shell globbing.
	I have a patch to resolve this, converting pkg_chk to using
	getopts(1) instead of getopt(1).


    2.	Even when the tag parsing is fixed, the matching algorithm
	won't treat a `*' in the current machine's set as acting as
	"match every entry in pkgchk.conf".
	It seems that "*" is only supported as a tag on a filename
	within pkgchk.conf, which seems rather useless, since you
	can emulate "match all tags" by commenting out _all_ the
	tags in an entry (i.e, no tags == "all systems).

	The behaviour I think it should be is that providing '*'
	via -D or PKGCHK_TAGS says "match all entries in pkgchk.conf"



>How-To-Repeat:
	Setup pkgchk.conf with some entries containing tags
	that don't match the current machine.
	Invoke
		pkgchk -D '*' -cv
	and notice that those entries won't be checked.


>Fix:
	This patch fixes the first problem.
	The program's tag matching logic needs work to fix the second.


Index: files/pkg_chk.sh
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_chk/files/pkg_chk.sh,v
retrieving revision 1.16
diff -p -p -u -r1.16 pkg_chk.sh
--- files/pkg_chk.sh	1 Jun 2005 14:14:47 -0000	1.16
+++ files/pkg_chk.sh	2 Aug 2005 09:58:19 -0000
@@ -516,38 +516,32 @@ verbose()
     fi
     }

-args=$(getopt BC:D:L:P:U:abcfghiklNnrsuv $*)
-if [ $? != 0 ]; then
-    opt_h=1
-fi
-set -- $args
-while [ $# != 0 ]; do
-    case "$1" in
-	-a )	opt_a=1 ; opt_c=1 ;;
-	-B )    opt_B=1 ; opt_i=1 ;;
-	-b )	opt_b=1 ;;
-	-C )	opt_C="$2" ; shift;;
-	-c )	opt_c=1 ;;
-	-D )	opt_D="$2" ; shift;;
-	-f )	opt_f=1 ;;
-	-g )	opt_g=1 ;;
-	-h )	opt_h=1 ;;
-	-i )	opt_i=1 ;;
-	-k )	opt_k=1 ;;
-	-L )	opt_L="$2" ; shift;;
-	-l )	opt_l=1 ;;
-	-N )	opt_N=1 ;;
-	-n )	opt_n=1 ;;
-	-P )	opt_P="$2" ; shift;;
-	-r )	opt_r=1 ; opt_i=1 ;;
-	-s )	opt_s=1 ;;
-	-U )	opt_U="$2" ; shift;;
-	-u )	opt_u=1 ; opt_i=1 ;;
-	-v )	opt_v=1 ;;
-	-- )	shift; break ;;
+while getopts BC:D:L:P:U:abcfghiklNnrsuv ch; do
+    case "$ch" in
+	a )	opt_a=1 ; opt_c=1 ;;
+	B )	opt_B=1 ; opt_i=1 ;;
+	b )	opt_b=1 ;;
+	C )	opt_C="$OPTARG" ;;
+	c )	opt_c=1 ;;
+	D )	opt_D="$OPTARG" ;;
+	f )	opt_f=1 ;;
+	g )	opt_g=1 ;;
+	h | \?)	opt_h=1 ;;
+	i )	opt_i=1 ;;
+	k )	opt_k=1 ;;
+	L )	opt_L="$OPTARG" ;;
+	l )	opt_l=1 ;;
+	N )	opt_N=1 ;;
+	n )	opt_n=1 ;;
+	P )	opt_P="$OPTARG" ;;
+	r )	opt_r=1 ; opt_i=1 ;;
+	s )	opt_s=1 ;;
+	U )	opt_U="$OPTARG" ;;
+	u )	opt_u=1 ; opt_i=1 ;;
+	v )	opt_v=1 ;;
     esac
-    shift
 done
+shift $(($OPTIND - 1))

 if [ -z "$opt_b" -a -z "$opt_s" ];then
     opt_b=1; opt_s=1;

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->abs
Responsible-Changed-By: recht@netbsd.org
Responsible-Changed-When: Thu, 04 Aug 2005 19:59:16 +0000
Responsible-Changed-Why:
over to maintainer


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.