Subject: Re: DESTDIR support
To: None <tech-pkg@netbsd.org>
From: Klaus Heinz <k.heinz.maer.sieben@kh-22.de>
List: tech-pkg
Date: 03/17/2007 20:30:57
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Joerg Sonnenberger wrote:

> I'll go through the Perl, Python, KDE and Gnome stuff through, as most
> of it should support it without changes beside the above.

This is my first stab at this DESTDIR stuff and it seems to work pretty
nice. I have noticed some issues, though.

- check-interpreter.mk does not know about DESTDIR and complains:

    => Checking for non-existent script interpreters in gmake-3.81
    WARNING: [check-interpreter.mk] File "bin/gmake" cannot be read.
    WARNING: [check-interpreter.mk] File "info/make.info" cannot be read.
    ...

- check-shlibs.mk does not know about DESTDIR and does not complain. In
  fact, I think it has not worked at all since revision 1.13 when the
  .PLIST format switched to relative path names.

- check-perms.mk and check-wrkref.mk need an installed package to work
  correctly at this time:
    => Checking file permissions in gmake-3.81
    pkg_info: can't find package `gmake-3.81'
    ...
    => Checking for work-directory references in gmake-3.81
    pkg_info: can't find package `gmake-3.81'

  Both should be changed to not use PKG_FILELIST_CMD in order to get a
  list of files for the package at hand.


I have attached patches for the first two issues.

ciao
     Klaus

--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="check-interpreter.mk.diff"

Index: check-interpreter.mk
===================================================================

Since the .PLIST file contains relative paths, we need to change the working
directory to ${DESTDIR}${PREFIX} before we can check the files.

We can also omit "${PREFIX}/${p}" from the case statement due to those
relative paths. Otherwise, it would have to change to
"${DESTDIR}${PREFIX}/${p}"


RCS file: /cvsroot/pkgsrc/mk/check/check-interpreter.mk,v
retrieving revision 1.16
diff -u -r1.16 check-interpreter.mk
--- check-interpreter.mk	12 Nov 2006 00:49:57 -0000	1.16
+++ check-interpreter.mk	17 Mar 2007 18:49:56 -0000
@@ -40,11 +40,11 @@
 	@${STEP_MSG} "Checking for non-existent script interpreters in ${PKGNAME}"
 	${_PKG_SILENT}${_PKG_DEBUG}					\
 	set -e;								\
-	cd ${PREFIX};							\
+	cd ${DESTDIR}${PREFIX};						\
 	${_CHECK_INTERP_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g' |\
 	while read file; do						\
 		case "$$file" in					\
-		${_CHECK_INTERP_SKIP:@p@${PREFIX}/${p}|${p}) continue ;;@} \
+		${_CHECK_INTERP_SKIP:@p@${p}) continue ;;@}		\
 		*) ;;							\
 		esac;							\
 		if [ ! -r "$$file" ]; then				\

--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="check-shlibs.mk.diff"

Index: check-shlibs.mk
===================================================================

The regular expression will not match relative paths from .PLIST if
it contains a leading /.

Change the working directory to ${DESTDIR}${PREFIX} so files can be
accessed correctly. In case of errors, extend the relative paths to
absolute paths again for better clarity. Improve (IMHO) some wording.


RCS file: /cvsroot/pkgsrc/mk/check/check-shlibs.mk,v
retrieving revision 1.8
diff -u -r1.8 check-shlibs.mk
--- check-shlibs.mk	16 Mar 2007 10:29:22 -0000	1.8
+++ check-shlibs.mk	17 Mar 2007 18:48:57 -0000
@@ -29,7 +29,7 @@
 CHECK_SHLIBS_SUPPORTED?=	yes
 
 # All binaries and shared libraries.
-_CHECK_SHLIBS_ERE=	/(bin/|sbin/|libexec/|lib/lib.*\.so|lib/lib.*\.dylib)
+_CHECK_SHLIBS_ERE=	(bin/|sbin/|libexec/|lib/lib.*\.so|lib/lib.*\.dylib)
 
 _CHECK_SHLIBS_FILELIST_CMD?=	${SED} -e '/^@/d' ${PLIST}
 
@@ -48,17 +48,18 @@
 	*)	ldd=${LDD:Q} ;;						\
 	esac;								\
 	${TEST} -x "$$ldd" || exit 0;					\
+	cd ${DESTDIR}${PREFIX};						\
 	${_CHECK_SHLIBS_FILELIST_CMD} |					\
 	${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} |				\
 	while read file; do						\
 		err=`$$ldd $$file 2>&1 | ${GREP} "not found" || ${TRUE}`; \
-		${TEST} -z "$$err" || ${ECHO} "$$file: $$err";		\
+		${TEST} -z "$$err" || ${ECHO} "${DESTDIR}${PREFIX}/$$file: $$err"; \
 	done
 	${_PKG_SILENT}${_PKG_DEBUG}					\
 	exec 1>>${ERROR_DIR}/${.TARGET};				\
 	if ${_NONZERO_FILESIZE_P} ${ERROR_DIR}/${.TARGET}; then		\
-		${ECHO} "*** The above programs/libs will not find the listed shared libraries"; \
-		${ECHO} "    at runtime.  Please fix the package (add -Wl,-R.../lib in the right"; \
-		${ECHO} "    places)!";					\
+		${ECHO} "*** The programs/libs shown above will not find the listed"; \
+		${ECHO} "    shared libraries at runtime."; \
+		${ECHO} "    Please fix the package (add -Wl,-R.../lib in the right places)!"; \
 		${SHCOMMENT} Might not error-out for non-pkg-developers; \
 	fi

--6TrnltStXW4iwmi0--