From owner-svn-soc-all@FreeBSD.ORG Tue Jun 26 07:09:31 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id C3A89106564A for ; Tue, 26 Jun 2012 07:09:29 +0000 (UTC) (envelope-from scher@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Tue, 26 Jun 2012 07:09:29 +0000 Date: Tue, 26 Jun 2012 07:09:29 +0000 From: scher@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120626070929.C3A89106564A@hub.freebsd.org> Cc: Subject: socsvn commit: r238322 - soc2012/scher/par_ports/head/Mk X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2012 07:09:32 -0000 Author: scher Date: Tue Jun 26 07:09:29 2012 New Revision: 238322 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238322 Log: [fixed] ${_TERMINATE_PROCESS_TREE} and ${_PROCESS_ACTIVE_BUILDS} scripts are moved to bsd.parallel.mk since they are not used by non parallel builds. ${_TERMINATE_PROCESS_TREE} listens either to EXIT signal. Modified: soc2012/scher/par_ports/head/Mk/bsd.parallel.mk soc2012/scher/par_ports/head/Mk/bsd.port.mk Modified: soc2012/scher/par_ports/head/Mk/bsd.parallel.mk ============================================================================== --- soc2012/scher/par_ports/head/Mk/bsd.parallel.mk Tue Jun 26 06:02:43 2012 (r238321) +++ soc2012/scher/par_ports/head/Mk/bsd.parallel.mk Tue Jun 26 07:09:29 2012 (r238322) @@ -363,12 +363,127 @@ # End of Locking variables and tools section ##################################################### -locking-config-recursive: locking-config-message lock-port-dbdir config-conditional config-recursive unlock-port-dbdir +# +# _PROCESS_ACTIVE_BUILDS - this script contains all magic, related to +# processing of background dependecy builds. +# +# $${builds_num} - current number of spawned background dependecy +# builds. If $${builds_num} < ${_parv_PARALLEL_BUILDS_NUMBER} +# then another background dependency build will be +# spawned, if there is any dependency to be spawned. +# Otherwise "sleep ${CHECK_ACTIVE_TIMEOUT}" will be called. +# $${active_builds} - a list of "pid:path:dir[:target]" or "pid:lib:dir[:target]" +# tuples of all currently being processed ports, +# spawned by this make process. +# +_PROCESS_ACTIVE_BUILDS= \ + echo "---- dependency output ----- : --- ENTER _PROCESS_ACTIVE_BUILDS SECTION "; \ + while true; do \ + builds_num=$$( ${ECHO_CMD} $${active_builds} | wc -w ); \ + if [ $${builds_num} -lt ${_parv_PARALLEL_BUILDS_NUMBER} ] && [ $${\#depends} -ne 0 ]; then \ + echo "---- dependency output ----- : WE CAN START ANOTHER PAR BUILD "; \ + break; \ + fi; \ + if [ $${builds_num} -eq 0 ] && [ $${\#depends} -eq 0 ]; then \ + ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ + break; \ + fi; \ + for build in $$( ${ECHO_CMD} "$${active_builds}" ); do \ + pid=$${build%%:*}; \ + dep=$${build\#*:}; \ + ps -p $${pid} > /dev/null || { \ + wait $${pid} && status=$$? || status=$$?; \ + if [ $${status} -eq 0 ]; then \ + echo "---- dependency output ----- : SOME DEP IS INSTALLED ($${dep}) "; \ + echo "---- dependency output ----- : ACTIVE BUILDS WAS _$${active_builds}_ "; \ + active_builds="$${active_builds%%$${build}*} $${active_builds\#\#*$${build}}"; \ + active_builds=$$( echo "$${active_builds}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ + builds_num=$$(( $${builds_num} - 1 )); \ + echo "---- dependency output ----- : ACTIVE BUILDS NOW _$${active_builds}_ "; \ + if [ ${.TARGET} = "lib-depends" ]; then \ + lib=$${dep%%:*}; \ + pattern="`${ECHO_CMD} $$lib | ${SED} -E -e 's/\./\\\\./g' -e 's/(\\\\)?\+/\\\\+/g'`"; \ + if ! ${LDCONFIG} ${_LDCONFIG_FLAGS} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \ + ${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \ + ${FALSE}; \ + fi; \ + fi; \ + elif [ $${status} -eq ${_parv_MAKE_LOCK_EXIT_STATUS} ]; then \ + echo "---- dependency output ----- : SOME DEP IS LOCKED ($${dep}) "; \ + echo "---- dependency output ----- : ACTIVE BUILDS WAS _$${active_builds}_ "; \ + active_builds="$${active_builds%%$${build}*} $${active_builds\#\#*$${build}}"; \ + active_builds=$$( echo "$${active_builds}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ + builds_num=$$(( $${builds_num} - 1 )); \ + echo "---- dependency output ----- : ACTIVE BUILDS NOW _$${active_builds}_ "; \ + echo "---- dependency output ----- : ADD IT BACK DO DEPENDS LIST "; \ + echo "---- dependency output ----- : DEPENDS WAS _$${depends}_ "; \ + depends="$${depends} $${dep}"; \ + depends=$$( echo "$${depends}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ + echo "---- dependency output ----- : DEPENDS NOW _$${depends}_ "; \ + else \ + ${ECHO_CMD} "Errors occured while building a dependency (PID - $${pid}): $${dep}"; \ + ${ECHO_CMD} "Checkout it's log"; \ + ${ECHO_CMD} "Terminating..."; \ + ${_TERMINATE_PROCESS_TREE}; \ + fi; \ + }; \ + done; \ + if { [ $${builds_num} -eq ${_parv_PARALLEL_BUILDS_NUMBER} ] || \ + ( [ $${builds_num} -gt 0 ] && [ $${\#depends} -eq 0 ] ); }; then \ + if [ ${_parv_WANT_PARALLEL_BUILD} ]; then \ + echo "---- dependency output ----- : CAN'T SPAWN MORE DEPS! SLEEP... "; \ + fi; \ + sleep ${CHECK_ACTIVE_TIMEOUT}; \ + fi; \ + done; \ + echo "---- dependency output ----- : --- LEAVE _PROCESS_ACTIVE_BUILDS SECTION " + +# +# _TERMINATE_PROCESS_TREE - this script contains all magic, related to +# terminating of the whole process tree, starting +# from ${.MAKE.PID}. +# This script implements Breadth-first traversal of +# the process tree. It prevents processes of the +# current level from evaluation of any commands using +# STOP signal. Then it determines children of +# processes of the current level of process tree +# and stops them and so forth... +# It is necessary to stop processes to avoid new +# untracked pids. Finally, this script kills $${pids_to_kill} +# +# $${pids_to_kill} - all pids of the process tree, starting from ${.MAKE.PID} +# +_TERMINATE_PROCESS_TREE= \ + [ $$? -eq 0 ] && exit 0; \ + ${ECHO_CMD} Terminating process tree strating from ${.MAKE.PID}; \ + pids_to_kill=${.MAKE.PID}; \ + /bin/kill -STOP ${.MAKE.PID} 2> /dev/null || ${DO_NADA}; \ + ppids=$$( ps -xao pid,ppid | awk "{ if (\$$2==${.MAKE.PID}) {print \$$1} }" ); \ + pids_to_kill="$${pids_to_kill} $${ppids}"; \ + /bin/kill -STOP "$${ppids%%$$$$*} $${ppids\#\#*$$$$}" 2> /dev/null || ${DO_NADA}; \ + while true; do \ + tmp_ppids=$$(${ECHO_CMD} $${ppids}); \ + ppids=""; \ + for ppid in $${tmp_ppids}; do \ + children=$$( ps -xao pid,ppid | awk "{ if (\$$2==$${ppid}) {print \$$1} }" ); \ + if [ $${\#children} -eq 0 ]; then continue; fi; \ + pids_to_kill="$${pids_to_kill} $${children}"; \ + ppids="$${ppids} $${children}"; \ + /bin/kill -STOP $${children} 2> /dev/null || ${DO_NADA}; \ + done; \ + if [ $${\#ppids} -eq 0 ]; then break; fi; \ + done; \ + ${ECHO_CMD} PIDs to kill: $${pids_to_kill}; \ + /bin/kill -KILL $${pids_to_kill} 2> /dev/null || ${DO_NADA} + +##################################################### + +locking-config-recursive: locking-config-message lock-port-dbdir config-recursive unlock-port-dbdir locking-config-message: @${ECHO_MSG} "===> Setting user-specified options for ${PKGNAME} and dependencies"; -config-recursive: +config-recursive: config-conditional @for dir in $$(${MAKE} run-depends-list build-depends-list | uniq); do \ while true; do \ ( cd $$dir; ${MAKE} locking-config-recursive ) || { \ Modified: soc2012/scher/par_ports/head/Mk/bsd.port.mk ============================================================================== --- soc2012/scher/par_ports/head/Mk/bsd.port.mk Tue Jun 26 06:02:43 2012 (r238321) +++ soc2012/scher/par_ports/head/Mk/bsd.port.mk Tue Jun 26 07:09:29 2012 (r238322) @@ -1133,12 +1133,6 @@ # It does not matter what value is assigned. # Example: _parv_WANT_PARALLEL_BUILD=yes # -# CHECK_ACTIVE_TIMEOUT -# - timeout in seconds before next check of active builds in case -# if port is prohibit to spawn another background process. -# Consider that this variable is also used in non-parallel build. -# Default: 2 -# ############### ENDF OF PAR_PORTS SPECIFIC COMMENT LINE ############### # # End of the list of all variables that need to be defined in a port. @@ -1160,16 +1154,11 @@ ############### PAR_PORTS SPECIFIC COMMENT LINE ############### -CHECK_ACTIVE_TIMEOUT?= 2 - .if defined(_parv_WANT_PARALLEL_BUILD) .include "${PORTSDIR}/Mk/bsd.parallel.mk" .endif -# non-parallel build -.if !defined(_parv_WANT_PARALLEL_BUILD) -_parv_PARALLEL_BUILDS_NUMBER= 1 -.endif +_PROCESS_ACTIVE_BUILDS?= ${DO_NADA} .if !target(lock-port-dbdir) lock-port-dbdir: @@ -4359,7 +4348,7 @@ check-categories check-makevars check-desktop-entries \ check-depends check-active-build-conflicts identify-install-conflicts check-deprecated \ check-vulnerable check-license check-config buildanyway-message \ - options-message locking-config-recursive + options-message locking-config-recursive seal _PKG_DEP= check-sanity locking-config-recursive _PKG_SEQ= pkg-depends @@ -5104,128 +5093,6 @@ fi; \ fi; \ -############### PAR_PORTS SPECIFIC COMMENT LINE ############### -# -# _PROCESS_ACTIVE_BUILDS - this script contains all magic, related to -# processing of background dependecy builds. -# -# $${builds_num} - current number of spawned background dependecy -# builds. If $${builds_num} < ${_parv_PARALLEL_BUILDS_NUMBER} -# then another background dependency build will be -# spawned, if there is any dependency to be spawned. -# Otherwise "sleep ${CHECK_ACTIVE_TIMEOUT}" will be called. -# $${active_builds} - a list of "pid:path:dir[:target]" or "pid:lib:dir[:target]" -# tuples of all currently being processed ports, -# spawned by this make process. -# -############### END OF PAR_PORTS SPECIFIC COMMENT LINE ############### - -.if defined(_parv_WANT_PARALLEL_BUILD) -_PROCESS_ACTIVE_BUILDS= \ - echo "---- dependency output ----- : --- ENTER _PROCESS_ACTIVE_BUILDS SECTION "; \ - while true; do \ - builds_num=$$( ${ECHO_CMD} $${active_builds} | wc -w ); \ - if [ $${builds_num} -lt ${_parv_PARALLEL_BUILDS_NUMBER} ] && [ $${\#depends} -ne 0 ]; then \ - echo "---- dependency output ----- : WE CAN START ANOTHER PAR BUILD "; \ - break; \ - fi; \ - if [ $${builds_num} -eq 0 ] && [ $${\#depends} -eq 0 ]; then \ - ${ECHO_MSG} "===> Returning to build of ${PKGNAME}"; \ - break; \ - fi; \ - for build in $$( ${ECHO_CMD} "$${active_builds}" ); do \ - pid=$${build%%:*}; \ - dep=$${build\#*:}; \ - ps -p $${pid} > /dev/null || { \ - wait $${pid} && status=$$? || status=$$?; \ - if [ $${status} -eq 0 ]; then \ - echo "---- dependency output ----- : SOME DEP IS INSTALLED ($${dep}) "; \ - echo "---- dependency output ----- : ACTIVE BUILDS WAS _$${active_builds}_ "; \ - active_builds="$${active_builds%%$${build}*} $${active_builds\#\#*$${build}}"; \ - active_builds=$$( echo "$${active_builds}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ - builds_num=$$(( $${builds_num} - 1 )); \ - echo "---- dependency output ----- : ACTIVE BUILDS NOW _$${active_builds}_ "; \ - if [ ${.TARGET} = "lib-depends" ]; then \ - lib=$${dep%%:*}; \ - pattern="`${ECHO_CMD} $$lib | ${SED} -E -e 's/\./\\\\./g' -e 's/(\\\\)?\+/\\\\+/g'`"; \ - if ! ${LDCONFIG} ${_LDCONFIG_FLAGS} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \ - ${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \ - ${FALSE}; \ - fi; \ - fi; \ - elif [ $${status} -eq ${_parv_MAKE_LOCK_EXIT_STATUS} ]; then \ - echo "---- dependency output ----- : SOME DEP IS LOCKED ($${dep}) "; \ - echo "---- dependency output ----- : ACTIVE BUILDS WAS _$${active_builds}_ "; \ - active_builds="$${active_builds%%$${build}*} $${active_builds\#\#*$${build}}"; \ - active_builds=$$( echo "$${active_builds}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ - builds_num=$$(( $${builds_num} - 1 )); \ - echo "---- dependency output ----- : ACTIVE BUILDS NOW _$${active_builds}_ "; \ - echo "---- dependency output ----- : ADD IT BACK DO DEPENDS LIST "; \ - echo "---- dependency output ----- : DEPENDS WAS _$${depends}_ "; \ - depends="$${depends} $${dep}"; \ - depends=$$( echo "$${depends}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ - echo "---- dependency output ----- : DEPENDS NOW _$${depends}_ "; \ - else \ - ${ECHO_CMD} "Errors occured while building a dependency (PID - $${pid}): $${dep}"; \ - ${ECHO_CMD} "Checkout it's log"; \ - ${ECHO_CMD} "Terminating..."; \ - ${_TERMINATE_PROCESS_TREE}; \ - fi; \ - }; \ - done; \ - if { [ $${builds_num} -eq ${_parv_PARALLEL_BUILDS_NUMBER} ] || \ - ( [ $${builds_num} -gt 0 ] && [ $${\#depends} -eq 0 ] ); }; then \ - if [ ${_parv_WANT_PARALLEL_BUILD} ]; then \ - echo "---- dependency output ----- : CAN'T SPAWN MORE DEPS! SLEEP... "; \ - fi; \ - sleep ${CHECK_ACTIVE_TIMEOUT}; \ - fi; \ - done; \ - echo "---- dependency output ----- : --- LEAVE _PROCESS_ACTIVE_BUILDS SECTION " -.else -_PROCESS_ACTIVE_BUILDS= ${DO_NADA} -.endif - -############### PAR_PORTS SPECIFIC COMMENT LINE ############### -# -# _TERMINATE_PROCESS_TREE - this script contains all magic, related to -# terminating of the whole process tree, starting -# from ${.MAKE.PID}. -# This script implements Breadth-first traversal of -# the process tree. It prevents processes of the -# current level from evaluation of any commands using -# STOP signal. Then it determines children of -# processes of the current level of process tree -# and stops them and so forth... -# It is necessary to stop processes to avoid new -# untracked pids. Finally, this script kills $${pids_to_kill} -# -# $${pids_to_kill} - all pids of the process tree, starting from ${.MAKE.PID} -# -############### END OF PAR_PORTS SPECIFIC COMMENT LINE ############### - -_TERMINATE_PROCESS_TREE= \ - ${ECHO_CMD} Terminating process tree strating from ${.MAKE.PID}; \ - pids_to_kill=${.MAKE.PID}; \ - /bin/kill -STOP ${.MAKE.PID} 2> /dev/null || ${DO_NADA}; \ - ppids=$$( ps -xao pid,ppid | awk "{ if (\$$2==${.MAKE.PID}) {print \$$1} }" ); \ - pids_to_kill="$${pids_to_kill} $${ppids}"; \ - /bin/kill -STOP "$${ppids%%$$$$*} $${ppids\#\#*$$$$}" 2> /dev/null || ${DO_NADA}; \ - while true; do \ - tmp_ppids=$$(${ECHO_CMD} $${ppids}); \ - ppids=""; \ - for ppid in $${tmp_ppids}; do \ - children=$$( ps -xao pid,ppid | awk "{ if (\$$2==$${ppid}) {print \$$1} }" ); \ - if [ $${\#children} -eq 0 ]; then continue; fi; \ - pids_to_kill="$${pids_to_kill} $${children}"; \ - ppids="$${ppids} $${children}"; \ - /bin/kill -STOP $${children} 2> /dev/null || ${DO_NADA}; \ - done; \ - if [ $${\#ppids} -eq 0 ]; then break; fi; \ - done; \ - ${ECHO_CMD} PIDs to kill: $${pids_to_kill}; \ - /bin/kill -KILL $${pids_to_kill} 2> /dev/null || ${DO_NADA} - ############### PAR_PORTS SPECIFIC COMMENT LINE ############### # # $${notfound} codes : 0 - dep found @@ -5239,7 +5106,7 @@ .if defined(${deptype}_DEPENDS) .if !defined(NO_DEPENDS) @if [ ! ${INSTALLS_DEPENDS} ]; then \ - trap '${_TERMINATE_PROCESS_TREE}' INT TERM; \ + trap '${_TERMINATE_PROCESS_TREE}' EXIT INT TERM; \ fi; \ depends=`${ECHO_CMD} "${${deptype}_DEPENDS}"`; \ depends=$$( echo "$${depends}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ @@ -5319,7 +5186,7 @@ pkg_info=`${PKG_INFO} -E "$$inverse_dep" || ${TRUE}`; \ if [ "$$pkg_info" != "" ]; then \ ${ECHO_MSG} "===> Found $$pkg_info, but you need to upgrade to $$prog."; \ - ${_TERMINATE_PROCESS_TREE}; \ + exit 1; \ fi; \ fi; \ elif ${WHICH} "$$prog" > /dev/null 2>&1 ; then \ @@ -5391,7 +5258,7 @@ lib-depends: .if defined(LIB_DEPENDS) && !defined(NO_DEPENDS) @if [ ! ${INSTALLS_DEPENDS} ]; then \ - trap '${_TERMINATE_PROCESS_TREE}' INT TERM; \ + trap '${_TERMINATE_PROCESS_TREE}' EXIT INT TERM; \ fi; \ depends=`${ECHO_CMD} "${LIB_DEPENDS}"`; \ depends=$$( echo "$${depends}" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$$//' ); \ @@ -5451,6 +5318,11 @@ ${ECHO_MSG} " => No directory for $$lib. Skipping.."; \ else \ ${_INSTALL_DEPENDS} \ + if [ !${_parv_WANT_PARALLEL_BUILD} ]; then \ + if ! ${LDCONFIG} ${_LDCONFIG_FLAGS} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \ + ${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \ + ${FALSE}; \ + fi; \ if [ $${spawned} ]; then \ echo "---- dependency output ----- : SPAWNED PID $${spawned}"; \ active_builds="$${active_builds} $${spawned}:$${i}"; \