#!/bin/sh # $UFP$ #set -x set -eu -o pipefail #ARCH_DIR=amd64.amd64 CCACHE=/usr/local/bin/ccache CCACHE_DIR=/var/cache/ccache/base DATE=/bin/date DATE_FORMAT="+%Y%m%d-%H%M%S" GIT_CANDIDATES="/usr/local/bin/git /usr/bin/git /usr/bin/gitlite" MAKE=/usr/bin/make MKDIR=/bin/mkdir RENICE=/usr/bin/renice RENICE_ARGS="-n 10 -p ${$}" OBJECT_TREE=/usr/obj RM=/bin/rm SCRIPT=/usr/bin/script SOURCE_TREE=/usr/src SYSCTL=/sbin/sysctl TIME=/usr/bin/time TIME_FLAGS=-l TYPESCRIPT_DIR=/root/tmp WEAK_CPU=0 # We better use the C locale consistently. export LANG=C.UTF-8 #${RENICE} ${RENICE_ARGS} if [ ! -d ${TYPESCRIPT_DIR} ]; then ${MKDIR} -p ${TYPESCRIPT_DIR} if [ ! -d ${TYPESCRIPT_DIR} ]; then echo "${0}: unable to access directory ${TYPESCRIPT_DIR} nor able to create it" >/dev/stderr exit 69 fi fi # Determine which git executable to run. for cand in ${GIT_CANDIDATES}; do if [ -x ${cand} ]; then GIT=${cand} break fi done if [ -z "${GIT}" ]; then echo "${0}: neither of ${GIT_CANDIDATES} are useable" >/dev/stderr exit 69 fi # Determine if we need to clean up the object tree. #if [ "${1}" = "cleanup" -o ${SOURCE_TREE}/sys/sys/param.h -nt ${OBJECT_TREE}${SOURCE_TREE}/${ARCH_DIR}/bin/sh/sh -o ${SOURCE_TREE}/lib/clang/include/clang/Basic/Version.inc -nt ${OBJECT_TREE}${SOURCE_TREE}/${ARCH_DIR}/usr.bin/clang/clang/clang ]; then #fi # Simplified the condition for cleaning up the object tree because of meta mode. if [ "${#}" -gt 0 ] && [ "${1}" = "cleanup" ]; then echo "${0}: cleaning up ${OBJECT_TREE} ..." ${RM} -Rf -- ${OBJECT_TREE}/* fi # These variables take some time to compute. echo "${0}: inquiring Git about branch name, revision count, and latest commit hash ..." GIT_BRANCH=`${GIT} -C /usr/src rev-parse --abbrev-ref HEAD | sed 's|[/+]|-|g'` GIT_COMMIT_COUNT=`${GIT} -C ${SOURCE_TREE} rev-list --first-parent --count HEAD` GIT_SHORT_COMMIT_HASH=`${GIT} -C ${SOURCE_TREE} rev-parse --verify --short=12 HEAD` if [ -z "${GIT_BRANCH}" ]; then echo "${0}: zero length GIT_BRANCH" >/dev/stderr exit 69 fi if [ -z "${GIT_COMMIT_COUNT}" ]; then echo "${0}: zero length GIT_COMMIT_COUNT" >/dev/stderr exit 69 fi if [ -z "${GIT_SHORT_COMMIT_HASH}" ]; then echo "${0}: zero length GIT_SHORT_COMMIT_HASH" >/dev/stderr exit 69 fi echo "${0}: ... done" NCPU=`${SYSCTL} -n hw.ncpu` if [ "${WEAK_CPU}" = 1 ]; then NCPU=$((${NCPU} - 2)) fi readonly NCPU # Ensure the ccache contents and statistics are sane before proceeding. echo "${0}: ensuring ${CCACHE_DIR} has sane contents, statistics, etc ..." CCACHE_DIR=${CCACHE_DIR} ${CCACHE} -c || exit echo "${0}: ... done." # Resetting the ccache statistics prior to this run. echo "${0}: zeroing statistics in ${CCACHE_DIR} ..." CCACHE_DIR=${CCACHE_DIR} ${CCACHE} -z || exit echo "${0}: ... done." # -D NO_CLEAN is now specified in /etc/src.conf as WITHOUT_CLEAN=yes ${SCRIPT} -at 0 ${TYPESCRIPT_DIR}/make-buildworld-buildkernel-`${DATE} ${DATE_FORMAT}`-${GIT_BRANCH}-n${GIT_COMMIT_COUNT}-${GIT_SHORT_COMMIT_HASH}.txt ${TIME} ${TIME_FLAGS} ${MAKE} -C ${SOURCE_TREE} -j ${NCPU} -k buildworld buildkernel # EOF