Subject: Re: strange permissions difference between /var/db/pkg and the package archive
To: NetBSD Packages Technical Discussion List <tech-pkg@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: tech-pkg
Date: 04/21/1999 15:58:48
[ On Wednesday, April 21, 1999 at 21:00:32 (+0200), Hubert Feyrer wrote: ]
> Subject: Re: strange permissions difference between /var/db/pkg and the  package archive
>
> I have an odd feeling that the files in pkgsrc are used for the tar-file,
> NOT the ones in /var/db/pkg.
 
Well, I made the mistake of looking at it all again....

Here's a tested-exactly-once work-around that gets the files for the
package.tgz from /var/db/pkg instead of from ${WRKDIR}.  This means that
so long as you did the "make install" as root then you'll get the
"right" ownerships in the package.tgz file too.

This change also "cleans" up the registering stuff a bit (only the
re-ordering of the pkg_create call is really necessary).  I think though
that it should be an error for there to be an INSTALL_FILE defined, but
no such file in existance, so I took out the "if [ -e $FILE ]" bits, and
I also changed it to use ${INSTALL_*} which seems much more correct.

I still think pkg_add should ensure the ownerships are correct after the
fact too, as well as not deleting INSTALL_FNAME and MTREE_FNAME, and
though that appears to be a simple change too, I'll leave it until later.

If there are no other comments right now I can send-pr this part of the
fix right away (unless someone takes it right from here! ;-)

(lines are likely way out of wack because this was manually edited to
get rid of other irrelevant hunks)

Diff is based on:

#	$NetBSD: bsd.pkg.mk,v 1.232 1999/03/29 11:22:29 agc Exp $


Index: bsd.pkg.mk
===================================================================
RCS file: /cvs/NetBSD/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1.1.14
diff -c -c -r1.1.1.14 bsd.pkg.mk
*** bsd.pkg.mk	1999/03/29 17:43:07	1.1.1.14
--- bsd.pkg.mk	1999/04/21 19:43:48
***************
*** 431,436 ****
--- 431,439 ----
  BUILD_VERSION_FILE=	${WRKDIR}/BuildVersion
  BUILD_INFO_FILE=	${WRKDIR}/BuildInfo
  
+ # File created by pkg_create
+ CONTENTS_FILE=		${WRKDIR}/.CONTENTS
+ 
  .if (${OPSYS} == "SunOS")
  PKG_ADD?=	${LOCALBASE}/bsd/bin/pkg_add
  PKG_CREATE?=	${LOCALBASE}/bsd/bin/pkg_create
***************
*** 444,469 ****
  .endif
  
  .ifndef PKG_ARGS
! PKG_ARGS=		-v -c ${COMMENT} -d ${DESCR} -f ${PLIST} -l
! PKG_ARGS+=		-b ${BUILD_VERSION_FILE} -B ${BUILD_INFO_FILE}
! PKG_ARGS+=		-p ${PREFIX} -P "`${MAKE} package-depends PACKAGE_DEPENDS_WITH_PATTERNS=true|sort -u`"
  .ifdef CONFLICTS
  PKG_ARGS+=		-C "${CONFLICTS}"
  .endif
  .ifdef INSTALL_FILE
! PKG_ARGS+=		-i ${INSTALL_FILE}
  .endif
  .ifdef DEINSTALL_FILE
! PKG_ARGS+=		-k ${DEINSTALL_FILE}
  .endif
! .ifdef REQ_FILE
! PKG_ARGS+=		-r ${REQ_FILE}
  .endif
  .ifdef MESSAGE_FILE
! PKG_ARGS+=		-D ${MESSAGE_FILE}
  .endif
  .ifndef NO_MTREE
! PKG_ARGS+=		-m ${MTREE_FILE}
  .endif
  .endif # !PKG_ARGS
  PKG_SUFX?=		.tgz
--- 447,475 ----
  .endif
  
  .ifndef PKG_ARGS
