tech-pkg archive

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

pkg_chk likes obsolete packages



Hi,

I found that pkgtools/pkg_chk doesn't pay attention if available
binary package older than already installed one.  It results in
a weird attempt to install obsolete packages.  For example:

$ pkg_info -e R                                                                 
                                                                           
R-2.14.2
$ pkg_chk -C ./pkg_chk.conf -P /usr/pkgsrc/packages/All -ab
math/R - R-2.14.2 < R-2.14.0nb3 (binary package available)

I'd suggest the following fix to pkg_chk and bump its version to 2.1:

--- files/pkg_chk.sh    2009-12-10 15:19:42.000000000 +0200
+++ files/pkg_chk.sh    2012-07-19 01:16:58.000000000 +0300
@@ -57,21 +57,26 @@
            continue
        fi
        if [ ! -d $PKG_DBDIR/$PKGNAME ];then
-           msg_n "$pkgdir - "
            pkg=$(echo $PKGNAME | ${SED} 's/-[0-9].*//')
+           pkgmatch=$(echo $PKGNAME | ${SED} 's/-\([0-9].*\)/>=\1/')
            pkginstalled=$(sh -c "${PKG_INFO} -e $pkg" || true)
-           INSTALL=
-           if [ -n "$pkginstalled" ];then
-               msg_n "$pkginstalled < $PKGNAME"
-               MISMATCH_TODO="$MISMATCH_TODO $pkginstalled"
+           if ! ${PKG_ADMIN} pmatch "$pkgmatch" "$pkginstalled" ; then
+             msg_n "$pkgdir - "
+             INSTALL=
+             if [ -n "$pkginstalled" ];then
+                 msg_n "$pkginstalled < $PKGNAME"
+                 MISMATCH_TODO="$MISMATCH_TODO $pkginstalled"
+             else
+                 msg_n "$PKGNAME missing"
+                 MISSING_TODO="$MISSING_TODO $PKGNAME $pkgdir"
+             fi
+             if is_binary_available $PKGNAME ;then
+                 msg_n " (binary package available)"
+             fi
+             msg
            else
-               msg_n "$PKGNAME missing"
-               MISSING_TODO="$MISSING_TODO $PKGNAME $pkgdir"
+             verbose "$PKGNAME: OK"
            fi
-           if is_binary_available $PKGNAME ;then
-               msg_n " (binary package available)"
-           fi
-           msg
        else
            if [ -n "$opt_B" ];then
                # sort here temporarily to handle older +BUILD_VERSION
@@ -282,6 +287,8 @@
 
 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/|"
     }
 
^--- <don't miss the empty line with single space here>

--
Cheers,
Mishka.


Home | Main Index | Thread Index | Old Index