print_status DONE
}
-# Launches a timer process as a co-process
-launch_timer() {
- # Do nothing if the timer is already running
- if [ -n "${TIMER_PID}" ]; then
- return 0
- fi
-
- # Don't launch the timer when we are not on a terminal
- if ! is_terminal; then
- return 0
- fi
-
- # Launch the co-process
- coproc TIMER { "${0}" "__timer" "$$"; }
-
- # Register the signal handlers
- trap "__timer_event" SIGUSR1
- trap "terminate_timer" EXIT
-}
-
-# Terminates a previously launched timer
-terminate_timer() {
- if [ -n "${TIMER_PID}" ]; then
- kill -TERM "${TIMER_PID}"
- fi
-}
-
-# The timer main loop
-__timer() {
- local pid="${1}"
-
- # Send SIGUSR1 to the main process once a second
- # If the parent process has gone away, we will terminate.
- while sleep 1; do
- if ! kill -USR1 "${pid}" &>/dev/null; then
- break
- fi
- done
-
- return 0
-}
-
-# Called when the timer triggers
-# This function does nothing, but is needed interrupt the wait call
-__timer_event() {
- return 0
-}
-
exiterror() {
# Dump logfile
if [ -n "${LOGFILE}" ] && [ -e "${LOGFILE}" ]; then
local chroot="false"
local command=()
local interactive="false"
- local timer
local network="false"
# Collect environment variables
)
;;
- --timer=*)
- timer="${1#--timer=}"
- ;;
-
-*)
echo "Unknown argument: ${1}" >&2
return 2
;;
false)
- # Launch the timer if needed
- if [ -n "${timer}" ]; then
- launch_timer
- fi
-
# Dispatch the command to the background
{
"${execute[@]}" >> "${LOGFILE}" 2>&1 </dev/null
r="$?"
case "${r}" in
- # Code means that we have received SIGUSR1 from the timer
- 138)
- # Call the timer callback
- if [ -n "${timer}" ]; then
- "${timer}"
- fi
-
- # Go back and wait
- continue
- ;;
-
# Ignore SIGWINCH
156)
continue
break
done
- # Call the timer callback at least once
- if [ -n "${timer}" ]; then
- "${timer}"
- fi
+ # Print the total runtime
+ print_runtime "$(( SECONDS - t ))"
esac
return "${r}"
exiterror "Downloading ${pkg}"
fi
- if ! make_pkg --timer="update_runtime" "${pkg}" TOOLCHAIN=1 ROOT="${BUILD_DIR}" b2 install "$@"; then
+ if ! make_pkg "${pkg}" TOOLCHAIN=1 ROOT="${BUILD_DIR}" b2 install "$@"; then
print_status FAIL
exiterror "Building ${pkg}"
fi
# Run install on the package
- if ! make_pkg --chroot --timer="update_runtime" \
- "${args[@]}" "${pkg}" b2 install "$@"; then
+ if ! make_pkg --chroot "${args[@]}" "${pkg}" b2 install "$@"; then
print_status FAIL
exiterror "Building ${pkg}"
[ $? == 1 ] && return 0
# Run dist on the package
- if ! make_pkg --chroot --timer="update_runtime" "${pkg}" dist "$@"; then
+ if ! make_pkg --chroot "${pkg}" dist "$@"; then
print_status FAIL
exiterror "Packaging ${pkg}"
print_status DONE
}
-update_runtime() {
- print_runtime "$(( SECONDS - t ))"
-}
-
qemu_is_required() {
local build_arch="${1}"
print_status FAIL
fi
;;
-__timer)
- __timer "${2}" || exit $?
- ;;
*)
echo "Usage: $0 [OPTIONS] {build|check-manualpages|clean|downloadsrc|find-dependencies|gettoolchain|lang|shell|tail|toolchain|update-contributors|uploadsrc}"
cat doc/make.sh-usage