X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions;h=ecd34f04cf8b44403614c79ee52a94bb937f6ee0;hb=4281eb80b9dcf56ac2cc042daa312a38a9d453f1;hp=7497f3a7746d238b15cfe1362bb4b6a101644d55;hpb=0028eaa73ae0c3bd1dbf90c4bd508ae705bc386f;p=hvlinux.git diff --git a/functions b/functions index 7497f3a..ecd34f0 100644 --- a/functions +++ b/functions @@ -1,6 +1,6 @@ #!/bin/bash -# This file is 'sourced' by other scripts, therefore the above line is of no -# use, except when modifying the file in emacs to have syntax highlighting. +set -o errtrace # Let shell functions inherit ERR trap. +set -o errexit # Constants for return codes EXIT_SUCCESS=0 @@ -733,6 +733,28 @@ ipkg_trap_handler() exit 1 } +ipkg_display_build_infos() +{ + echo "hvlinux: configure options:" + for opt in ${CONFIGURE_OPTS}; do + echo " ${opt}" + done + echo "hvlinux: environment variables:" + echo " HOST: ${CLFS_HOST}" + echo " TARGET: ${CLFS_TARGET}" + echo " BUILD64: ${BUILD64}" + echo " CFLAGS: ${CFLAGS}" + echo " CPPFLAGS: ${CPPFLAGS}" + echo " CXXFLAGS: ${CFLAGS}" + echo " LDFLAGS: ${LDFLAGS}" + echo " RANLIB: ${RANLIB}" + echo " CC: ${CC}" + echo " CXX: ${CXX}" + echo " AR: ${AR}" + echo " AS: ${AS}" + echo " PATH: ${PATH}" +} + # Installation of a package # Arg. #1: Package name and version (ex: gcc-4.5.1) # Remaining arguments: Additional configure options @@ -832,6 +854,12 @@ ipkg() echo "------------------------" 1>> ${LFS_LOG_FILE} echo "${MSGSTRING}" 1>> ${LFS_LOG_FILE} + exec 7>&1 # Save current "value" of stdout. + # All output from commands in this block sent to file $LFS_LOG_FILE. + exec >> ${LFS_LOG_FILE} 2>&1 + ipkg_display_build_infos + exec 1>&7 7>&- # Restore stdout and close file descriptor #7. + # All output from commands in this block sent to file $PACKAGE_LOG. exec > ${PACKAGE_LOG} 2>&1 @@ -934,6 +962,29 @@ rscr() return $EXIT_SUCCESS } +rcmd_trap_setup() +{ + exec 6>&1 # Save current "value" of stdout. + trap rcmd_trap_handler INT TERM EXIT ERR +} + +rcmd_trap_end() +{ + trap - INT TERM EXIT ERR + + # Restore global trap + #####hvtrap_setup +} + +rcmd_trap_handler() +{ + exec 1>&6 6>&- # Restore stdout and close file descriptor #6. + print_status failure + + ###rcmd_trap_end + ###exit 1 +} + # Run command, no log # First argument: Message to display during script # Second argument: command + arguments @@ -954,10 +1005,21 @@ rcmd() display_checkbox_msg ${MSGSTRING} + rcmd_trap_setup + echo ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} + if [ -n "${RCMD_NO_EXIT}" ]; then + set +e + fi + # Executing command ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} 2>&1 + + if [ -n "${RCMD_NO_EXIT}" ]; then + set -e + fi + if [ $? -ne 0 ]; then print_status failure if [ -n "${RCMD_NO_EXIT}" ]; then @@ -970,6 +1032,8 @@ rcmd() # Displaying build time after the package name print_status success + rcmd_trap_end + return $EXIT_SUCCESS }