diff options
-rw-r--r-- | pkgtools/pkg_chk/Makefile | 4 | ||||
-rwxr-xr-x | pkgtools/pkg_chk/files/pkg_chk.sh | 159 |
2 files changed, 90 insertions, 73 deletions
diff --git a/pkgtools/pkg_chk/Makefile b/pkgtools/pkg_chk/Makefile index 563251f5212..35504de80bf 100644 --- a/pkgtools/pkg_chk/Makefile +++ b/pkgtools/pkg_chk/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.76 2012/05/13 13:43:59 abs Exp $ +# $NetBSD: Makefile,v 1.77 2012/07/29 17:31:11 abs Exp $ -DISTNAME= pkg_chk-2.0.1 +DISTNAME= pkg_chk-2.0.2 CATEGORIES= pkgtools MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/pkg_chk/files/pkg_chk.sh b/pkgtools/pkg_chk/files/pkg_chk.sh index 6774761e357..e3b49fe22d7 100755 --- a/pkgtools/pkg_chk/files/pkg_chk.sh +++ b/pkgtools/pkg_chk/files/pkg_chk.sh @@ -1,6 +1,6 @@ #!@SH@ -e # -# $Id: pkg_chk.sh,v 1.66 2012/05/13 13:43:59 abs Exp $ +# $Id: pkg_chk.sh,v 1.67 2012/07/29 17:31:11 abs Exp $ # # TODO: Make -g check dependencies and tsort # TODO: Make -g list user-installed packages first, followed by commented @@ -21,7 +21,7 @@ is_binary_available() return 0; ;; esac - done + done return 1; else if [ -f "$PACKAGES/$1$PKG_SUFX" ]; then @@ -35,7 +35,7 @@ is_binary_available() bin_pkg_info2pkgdb() { ${AWK} '/^PKGNAME=/ {sub("^PKGNAME=", ""); PKGNAME=$0} \ - /^PKGPATH=/ {sub("^PKGPATH=", ""); printf("%s:%s ", $0, PKGNAME)}' + /^PKGPATH=/ {sub("^PKGPATH=", ""); printf("%s:%s ", $0, PKGNAME)}' } check_packages_installed() @@ -53,23 +53,38 @@ check_packages_installed() PKGNAME=`pkgdir2pkgname $pkgdir` fi if [ -z "$PKGNAME" ]; then - MISS_DONE=$MISS_DONE" "$pkgdir + MISSING_DONE=$MISSING_DONE" "$pkgdir continue fi if [ ! -d $PKG_DBDIR/$PKGNAME ];then msg_n "$pkgdir - " pkg=$(echo $PKGNAME | ${SED} 's/-[0-9].*//') pkginstalled=$(sh -c "${PKG_INFO} -e $pkg" || true) - INSTALL= - if [ -n "$pkginstalled" ];then - msg_n "$pkginstalled < $PKGNAME" - MISMATCH_TODO="$MISMATCH_TODO $pkginstalled" - else + if [ -z "$pkginstalled" ];then msg_n "$PKGNAME missing" MISSING_TODO="$MISSING_TODO $PKGNAME $pkgdir" - fi - if is_binary_available $PKGNAME ;then - msg_n " (binary package available)" + else + pkgmatch=$(echo $PKGNAME | ${SED} 's/-\([0-9].*\)/>=\1/') + if ! ${PKG_ADMIN} pmatch "$pkgmatch" "$pkginstalled" ; then + INSTALL= + if [ -n "$pkginstalled" ];then + msg_n "$pkginstalled < $PKGNAME" + MISMATCH_TODO="$MISMATCH_TODO $pkginstalled" + else + msg_n "missing $PKGNAME" + MISSING_TODO="$MISSING_TODO $PKGNAME $pkgdir" + fi + else + if [ -n "$opt_B" ];then + msg_n "$pkginstalled > $PKGNAME" + MISMATCH_TODO="$MISMATCH_TODO $pkginstalled" + else + msg_n "$pkginstalled > $PKGNAME - ignoring" + fi + fi + if is_binary_available $PKGNAME ;then + msg_n " (has binary package)" + fi fi msg else @@ -282,6 +297,8 @@ get_build_ver() list_bin_pkgs () { + # XXX ls -t is usually enough to get newer packages first, but it + # depends on how files appeared in the $PACKAGES - beware ls -t $PACKAGES | grep "$PKG_SUFX_RE"'$' | ${SED} "s|^|$PACKAGES/|" } @@ -469,7 +486,7 @@ pkgdirs_from_conf() need = 1; } for (f = 2 ; f<=NF ; ++f) { # For each word on the line - if (sub("^-", "", $f)) { # If it begins with a '-' + if (sub("^-", "", $f)) { # If it begins with a '-' if (f == 2) # If first entry '-', assume '*' { need = 1; } if (and_expr_with_dict($f, taglist)) @@ -526,7 +543,7 @@ pkg_fetch() run_cmd "cd $PKGSRCDIR/$PKGDIR && ${MAKE} fetch-list | sh" if [ -n "$FAIL" ]; then - FAIL_DONE=$FAIL_DONE" "$PKGNAME + FAILED_DONE=$FAILED_DONE" "$PKGNAME else FETCH_DONE=$FETCH_DONE" "$PKGNAME fi @@ -569,7 +586,7 @@ pkg_install() fi if [ -n "$FAIL" ]; then - FAIL_DONE=$FAIL_DONE" "$PKGNAME + FAILED_DONE=$FAILED_DONE" "$PKGNAME else INSTALL_DONE=$INSTALL_DONE" "$PKGNAME fi @@ -603,15 +620,15 @@ run_cmd() sh -c "$1" || FAIL=1 fi if [ -n "$FAIL" ] ; then - msg "** '$1' failed" + msg "** '$1' failed" if [ -n "$opt_L" ] ; then tail -100 "$opt_L" | egrep -v '^(\*\*\* Error code 1|Stop\.)' |\ tail -40 fi - if [ "$FAILOK" != 1 ]; then - fatal "** '$1' failed" - fi - fi + if [ "$FAILOK" != 1 ]; then + fatal "** '$1' failed" + fi + fi fi } @@ -628,9 +645,8 @@ set_path() { arg=$1 case $arg in - http://*|ftp://*|/*) - echo $arg ;; - *) echo $basedir/$arg ;; + http://* | ftp://* | /*) echo $arg ;; + *) echo $basedir/$arg ;; esac } @@ -641,27 +657,27 @@ usage() echo fi echo 'Usage: pkg_chk [opts] - -a Add all missing packages - -B Check the "Build version" of packages - -b Use binary packages + -a Add all missing packages + -B Force exact pkg match - check "Build version" & even downgrade + -b Use binary packages -C conf Use pkgchk.conf file 'conf' -D tags Comma separated list of additional pkgchk.conf tags to set - -f Perform a 'make fetch' for all required packages - -g Generate an initial pkgchk.conf file - -h This help + -f Perform a 'make fetch' for all required packages + -g Generate an initial pkgchk.conf file + -h This help -k Continue with further packages if errors are encountered -L file Redirect output from commands run into file (should be fullpath) -l List binary packages including dependencies -N List installed packages for which a newer version is in TODO -n Display actions that would be taken, but do not perform them -p Display the list of pkgdirs that match the current tags - -P dir Set PACKAGES dir (overrides any other setting) + -P dir Set PACKAGES dir (overrides any other setting) -q Do not display actions or take any action; only list packages -r Recursively remove mismatches (use with care) - -s Use source for building packages + -s Use source for building packages -U tags Comma separated list of pkgchk.conf tags to unset ('*' for all) - -u Update all mismatched packages - -v Verbose + -u Update all mismatched packages + -v Verbose pkg_chk verifies installed packages against pkgsrc. The most common usage is 'pkg_chk -u -q' to check all installed packages or @@ -699,30 +715,30 @@ set -- $args set +o noglob while [ $# != 0 ]; do case "$1" in - -a ) opt_a=1 ;; - -B ) opt_B=1 ;; - -b ) opt_b=1 ;; - -C ) opt_C="$2" ; shift ;; - -c ) opt_a=1 ; opt_q=1 ; echo "-c is deprecated - use -a -q" ;; - -D ) opt_D="$2" ; shift ;; - -f ) opt_f=1 ;; - -g ) opt_g=1 ;; - -h ) opt_h=1 ;; - -i ) opt_u=1 ; opt_q=1 ; echo "-i is deprecated - use -u -q" ;; - -k ) opt_k=1 ;; - -L ) opt_L="$2" ; shift ;; - -l ) opt_l=1 ;; - -N ) opt_N=1 ;; - -n ) opt_n=1 ;; - -p ) opt_p=1 ;; - -P ) opt_P="$2" ; shift ;; - -q ) opt_q=1 ;; - -r ) opt_r=1 ;; - -s ) opt_s=1 ;; - -U ) opt_U="$2" ; shift ;; - -u ) opt_u=1 ;; - -v ) opt_v=1 ;; - -- ) shift; break ;; + -a ) opt_a=1 ;; + -B ) opt_B=1 ;; + -b ) opt_b=1 ;; + -C ) opt_C="$2" ; shift ;; + -c ) opt_a=1 ; opt_q=1 ; echo "-c is deprecated - use -a -q" ;; + -D ) opt_D="$2" ; shift ;; + -f ) opt_f=1 ;; + -g ) opt_g=1 ;; + -h ) opt_h=1 ;; + -i ) opt_u=1 ; opt_q=1 ; echo "-i is deprecated - use -u -q" ;; + -k ) opt_k=1 ;; + -L ) opt_L="$2" ; shift ;; + -l ) opt_l=1 ;; + -N ) opt_N=1 ;; + -n ) opt_n=1 ;; + -p ) opt_p=1 ;; + -P ) opt_P="$2" ; shift ;; + -q ) opt_q=1 ;; + -r ) opt_r=1 ;; + -s ) opt_s=1 ;; + -U ) opt_U="$2" ; shift ;; + -u ) opt_u=1 ;; + -v ) opt_v=1 ;; + -- ) shift; break ;; esac shift done @@ -748,13 +764,13 @@ fi saved_PKG_PATH=$PKG_PATH unset PKG_PATH || true -test -n "$AWK" || AWK="@AWK@" -test -n "$GREP" || GREP="@GREP@" +test -n "$AWK" || AWK="@AWK@" +test -n "$GREP" || GREP="@GREP@" test -n "$GZCAT" || GZCAT="@GZCAT@" test -n "$GZIP_CMD" || GZIP_CMD="@GZIP_CMD@" export GZIP_CMD -test -n "$ID" || ID="@ID@" -test -n "$MAKE" || MAKE="@MAKE@" +test -n "$ID" || ID="@ID@" +test -n "$MAKE" || MAKE="@MAKE@" test -n "$MAKECONF" || MAKECONF="@MAKECONF@" test -n "$MKTEMP" || MKTEMP="@MKTEMP@" test -n "$PKG_ADD" || PKG_ADD="@PKG_ADD@" @@ -762,7 +778,7 @@ test -n "$PKG_ADMIN" || PKG_ADMIN="@PKG_ADMIN@" test -n "$PKG_DBDIR" || PKG_DBDIR="@PKG_DBDIR@" test -n "$PKG_DELETE" || PKG_DELETE="@PKG_DELETE@" test -n "$PKG_INFO" || PKG_INFO="@PKG_INFO@" -test -n "$SED" || SED="@SED@" +test -n "$SED" || SED="@SED@" test -n "$SORT" || SORT="@SORT@" test -n "$TSORT" || TSORT="@TSORT@" test -n "$XARGS" || XARGS="@XARGS@" @@ -819,13 +835,13 @@ fi if [ -n "$opt_N" ]; then ${PKG_INFO} | \ - ${SED} -e "s/[ ].*//" -e "s/-[^-]*$//" \ + ${SED} -e "s/[ ].*//" -e "s/-[^-]*$//" \ -e "s/py[0-9][0-9]pth-/py-/" \ -e "s/py[0-9][0-9]-/py-/" | \ while read a do b=$(grep "o $a-[0-9]" $PKGSRCDIR/doc/TODO | \ - ${SED} -e "s/[ ]*o //") + ${SED} -e "s/[ ]*o //") if [ "$b" ] then echo $a: $b @@ -838,7 +854,7 @@ AWK_PARSE_SUMMARY='$1=="PKGNAME"{pkgname=$2} $1=="PKGPATH"{pkgpath=$2} NF==0{if if [ -n "$opt_b" -a -z "$opt_s" ] ; then case $PACKAGES in http://*|ftp://*) - PKGDB=`ftp -o - $PACKAGES/$SUMMARY_FILE | ${GZIP_CMD} -cd \ + PKGDB=`ftp -o - $PACKAGES/$SUMMARY_FILE | ${GZIP_CMD} -cd \ | ${AWK} -F= "$AWK_PARSE_SUMMARY"` if [ -z "$PKGDB" ] then @@ -852,13 +868,14 @@ if [ -n "$opt_b" -a -z "$opt_s" ] ; then esac fi -determine_tags - if [ -n "$opt_g" ]; then verbose "Write $PKGCHK_CONF based on installed packages" generate_conf_from_installed $PKGCHK_CONF + exit fi +determine_tags + if [ -n "$opt_r" -o -n "$opt_u" ];then verbose "Enumerate PKGDIRLIST from installed packages" PKGDIRLIST=$(pkgdirs_from_installed) @@ -927,15 +944,15 @@ if [ -n "$MISSING_TODO" ] ; then fi fi -if [ -n "$opt_u" -a -z "$FAIL_DONE" -a -f $PKGCHK_UPDATE_CONF ] ; then +if [ -n "$opt_u" -a -z "$FAILED_DONE" -a -f $PKGCHK_UPDATE_CONF ] ; then run_cmd "rm -f $PKGCHK_UPDATE_CONF" fi -[ -z "$MISS_DONE" ] || msg "Missing:$MISS_DONE" +[ -z "$MISSING_DONE" ] || msg "Missing:$MISSING_DONE" [ -z "$INSTALL_DONE" ] || msg "Installed:$INSTALL_DONE" -if [ -n "$FAIL_DONE" ] ; then - msg "Failed:$FAIL_DONE" +if [ -n "$FAILED_DONE" ] ; then + msg "Failed:$FAILED_DONE" cleanup_and_exit 1 fi |