! PKG_ARGS=		-v -l -p ${PREFIX} -f ${PLIST}
! PKG_ARGS+=		-c ${PKG_DBDIR}/${PKGNAME}/+COMMENT
! PKG_ARGS+=		-d ${PKG_DBDIR}/${PKGNAME}/+DESC
! PKG_ARGS+=		-b ${PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION
! PKG_ARGS+=		-B ${PKG_DBDIR}/${PKGNAME}/+BUILD_INFO
! PKG_ARGS+=		-P "`${MAKE} package-depends PACKAGE_DEPENDS_WITH_PATTERNS=true|sort -u`"
  .ifdef CONFLICTS
  PKG_ARGS+=		-C "${CONFLICTS}"
  .endif
  .ifdef INSTALL_FILE
! PKG_ARGS+=		-i ${PKG_DBDIR}/${PKGNAME}/+INSTALL
  .endif
  .ifdef DEINSTALL_FILE
! PKG_ARGS+=		-k ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL
  .endif
! .ifdef REQIRE_FILE
! PKG_ARGS+=		-r ${PKG_DBDIR}/${PKGNAME}/+REQUIRE
  .endif
  .ifdef MESSAGE_FILE
! PKG_ARGS+=		-D ${PKG_DBDIR}/${PKGNAME}/+DISPLAY
  .endif
  .ifndef NO_MTREE
! PKG_ARGS+=		-m ${PKG_DBDIR}/${PKGNAME}/+MTREE_DIRS
  .endif
  .endif # !PKG_ARGS
  PKG_SUFX?=		.tgz
***************
*** 2148,2181 ****
  	@${ECHO} "GMAKE=	`${GMAKE} --version | ${GREP} version`" >> ${BUILD_INFO_FILE}
  .endif
  	@${ECHO} "_PKGTOOLS_VER= `${MAKE} show-pkgtools-version`" >> ${BUILD_INFO_FILE}
! 	${_PKG_SILENT}${_PKG_DEBUG}if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then			\
! 		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
! 		${MKDIR} ${PKG_DBDIR}/${PKGNAME};			\
! 		${PKG_CREATE} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
! 		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC;		\
! 		${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT;	\
! 		${CP} ${BUILD_VERSION_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \
! 		${CP} ${BUILD_INFO_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \
  		if [ -n "${INSTALL_FILE}" ]; then			\
! 			if ${TEST} -e ${INSTALL_FILE}; then		\
! 				${CP} ${INSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
! 			fi;						\
  		fi;							\
  		if [ -n "${DEINSTALL_FILE}" ]; then			\
! 			if ${TEST} -e ${DEINSTALL_FILE}; then		\
! 				${CP} ${DEINSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
! 			fi;						\
  		fi;							\
! 		if [ -n "${REQ_FILE}" ]; then				\
! 			if ${TEST} -e ${REQ_FILE}; then			\
! 				${CP} ${REQ_FILE} ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
! 			fi;						\
  		fi;							\
  		if [ -n "${MESSAGE_FILE}" ]; then			\
! 			if ${TEST} -e ${MESSAGE_FILE}; then		\
! 				${CP} ${MESSAGE_FILE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
! 			fi;						\
  		fi;							\
  		for dep in `${MAKE} package-depends PACKAGE_DEPENDS_WITH_PATTERNS=true ECHO_MSG=${TRUE} | sort -u`; do \
  			realdep="`${PKG_INFO} -e \"$$dep\" || ${TRUE}`" ; \
  			${ECHO} "a sanity check should be put in here to prevent some user having the pkg installed/registered twice somehow - HF" >/dev/null ; \
--- 2156,2185 ----
  	@${ECHO} "GMAKE=	`${GMAKE} --version | ${GREP} version`" >> ${BUILD_INFO_FILE}
  .endif
  	@${ECHO} "_PKGTOOLS_VER= `${MAKE} show-pkgtools-version`" >> ${BUILD_INFO_FILE}
! 	${_PKG_SILENT}${_PKG_DEBUG}if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then	\
! 		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}";	\
! 		${INSTALL_DATA_DIR} ${PKG_DBDIR}/${PKGNAME};			\
! 		${INSTALL_DATA} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC;		\
! 		${INSTALL_DATA} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT;	\
! 		${INSTALL_DATA} ${BUILD_VERSION_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_VERSION; \
! 		${INSTALL_DATA} ${BUILD_INFO_FILE} ${PKG_DBDIR}/${PKGNAME}/+BUILD_INFO; \
  		if [ -n "${INSTALL_FILE}" ]; then			\
! 			${INSTALL_SCRIPT} ${INSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
  		fi;							\
  		if [ -n "${DEINSTALL_FILE}" ]; then			\
! 			${INSTALL_SCRIPT} ${DEINSTALL_FILE} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
  		fi;							\
! 		if [ -n "${REQUIRE_FILE}" ]; then				\
! 			${INSTALL_SCRIPT} ${REQUIRE_FILE} ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
  		fi;							\
  		if [ -n "${MESSAGE_FILE}" ]; then			\
! 			${INSTALL_DATA} ${MESSAGE_FILE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
! 		fi;							\
! 		if [ -n "${MTREE_FILE}" ]; then			\
! 			${INSTALL_DATA} ${MTREE_FILE} ${PKG_DBDIR}/${PKGNAME}/+MTREE_DIRS; \
  		fi;							\
+ 		${PKG_CREATE} ${PKG_ARGS} -O ${PKGFILE} > ${CONTENTS_FILE};	\
+ 		${INSTALL_DATA} ${CONTENTS_FILE} ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
  		for dep in `${MAKE} package-depends PACKAGE_DEPENDS_WITH_PATTERNS=true ECHO_MSG=${TRUE} | sort -u`; do \
  			realdep="`${PKG_INFO} -e \"$$dep\" || ${TRUE}`" ; \
  			${ECHO} "a sanity check should be put in here to prevent some user having the pkg installed/registered twice somehow - HF" >/dev/null ; \


-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>