Avoid using DESTDIR in packaged-base targets, which can

cause bizarre packaging failures with non-default OBJDIR
and/or MAKEOBJDIRPREFIX and REPODIR set to a location not
within OBJDIR.

Reported by:	many
Tested by:	sef
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
gjb 2016-04-08 01:57:40 +00:00
parent 5fec2ae02d
commit cbc3bd9845

View File

@ -1241,7 +1241,7 @@ package-pkg:
real-packages: stage-packages create-packages sign-packages real-packages: stage-packages create-packages sign-packages
stage-packages: stage-packages:
@mkdir -p ${WSTAGEDIR} ${KSTAGEDIR} @mkdir -p ${REPODIR} ${WSTAGEDIR} ${KSTAGEDIR}
${_+_}@cd ${.CURDIR}; \ ${_+_}@cd ${.CURDIR}; \
${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \ ${MAKE} DESTDIR=${WSTAGEDIR} -DNO_ROOT -B stageworld ; \
${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel ${MAKE} DESTDIR=${KSTAGEDIR} -DNO_ROOT -B stagekernel
@ -1256,37 +1256,37 @@ create-packages: _pkgbootstrap
create-kernel-packages create-kernel-packages
create-world-packages: _pkgbootstrap create-world-packages: _pkgbootstrap
@rm -f ${DESTDIR}/*.plist 2>/dev/null || : @rm -f ${WSTAGEDIR}/*.plist 2>/dev/null || :
@cd ${DESTDIR} ; \ @cd ${WSTAGEDIR} ; \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
${DESTDIR}/METALOG ${WSTAGEDIR}/METALOG
@for plist in ${DESTDIR}/*.plist; do \ @for plist in ${WSTAGEDIR}/*.plist; do \
plist=$${plist##*/} ; \ plist=$${plist##*/} ; \
pkgname=$${plist%.plist} ; \ pkgname=$${plist%.plist} ; \
sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \ sh ${SRCDIR}/release/packages/generate-ucl.sh -o $${pkgname} \
-s ${SRCDIR} -u ${DESTDIR}/$${pkgname}.ucl ; \ -s ${SRCDIR} -u ${WSTAGEDIR}/$${pkgname}.ucl ; \
done done
@for plist in ${DESTDIR}/*.plist; do \ @for plist in ${WSTAGEDIR}/*.plist; do \
plist=$${plist##*/} ; \ plist=$${plist##*/} ; \
pkgname=$${plist%.plist} ; \ pkgname=$${plist%.plist} ; \
awk -F\" ' \ awk -F\" ' \
/^name/ { printf("===> Creating %s-", $$2); next } \ /^name/ { printf("===> Creating %s-", $$2); next } \
/^version/ { print $$2; next } \ /^version/ { print $$2; next } \
' ${DESTDIR}/$${pkgname}.ucl ; \ ' ${WSTAGEDIR}/$${pkgname}.ucl ; \
pkg -o ABI_FILE=${DESTDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \ pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
create -M ${DESTDIR}/$${pkgname}.ucl \ create -M ${WSTAGEDIR}/$${pkgname}.ucl \
-p ${DESTDIR}/$${pkgname}.plist \ -p ${WSTAGEDIR}/$${pkgname}.plist \
-r ${DESTDIR} \ -r ${WSTAGEDIR} \
-o ${REPODIR}/$$(pkg -o ABI_FILE=${DESTDIR}/bin/sh config ABI)/${PKG_VERSION} ; \ -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} ; \
done done
create-kernel-packages: _pkgbootstrap create-kernel-packages: _pkgbootstrap
.if exists(${DESTDIR}/kernel.meta) .if exists(${KSTAGEDIR}/kernel.meta)
.for flavor in "" -debug .for flavor in "" -debug
@cd ${DESTDIR}/${DISTDIR} ; \ @cd ${KSTAGEDIR}/${DISTDIR} ; \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
-v kernel=yes -v _kernconf=${INSTALLKERNEL} \ -v kernel=yes -v _kernconf=${INSTALLKERNEL} \
${DESTDIR}/kernel.meta ; \ ${KSTAGEDIR}/kernel.meta ; \
cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
sed -e "s/%VERSION%/${PKG_VERSION}/" \ sed -e "s/%VERSION%/${PKG_VERSION}/" \
@ -1296,26 +1296,26 @@ create-kernel-packages: _pkgbootstrap
-e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \ -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
-e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \ -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
${SRCDIR}/release/packages/kernel.ucl \ ${SRCDIR}/release/packages/kernel.ucl \
> ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ > ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
awk -F\" ' \ awk -F\" ' \
/name/ { printf("===> Creating %s-", $$2); next } \ /name/ { printf("===> Creating %s-", $$2); next } \
/version/ {print $$2; next } ' \ /version/ {print $$2; next } ' \
${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \ ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \ pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
create -M ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \ create -M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
-p ${DESTDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \ -p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
-r ${DESTDIR}/${DISTDIR} \ -r ${KSTAGEDIR}/${DISTDIR} \
-o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
.endfor .endfor
.endif .endif
.if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS) .if ${BUILDKERNELS:[#]} > 1 && !defined(NO_INSTALLEXTRAKERNELS)
.for _kernel in ${BUILDKERNELS:[2..-1]} .for _kernel in ${BUILDKERNELS:[2..-1]}
.if exists(${DESTDIR}/kernel.${_kernel}.meta) .if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
.for flavor in "" -debug .for flavor in "" -debug
@cd ${DESTDIR}/kernel.${_kernel} ; \ @cd ${KSTAGEDIR}/kernel.${_kernel} ; \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \ awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
-v kernel=yes -v _kernconf=${_kernel} \ -v kernel=yes -v _kernconf=${_kernel} \
${DESTDIR}/kernel.${_kernel}.meta ; \ ${KSTAGEDIR}/kernel.${_kernel}.meta ; \
cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \ cap_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VCAP_MKDB_ENDIAN` ; \
pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \ pwd_arg=`cd ${SRCDIR}/etc ; ${MAKE} -VPWD_MKDB_ENDIAN` ; \
sed -e "s/%VERSION%/${PKG_VERSION}/" \ sed -e "s/%VERSION%/${PKG_VERSION}/" \
@ -1325,15 +1325,15 @@ create-kernel-packages: _pkgbootstrap
-e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \ -e "s/%CAP_MKDB_ENDIAN%/$${cap_arg}/g" \
-e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \ -e "s/%PWD_MKDB_ENDIAN%/$${pwd_arg}/g" \
${SRCDIR}/release/packages/kernel.ucl \ ${SRCDIR}/release/packages/kernel.ucl \
> ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ > ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
awk -F\" ' \ awk -F\" ' \
/name/ { printf("===> Creating %s-", $$2); next } \ /name/ { printf("===> Creating %s-", $$2); next } \
/version/ {print $$2; next } ' \ /version/ {print $$2; next } ' \
${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \ ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \ pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh -o ALLOW_BASE_SHLIBS=yes \
create -M ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \ create -M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
-p ${DESTDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \ -p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
-r ${DESTDIR}/kernel.${_kernel} \ -r ${KSTAGEDIR}/kernel.${_kernel} \
-o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION} -o ${REPODIR}/$$(pkg -o ABI_FILE=${WSTAGEDIR}/bin/sh config ABI)/${PKG_VERSION}
.endfor .endfor
.endif .endif