tech-pkg archive

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

Re: Making DESTDIR support mandatory



On Wed, 04 May 2011 18:24:29 +0900, OBATA Akio <obache%netbsd.org@localhost> 
wrote:

Following patch is uncompleted, but with USE_DESTDIR=yes
1. `make undo-replace' will work

Already committed.

2. `make install' will not create binary package in ${PACAKGES},
     but with `make package' or `make package-install'.

Take 2.
* "make stage-instlal" & "make install" will work as expected, but "make 
install" directly
   result in trying to install binary package twice
* try to create ${STAGE_PKGFILE} bit aggressively.

Index: mk/flavor/pkg/package.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/flavor/pkg/package.mk,v
retrieving revision 1.21
diff -u -r1.21 package.mk
--- mk/flavor/pkg/package.mk    19 Mar 2011 09:45:24 -0000      1.21
+++ mk/flavor/pkg/package.mk    16 Jun 2011 12:44:26 -0000
@@ -13,6 +13,11 @@
 PKG_SUFX?=             .tgz
 FILEBASE?=             ${PKGBASE}
 PKGFILE?=              ${PKGREPOSITORY}/${FILEBASE}-${PKGVERSION}${PKG_SUFX}
+.if ${_USE_DESTDIR} == "no"
+STAGE_PKGFILE?=                ${PKGFILE}
+.else
+STAGE_PKGFILE?=                
${WRKDIR}/.packages/${FILEBASE}-${PKGVERSION}${PKG_SUFX}
+.endif
 PKGREPOSITORY?=                ${PACKAGES}/${PKGREPOSITORYSUBDIR}
 PKGREPOSITORYSUBDIR?=  All

@@ -34,6 +39,12 @@
 ###
 .PHONY: package-create
 package-create: package-remove ${PKGFILE} package-links
+.PHONY: stage-package-create
+.if ${_USE_DESTDIR} == "no"
+stage-package-create:  package-create
+.else
+stage-package-create:  stage-install stage-package-remove ${STAGE_PKGFILE}
+.endif

 _PKG_ARGS_PACKAGE+=    ${_PKG_CREATE_ARGS}
 _PKG_ARGS_PACKAGE+=    -F ${PKG_COMPRESSION}
@@ -49,7 +60,7 @@
 _PKG_ARGS_PACKAGE+=    -E
 .endif

-${PKGFILE}: ${_CONTENTS_TARGETS}
+${STAGE_PKGFILE}: ${_CONTENTS_TARGETS}
        ${RUN} ${MKDIR} ${.TARGET:H}
        @${STEP_MSG} "Creating binary package ${.TARGET}"
        ${RUN} tmpname=${.TARGET:S,${PKG_SUFX}$,.tmp${PKG_SUFX},};      \
@@ -59,6 +70,12 @@
                exitcode=$$?; ${RM} -f "$$tmpname"; exit $$exitcode;    \
        fi

+.if ${_USE_DESTDIR} != "no"
+${PKGFILE}: ${STAGE_PKGFILE}
+       ${LN} -f ${STAGE_PKGFILE} ${PKGFILE} 2>/dev/null || \
+       ${CP} -pf ${STAGE_PKGFILE} ${PKGFILE}
+.endif
+
 ######################################################################
 ### package-remove (PRIVATE)
 ######################################################################
@@ -69,6 +86,10 @@
 package-remove:
        ${RUN} ${RM} -f ${PKGFILE}

+.PHONY: stage-package-remove
+stage-package-remove:
+       ${RUN} ${RM} -f ${STAGE_PKGFILE}
+
 ######################################################################
 ### package-links (PRIVATE)
 ######################################################################
@@ -132,6 +153,9 @@
 package-install: barrier
 .endif

+.PHONY: stage-package-install
+stage-package-install: stage-package-create real-package-install
+
 .if ${_USE_DESTDIR} != "no"
 .  if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
 real-package-install: su-real-package-install
@@ -147,13 +171,13 @@
        @${PHASE_MSG} "Install binary package of "${PKGNAME:Q}
 .if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
        @${MKDIR} ${_CROSS_DESTDIR}${PREFIX}
-       ${PKG_ADD} -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} 
${PKGFILE}
+       ${PKG_ADD} -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} 
${STAGE_PKGFILE}
        @${ECHO} "Fixing recorded cwd..."
        @${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' 
${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp
        @${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp 
${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS
 .else
        ${RUN} case ${_AUTOMATIC:Q}"" in                                        
\
-       [yY][eE][sS])   ${PKG_ADD} -A ${PKGFILE} ;;                     \
-       *)              ${PKG_ADD} ${PKGFILE} ;;                        \
+       [yY][eE][sS])   ${PKG_ADD} -A ${STAGE_PKGFILE} ;;               \
+       *)              ${PKG_ADD} ${STAGE_PKGFILE} ;;                  \
        esac
 .endif
Index: mk/install/bsd.install.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/install/bsd.install.mk,v
retrieving revision 1.13
diff -u -r1.13 bsd.install.mk
--- mk/install/bsd.install.mk   24 Feb 2010 22:53:34 -0000      1.13
+++ mk/install/bsd.install.mk   16 Jun 2011 12:44:26 -0000
@@ -25,7 +25,7 @@
 .if ${_USE_DESTDIR} == "no"
 install: stage-install
 .else
-install: package-install
+install: stage-package-install
 .endif

 ######################################################################



--
OBATA Akio / obache%NetBSD.org@localhost


Home | Main Index | Thread Index | Old Index