Shell-escape assignments to PATH in the top-level makefiles

Since 16fbf01912 PATH is no longer set
to a hardcoded value on non-FreeBSD build hosts, so we can end up with
spaces in $PATH. Instead of only escaping PATH I updated all `env PATH=`
uses in the toplevel makefile. While many of these currently can't
contain any special characters (since the build would have failed
already), in theory this gets us closer to allowing build/source
directory to contain e.g. spaces.
This commit is contained in:
Alex Richardson 2023-01-20 10:47:17 +00:00
parent e5c30ac930
commit 34ac629b40
2 changed files with 26 additions and 26 deletions

View File

@ -224,7 +224,7 @@ META_TGT_WHITELIST+= \
PATH= /sbin:/bin:/usr/sbin:/usr/bin
.endif
MAKEOBJDIRPREFIX?= /usr/obj
_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} MK_AUTO_OBJ=no \
_MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH:Q} ${MAKE} MK_AUTO_OBJ=no \
${.MAKEFLAGS:MMAKEOBJDIRPREFIX=*} __MAKE_CONF=${__MAKE_CONF} \
SRCCONF=${SRCCONF} SRC_ENV_CONF= \
-f /dev/null -V MAKEOBJDIRPREFIX dummy
@ -267,7 +267,7 @@ SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
.endif
_MAKE= PATH=${PATH} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
_MAKE= PATH=${PATH:Q} MAKE_CMD="${MAKE}" ${SUB_MAKE} -f Makefile.inc1 \
TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH} ${_MAKEARGS}
.if defined(MK_META_MODE) && ${MK_META_MODE} == "yes"
@ -595,7 +595,7 @@ universe-toolchain: .PHONY universe_prologue
@echo "> Toolchain bootstrap started on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
${_+_}@cd ${.CURDIR}; \
env PATH=${PATH} ${SUB_MAKE} ${JFLAG} kernel-toolchain \
env PATH=${PATH:Q} ${SUB_MAKE} ${JFLAG} kernel-toolchain \
TARGET=${MACHINE} TARGET_ARCH=${MACHINE_ARCH} \
OBJTOP="${HOST_OBJTOP}" \
WITHOUT_SYSTEM_COMPILER=yes \

View File

