diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index af13d1751c..f9e729b649 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -4272,6 +4272,23 @@ build_port() { markfs prebuild ${mnt} fi ;; + build) + build_semaphore_dir="/tmp/build_semaphore/${BUILDNAME}" + mkdir -p "${build_semaphore_dir}" + build_semaphore_wait=${max_execution_time} + build_semaphore_path="${build_semaphore_dir}/${pkgname}" + build_semaphore_size=${BUILD_SEMAPHORE=${PARALLEL_JOBS}} + if [ ! -f "${build_semaphore_path}" ]; then + lockf -k "${build_semaphore_dir}/.lock" \ + timeout ${build_semaphore_wait} sh -c " + trap 'touch \"${build_semaphore_path}\"' 0 + trap 'rm -f \"${build_semaphore_dir}\"/*; exit 1' TERM + while [ \`ls -I \"${build_semaphore_dir}\" | wc -l\` -ge ${build_semaphore_size} ]; do + sleep 1 + done" + job_msg "Build semaphore ${build_semaphore_path} in" + fi + ;; run-depends) JUSER=root if [ "${PORTTESTING}" -eq 1 ]; then @@ -4392,6 +4409,7 @@ build_port() { "${originspec}" "${pkgname}" job_msg_verbose "Status ${COLOR_PORT}${port}${flavor:+@${flavor}} | ${pkgname}${COLOR_RESET}: ${COLOR_PHASE}timeout" fi + rm -f "${build_semaphore_path}" return 1 fi fi @@ -4409,6 +4427,11 @@ build_port() { return 1 fi + if [ "${phase}" = "build" ]; then + job_msg "Build semaphore ${build_semaphore_path} out" + rm -f "${build_semaphore_path}" + fi + if [ "${phase}" = "stage" -a "${PORTTESTING}" -eq 1 ]; then local die=0