Subject: Re: problem finding libz
To: Todd Vierling <tv@duh.org>
From: Georg Schwarz <geos@epost.de>
List: tech-pkg
Date: 10/17/2004 00:22:35
> Hm.  Was your pkgsrc/mk/* all up to date when zlib was built?  It seems like
> the LIBTOOLIZE_PLIST logic didn't work when you built/installed zlib.

yes, and the reason goes as follows:

mk/scripts/print-la-libnames contains

: ${ECHO=echo}
: ${GREP=grep}
: ${SORT=sort}

This is supposed to set ${GREP} to grep only if it has not been defined
before as it should. The IRIX 5.3 grep in my path does not support a -q
option (and a few other things) so I have ${GREP} set to point to a locally
installed GNU grep (which is not in the shell path though).
Nevertheless mk/scripts/print-la-libnames fails with
UX:grep: ERROR: Illegal option -- q
i.e. not GNU grep but the system grep is being used.

I changed mk/bsd.pkg.mk as follows (please not that the occurrence of
grep was corrected into ${GREP}, but should not be related to this
problem):

--- bsd.pkg.mk.orig     2004-10-16 18:34:50.000000000 +0200
+++ bsd.pkg.mk  2004-10-17 00:12:51.000000000 +0200
@@ -3466,7 +3466,7 @@
 ${DLIST}: ${WRKDIR}
        ${_PKG_SILENT}${_PKG_DEBUG}                                     \
        { ${PKG_DELETE} -n "${PKGWILDCARD}" 2>&1 |                      \
-               grep '^ ' |                                             \
+               ${GREP} '^      ' |                                             \
                ${AWK} '{ l[NR]=$$0 } END { for (i=NR;i>0;--i) print l[i] }' \
        || ${TRUE}; } > ${DLIST}
 
@@ -4499,7 +4499,8 @@
          while read file; do                                           \
                case $$file in                                          \
                *.la)                                                   \
-                       ${SH} ${_PRINT_LA_LIBNAMES} $$file >> $$libslist; \
+                       ${SETENV} ECHO=${ECHO} GREP=${GREP}             \
+        SORT=${SORT} ${SH} ${_PRINT_LA_LIBNAMES} $$file >> $$libslist; \
                        ;;                                              \
                esac;                                                   \
                ${ECHO} "$$file";                                       \
@@ -4960,7 +4961,8 @@
 .else
 _PLIST_AWK_LIBTOOL?=                                                   \
 /^[^@].*\.la$$/ {                                                      \
-       system("cd ${PREFIX} && ${SH} ${_PRINT_LA_LIBNAMES} " $$0)      \
+       system("cd ${PREFIX} && ${SETENV} ECHO=${ECHO} GREP=${GREP}     \
+       SORT=${SORT} ${SH} ${_PRINT_LA_LIBNAMES} " $$0) \
 }
 .endif
 

I'm not exactly sure why this is necessary, but at least it does the
trick.
I had had the suspicion that it is because of SU_CMD being
su - root -c
which due to the '-' makes the environment variables being kept for the
root environment, but changing it to su root -c did not make a difference.

Maybe the same problem occurs elsewhere as well where other scripts are
called via the awk system() command?

-- 
Georg Schwarz    http://home.pages.de/~schwarz/
 geos@epost.de     +49 177 8811442