pkgsrc-Bugs archive

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

pkg/35026: new option for pkg_chk for using SU_CMD from mk.conf



>Number:         35026
>Category:       pkg
>Synopsis:       new option for pkg_chk for using SU_CMD from mk.conf
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 09 19:45:00 +0000 2006
>Originator:     Aleksey Cheusov <cheusov%tut.by@localhost>
>Release:        NetBSD 3.1.0_PATCH
>Organization:
Best regards, Aleksey Cheusov.
>Environment:
System: NetBSD chen.chizhovka.net 3.1.0_PATCH NetBSD 3.1.0_PATCH (GENERIC) #4: 
Sun Nov 5 01:36:02 EET 2006 
cheusov%chen.chizhovka.net@localhost:/srv/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
By default pkg_chk runs plain pkg_add and pkg_delete commands and therefore
pkg_chk -[ua] cannot work with ordinary user (not root).
The attached patch adds -S option to pkg_chk for using SU_CMD variable
set in /etc/mk.conf file. In my view it is more convenient than 
setting PKG_ADD and PKG_DELETE
environment variables (not documented in man page)
>Fix:
? README.html
? pkg_chk__SU_CMD.patch
? pkg_chk__tbz.patch
Index: files/pkg_chk.sh
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_chk/files/pkg_chk.sh,v
retrieving revision 1.42
diff -u -r1.42 pkg_chk.sh
--- files/pkg_chk.sh    20 Sep 2006 21:54:13 -0000      1.42
+++ files/pkg_chk.sh    4 Nov 2006 20:52:12 -0000
@@ -97,7 +97,7 @@
     {
     for pkg in $* ; do
        if [ -d $PKG_DBDIR/$pkg ] ; then
-           run_cmd "${PKG_DELETE} -r $pkg" 1
+           run_cmd_su "${PKG_DELETE} -r $pkg" 1
        fi
     done
     }
@@ -175,7 +175,8 @@
        cd $PKGSRCDIR/pkgtools/pkg_chk
        extract_make_vars Makefile AWK GREP GZIP_CMD SED SORT TSORT PACKAGES \
                        PKG_ADD PKG_DELETE PKG_INFO PKG_DBDIR PKGCHK_CONF \
-                       PKGCHK_UPDATE_CONF PKGCHK_TAGS PKGCHK_NOTAGS PKG_SUFX
+                       PKGCHK_UPDATE_CONF PKGCHK_TAGS PKGCHK_NOTAGS \
+                       PKG_SUFX SU_CMD
        if [ -z "$PACKAGES" ];then
            PACKAGES=$PKGSRCDIR/packages
        fi
@@ -477,7 +478,7 @@
        if [ -n "$saved_PKG_PATH" ] ; then
            export PKG_PATH=$saved_PKG_PATH
        fi
-       run_cmd "${PKG_ADD} $PACKAGES/$PKGNAME$PKG_SUFX"
+       run_cmd_su "${PKG_ADD} $PACKAGES/$PKGNAME$PKG_SUFX"
        if [ -n "$saved_PKG_PATH" ] ; then
            unset PKG_PATH
        fi
@@ -536,6 +537,15 @@
     fi
     }
 
+run_cmd_su()
+    {
+    if [ -n "$SU_CMD" ]; then
+       run_cmd "${SU_CMD} '$1'" "$2"
+    else
+       run_cmd "$1" "$2"
+    fi
+    }
+
 set_path()
     {
     arg=$1
@@ -570,6 +580,7 @@
        -q      Do not display actions or take any action; only list packages
        -r      Recursively remove mismatches (use with care) (implies -i)
        -s      Use source for building packages
+       -S      Prepand pkg_add/pkg_delete with $SU_CMD obtained from mk.conf
        -U tags Comma separated list of pkgchk.conf tags to unset
        -u      Update all mismatched packages (implies -i)
        -v      Verbose
@@ -630,6 +641,7 @@
        -U )    opt_U="$2" ; shift ;;
        -u )    opt_u=1 ;;
        -v )    opt_v=1 ;;
+       -S )    opt_S=1 ;;
        -- )    shift; break ;;
     esac
     shift
@@ -709,6 +721,10 @@
     PACKAGES="$PACKAGES/All"
 fi
 
+if [ -z "$opt_S" ] ; then
+    SU_CMD=
+fi
+
 if [ -n "$opt_N" ]; then
        ${PKG_INFO} | \
                ${SED} -e "s/[  ].*//" -e "s/-[^-]*$//" \




Home | Main Index | Thread Index | Old Index