pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/30893: pkg_chk tag support needs work



>Number:         30893
>Category:       pkg
>Synopsis:       pkg_chk tag support needs work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 02 11:44:00 +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;




Home | Main Index | Thread Index | Old Index