Add support for using USE_DESTDIR=yes and replace together.

Based on the patch send to tech-pkg in 2008, but less intrusive.
This commit is contained in:
joerg 2009-06-09 08:40:27 +00:00
parent e23c5c4fe0
commit 4e1bd80afd
4 changed files with 41 additions and 7 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: README,v 1.6 2007/10/01 10:08:20 rillig Exp $
$NetBSD: README,v 1.7 2009/06/09 08:40:27 joerg Exp $
= Introduction =
@ -58,6 +58,7 @@ The following make targets must be implemented:
* tarup-pkg
* package-install
* _flavor-replace
* _flavor-destdir-replace
* _flavor-undo-replace
= Bugs =

View file

@ -1,8 +1,11 @@
# $NetBSD: replace.mk,v 1.24 2008/01/23 14:48:50 gdt Exp $
# $NetBSD: replace.mk,v 1.25 2009/06/09 08:40:27 joerg Exp $
#
# _flavor-replace:
# Updates a package in-place on the system.
# Updates a package in-place on the system (USE_DESTDIR=yes).
#
# _flavor-destdir-replace:
# Updates a package in-place on the system (USE_DESTDIR=yes).
#
# See also:
# replace
@ -24,6 +27,13 @@ _flavor-replace: \
replace-fixup-installed-info \
.PHONY
_flavor-destdir-replace: \
replace-names \
replace-destdir \
replace-fixup-required-by \
replace-fixup-installed-info \
.PHONY
# _flavor-undo-replace:
# Undoes the actions from a previous _flavor-replace.
#
@ -172,3 +182,15 @@ replace-clean: .PHONY
${RM} -f ${WRKDIR}/$$newname${PKG_SUFX}; \
${RM} -f ${_REPLACE_OLDNAME_FILE} ${_REPLACE_NEWNAME_FILE} \
${_COOKIE.replace}
replace-destdir: .PHONY
@${PHASE_MSG} "Updating using binary package of "${PKGNAME:Q}
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
@${MKDIR} ${_CROSS_DESTDIR}${PREFIX}
${PKG_ADD} -u -m ${MACHINE_ARCH} -I -p ${_CROSS_DESTDIR}${PREFIX} ${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
${PKG_ADD} -u ${PKGFILE}
.endif

View file

@ -1,4 +1,4 @@
# $NetBSD: replace.mk,v 1.10 2007/03/09 03:28:58 rillig Exp $
# $NetBSD: replace.mk,v 1.11 2009/06/09 08:40:28 joerg Exp $
#
# Public targets:
#
@ -14,12 +14,19 @@
# Private targets that must be defined by the package system flavor:
#
# _flavor-replace:
# Updates a package in-place on the system.
# Updates a package in-place on the system (USE_DESTDIR=no).
#
# _flavor-destdir-replace:
# Updates a package in-place on the system (USE_DESTDIR=yes).
#
# _flavor-undo-replace:
# Undoes a previous "make _flavor-replace".
.if ${_USE_DESTDIR} == "no"
_REPLACE_TARGETS+= ${_PKGSRC_BUILD_TARGETS}
.else
_REPLACE_TARGETS+= package
.endif
_REPLACE_TARGETS+= replace-message
_REPLACE_TARGETS+= unprivileged-install-hook
@ -38,7 +45,11 @@ replace-message: .PHONY
@${PHASE_MSG} "Replacing for ${PKGNAME}"
@${WARNING_MSG} "experimental target - DATA LOSS MAY OCCUR."
.if ${_USE_DESTDIR} == "no"
su-replace: .PHONY _flavor-replace
.else
su-replace: .PHONY _flavor-destdir-replace
.endif
MAKEFLAGS.su-replace= _UPDATE_RUNNING=yes
#

View file

@ -1,4 +1,4 @@
# $NetBSD: package.mk,v 1.20 2009/03/17 22:13:36 rillig Exp $
# $NetBSD: package.mk,v 1.21 2009/06/09 08:40:28 joerg Exp $
#
# This file provides the code for the "package" phase.
#
@ -13,7 +13,7 @@
#
_PACKAGE_TARGETS+= check-vulnerable
.if make(replace)
.if make(replace) && ${_USE_DESTDIR} == "no"
_PACKAGE_TARGETS+= replace
.else
_PACKAGE_TARGETS+= install