Subject: pkgtools/pkg_chk (1.83), pkgsrc-XXXXQY switches, "Failed: " wrong
To: None <>
From: Martin S. Weber <>
List: pkgsrc-users
Date: 04/16/2007 13:34:01

I've just noticed something that bugs me for the past few pkgsrc-XXXXQY
switches already and thought I finally write some mail :)

I've noticed that the output of pkg_chk at the end of the installation
sometimes is wrong when a dependant package was installed as dependancy.

I'm switching pkgsrc - branches like:

- update pkgsrc
- update pkgsrc/pkgtools/pkg_install and pkgsrc/pkgtools/pkg_chk
- run pkg_chk -g (create list of installed pkgs)
- run pkg_chk -r (removes mismatched and dependant pkgs)
- run pkg_chk -ask (add the stuff again by building from source)

the latter then, when done, outputs two lines like:
Installed: <list of packages>
Failed: <list of packages>

I keep though finding packages in "Failed" which actually were
installed. One example: freeciv-share.

(Here's an edited grep output from my build logfile)

games/freeciv-share - freeciv-share-2.0.9 missing  [1]
=> Required installed package freeciv-share>=2.0.9: NOT found [2]
=> Verifying update for ../../games/freeciv-share
===> Building for freeciv-share-2.0.9
===> Installing for freeciv-share-2.0.9
=> Registering installation for freeciv-share-2.0.9
freeciv-share-2.0.9 installed in previous stage  [3]

Failed: (...) freeciv-share-2.0.9 (...)

[1]: beginning of pkg_chk run, all ok (freeciv-share is missing)
[2]: Installation of freeciv-share as dep of freeciv-client
[3]: pkg_chk comes to freeciv-share, correctly notices it's built already.

So. Why is it in "Failed" now?

So I thought every "installed in previous stage" would end up
in "Failed", but it's not like that. One of the packages which were installed
already in previous stage is "curl", which doesn't end up in "Failed" though.

So I look at this snippet:

if [ -d $PKG_DBDIR/$PKGNAME ];then
	msg "$PKGNAME installed in previous stage"
elif [ -n "$opt_b" ] && is_binary_available $PKGNAME; then
elif [ -n "$opt_s" ]; then
    run_cmd "cd $PKGSRCDIR/$PKGDIR && ${MAKE} update CLEANDEPENDS=yes"

if [ -z "$opt_n" -a -z "$opt_q" -a ! -d $PKG_DBDIR/$PKGNAME ];then
if [ -n "$FAIL" ]; then

I've seen the msg "freeciv-share installed in previous stage", so
 -d $PKG_DBDIR/$PKGNAME is true.

For the pkg to show up in Failed, I obviously need to NOT give -n, -q
AND the pkg shouldn't be there. I haven't given -n or -q but then again,
the package was built already, and the last test should fail (as hinted
by the output: ... installed in previous stage).

What about:

--- /usr/pkg/sbin/pkg_chk       2007-04-15 11:05:57.000000000 +0200
+++ ./pkg_chk   2007-04-16 13:31:55.000000000 +0200
@@ -485,6 +485,8 @@
     if [ -d $PKG_DBDIR/$PKGNAME ];then
        msg "$PKGNAME installed in previous stage"
+       return
     elif [ -n "$opt_b" ] && is_binary_available $PKGNAME; then
        if [ -n "$saved_PKG_PATH" ] ; then
            export PKG_PATH=$saved_PKG_PATH

But I shouldn't be offering patches for situations I don't fully understand.
So: Why is e.g. freeciv-share ending up in "Failed" and e.g. curl isn't ??

Regards, clueless Martin