From 3109ad4369679b600f0b16c550410e7e9fdb4b6a Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Mon, 2 May 2011 05:21:26 -0500 Subject: [PATCH] script/makeworld: add option to override source tree or detect based on world link --- script/makeworld | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/script/makeworld b/script/makeworld index aa5b772..91cd79e 100755 --- a/script/makeworld +++ b/script/makeworld @@ -10,6 +10,7 @@ pebkac() { echo " -m Provide additional flags to make" echo " -a World architecture (i386, amd64)" echo " -c World configuration (in worlds//)" + echo " -s Override source tree selection" echo " -h Help!" echo "" echo "If, for some reason, you wish to spread out builds across multiple" @@ -33,7 +34,7 @@ prepare() { [ -d "${build}" ] && omg "${build}: directory exists; purging" && cleanup mount | grep -q "${build}" && wtf "Stuff is mounted under ${build}; cannot continue" ls -1 "${seed}"/base.?? >/dev/null 2>&1 || wtf "Populate seed directory ${seed} first" - [ -f /usr/src/sys/conf/newvers.sh ] || wtf "Need sources in /usr/src to build" + [ -f "${SRCS}/sys/conf/newvers.sh" ] || wtf "Need sources in ${SRCS} to build" # Cleanup trap here, so that an abort during prepare can clean up properly trap "cleanup" exit hup int term kill @@ -51,14 +52,14 @@ prepare() { mount -t devfs devfs "${build}/dev" || wtf # Mount /usr/src as a union, so that changes to it will not affect the underlying tree # unionfs suffers from deadlocks; don't use it - mount -t nullfs -r /usr/src "${build}/usr/src" || wtf + mount -t nullfs -r "${SRCS}" "${build}/usr/src" || wtf mount -t nullfs "${world}/obj" "${build}/usr/obj" || wtf mount -t nullfs "${world}/root" "${build}/mnt" || wtf if [ -d "${world}/config" ] then meh "Installing build-time configuration" - [ -f "${world}/config/${CONF}" ] && cp "${world}/config/${CONF}" "/usr/src/sys/${ARCH}/conf/" + [ -f "${world}/config/${CONF}" ] && cp "${world}/config/${CONF}" "${SRCS}/sys/${ARCH}/conf/" [ -f "${world}/config/make.conf" ] && cp "${world}/config/make.conf" "${build}/etc/" [ -f "${world}/config/src.conf" ] && cp "${world}/config/src.conf" "${build}/etc/" fi @@ -102,6 +103,7 @@ do m) MAKEOPTS="${MAKEOPTS} ${OPTARG}" ;; a) ARCH="${OPTARG}" ;; c) CONF="${OPTARG}" ;; + s) SRCS="${OPTARG}" ;; p) CHROOT_PREPARE="TRUE" ;; d) CHROOT_DIRTY="TRUE" ;; q) CHROOT_CLEAN="TRUE" ;; @@ -124,6 +126,15 @@ seed="${ROOT}/seed/base/$(uname -m)" # Root directory for chroot build="${world}/chroot" +if [ -z "${SRCS}" ] +then + # Locate a usable source tree + # Pick world/src over /usr/src if it exists at all, even if it is not usable, to provide warning of bad configs + SRCS="${world}/src" + [ -L "${SRCS}" -o -d "${SRCS}" ] || SRCS=/usr/src +fi +SRCS="$(realpath "${SRCS}")" + # Environment for chroot build env=" USER=root @@ -157,6 +168,7 @@ meh "Making world for ${ARCH}/${CONF}" prepare meh "Seed: ${seed}" +meh "Srctree: ${SRCS}" meh "Config: ${ARCH}/${CONF}" meh "Builddir: ${build}" meh "make ${MAKEOPTS}" -- 2.45.0