@ -697,7 +697,7 @@ BOOTSTRAPPING_OSRELDATE?=${OSRELDATE}
# bootstrap-tools stage
BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
TOOLS_PREFIX=${TOOLS_PREFIX_UNDEF:U${WORLDTMP}} \
PATH=${BPATH}:${PATH} \
PATH=${BPATH:Q}:${PATH:Q} \
WORLDTMP=${WORLDTMP} \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
# need to keep this in sync with targets/pseudo/bootstrap-tools/Makefile
@ -765,7 +765,7 @@ XMAKE= ${BMAKE} \
# kernel-tools stage
KTMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
PATH=${BPATH}:${PATH} \
PATH=${BPATH:Q}:${PATH:Q} \
WORLDTMP=${WORLDTMP} \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
@ -792,13 +792,13 @@ KTMAKE= ${TIME_ENV} \
# world stage
WMAKEENV= ${CROSSENV} \
INSTALL="${INSTALL_CMD} -U" \
PATH=${TMPPATH} \
PATH=${TMPPATH:Q} \
SYSROOT=${WORLDTMP}
# make hierarchy
HMAKE= PATH=${TMPPATH} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
HMAKE= PATH=${TMPPATH:Q} ${MAKE} LOCAL_MTREE=${LOCAL_MTREE:Q}
.if defined(NO_ROOT)
HMAKE+= PATH=${TMPPATH} METALOG=${METALOG} -DNO_ROOT
HMAKE+= PATH=${TMPPATH:Q} METALOG=${METALOG} -DNO_ROOT
.endif
CROSSENV+= CC="${XCC} ${XCFLAGS}" CXX="${XCXX} ${XCXXFLAGS} ${XCFLAGS}" \
@ -909,12 +909,12 @@ IMAKEENV= ${CROSSENV}
IMAKE= ${TIME_ENV} ${IMAKEENV} ${MAKE} -f Makefile.inc1 \
${IMAKE_INSTALL} ${IMAKE_MTREE}
.if empty(.MAKEFLAGS:M-n)
IMAKEENV+= PATH=${STRICTTMPPATH}:${INSTALLTMP} \
LD_LIBRARY_PATH=${INSTALLTMP} \
IMAKEENV+= PATH=${STRICTTMPPATH:Q}:${INSTALLTMP:Q} \
LD_LIBRARY_PATH=${INSTALLTMP:Q} \
PATH_LOCALE=${INSTALLTMP}/locale
IMAKE+= __MAKE_SHELL=${INSTALLTMP}/sh
.else
IMAKEENV+= PATH=${TMPPATH}:${INSTALLTMP}
IMAKEENV+= PATH=${TMPPATH:Q}:${INSTALLTMP:Q}
.endif
# When generating install media, do not allow user and group information from
@ -1023,7 +1023,7 @@ _worldtmp: .PHONY
# so we remove that assingnment from $WMAKE and prepend the new $PATH
${_+_}@if [ -e "${WORLDTMP}" ]; then \
echo ">>> Deleting stale files in build tree..."; \
cd ${.CURDIR}; env PATH=${TMPPATH}:${PATH} ${WMAKE:NPATH=*} \
cd ${.CURDIR}; env PATH=${TMPPATH:Q}:${PATH:Q} ${WMAKE:NPATH=*} \
-DBATCH_DELETE_OLD_FILES delete-old \
delete-old-libs >/dev/null; \
fi
@ -1367,7 +1367,7 @@ MTREE_MAGIC?= mtree 2.0
distributeworld installworld stageworld: _installcheck_world .PHONY
mkdir -p ${INSTALLTMP}
progs=$$(for prog in ${ITOOLS}; do \
if progpath=`env PATH=${TMPPATH} which $$prog`; then \
if progpath=`env PATH=${TMPPATH:Q} which $$prog`; then \
echo $$progpath; \
else \
echo "Required tool $$prog not found in PATH ($$PATH)." >&2; \
@ -1442,7 +1442,7 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
.endif
.endfor
-mkdir ${DESTDIR}/${DISTDIR}/base
${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \
METALOG=${METALOG} ${IMAKE_INSTALL} ${IMAKE_MTREE} \
DISTBASE=/base DESTDIR=${DESTDIR}/${DISTDIR}/base \
LOCAL_MTREE=${LOCAL_MTREE:Q} distrib-dirs
@ -1452,7 +1452,7 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
${IMAKEENV} rm -rf ${INSTALLTMP}
.if !make(packageworld) && ${MK_CAROOT} != "no"
@if which openssl>/dev/null; then \
PATH=${TMPPATH}:${PATH} \
PATH=${TMPPATH:Q}:${PATH:Q} \
sh ${SRCTOP}/usr.sbin/certctl/certctl.sh ${CERTCTLFLAGS} rehash; \
else \
echo "No openssl on the host, not rehashing certificates target -- /etc/ssl may not be populated."; \
@ -1537,7 +1537,7 @@ sysent: .PHONY
.for _dir in ${_sysent_dirs}
sysent-${_dir}: .PHONY
@echo "${MAKE} -C ${.CURDIR}/${_dir} sysent"
${_+_}@env PATH=${_sysent_PATH} ${MAKE} -C ${.CURDIR}/${_dir} sysent
${_+_}@env PATH=${_sysent_PATH:Q} ${MAKE} -C ${.CURDIR}/${_dir} sysent
sysent: sysent-${_dir}
.endfor
@ -1585,10 +1585,10 @@ redistribute: .MAKE .PHONY
.endif
distrib-dirs distribution: .MAKE .PHONY
${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH} ${MAKE} \
${_+_}cd ${.CURDIR}/etc; ${CROSSENV} PATH=${TMPPATH:Q} ${MAKE} \
${IMAKE_INSTALL} ${IMAKE_MTREE} METALOG=${METALOG} ${.TARGET}
.if make(distribution)
${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH} \
${_+_}cd ${.CURDIR}; ${CROSSENV} PATH=${TMPPATH:Q} \
${MAKE} -f Makefile.inc1 ${IMAKE_INSTALL} \
METALOG=${METALOG} MK_TESTS=no \
MK_TESTS_SUPPORT=${MK_TESTS_SUPPORT} installconfig
@ -1696,7 +1696,7 @@ buildkernel: .MAKE .PHONY
@echo ">>> stage 1: configuring the kernel"
@echo "--------------------------------------------------------------"
cd ${KRNLCONFDIR}; \
PATH=${TMPPATH} \
PATH=${TMPPATH:Q} \
config ${CONFIGARGS} -d ${KRNLOBJDIR}/${_kernel} \
-I '${KERNCONFDIR}' -I '${KRNLCONFDIR}' \
'${KERNCONFDIR}/${_kernel}'
@ -1763,7 +1763,7 @@ reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
@echo ">>> Installing kernel ${INSTALLKERNEL} on $$(LC_ALL=C date)"
@echo "--------------------------------------------------------------"
${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${CROSSENV} PATH=${TMPPATH} \
${CROSSENV} PATH=${TMPPATH:Q} \
${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME} ${.TARGET:S/kernel//}
@echo "--------------------------------------------------------------"
@echo ">>> Installing kernel ${INSTALLKERNEL} completed on $$(LC_ALL=C date)"
@ -1775,7 +1775,7 @@ reinstallkernel reinstallkernel.debug: _installcheck_kernel .PHONY
@echo ">>> Installing kernel ${_kernel} $$(LC_ALL=C date)"
@echo "--------------------------------------------------------------"
${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
${CROSSENV} PATH=${TMPPATH} \
${CROSSENV} PATH=${TMPPATH:Q} \
${MAKE} ${IMAKE_INSTALL} KERNEL=${INSTKERNNAME}.${_kernel} ${.TARGET:S/kernel//}
@echo "--------------------------------------------------------------"
@echo ">>> Installing kernel ${_kernel} completed on $$(LC_ALL=C date)"
@ -1795,7 +1795,7 @@ distributekernel distributekernel.debug: .PHONY
.endif
${_+_}cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.premeta/} \
${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} KERNEL=${INSTKERNNAME} \
${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} KERNEL=${INSTKERNNAME} \
DESTDIR=${INSTALL_DDIR}/kernel \
${.TARGET:S/distributekernel/install/}
.if defined(NO_ROOT)
@ -1810,7 +1810,7 @@ distributekernel distributekernel.debug: .PHONY
.endif
${_+_}cd ${KRNLOBJDIR}/${_kernel}; \
${IMAKEENV} ${IMAKE_INSTALL:S/METALOG/kernel.${_kernel}.premeta/} \
${IMAKE_MTREE} PATH=${TMPPATH} ${MAKE} \
${IMAKE_MTREE} PATH=${TMPPATH:Q} ${MAKE} \
KERNEL=${INSTKERNNAME}.${_kernel} \
DESTDIR=${INSTALL_DDIR}/kernel.${_kernel} \
${.TARGET:S/distributekernel/install/}
@ -3405,7 +3405,7 @@ DTBOUTPUTPATH= ${.CURDIR}
# Build 'standalone' Device Tree Blob
#
builddtb: .PHONY
@PATH=${TMPPATH} MACHINE=${TARGET} \
@PATH=${TMPPATH:Q} MACHINE=${TARGET} \
sh ${.CURDIR}/sys/tools/fdt/make_dtb.sh ${.CURDIR}/sys \
"${FDT_DTS_FILE}" ${DTBOUTPUTPATH}
@ -3502,8 +3502,8 @@ CD2ENV=${CDENV} CC="${CC} ${CD2CFLAGS}" CXX="${CXX} ${CD2CXXFLAGS} ${CD2CFLAGS}"
MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}
CDTMP= ${OBJTOP}/${XDDIR}/tmp
CDMAKE=${CDENV} PATH=${CDTMP}/usr/bin:${PATH} ${MAKE} ${CDMAKEARGS} ${NOFUN}
CD2MAKE=${CD2ENV} PATH=${CDTMP}/usr/bin:${XDDESTDIR}/usr/bin:${PATH} \
CDMAKE=${CDENV} PATH=${CDTMP:Q}/usr/bin:${PATH:Q} ${MAKE} ${CDMAKEARGS} ${NOFUN}
CD2MAKE=${CD2ENV} PATH=${CDTMP:Q}/usr/bin:${XDDESTDIR:Q}/usr/bin:${PATH:Q} \
${MAKE} ${CD2MAKEARGS} ${NOFUN}
.if ${MK_META_MODE} != "no"
# Don't rebuild build-tools targets during normal build.