From c30fb25c21971a9ef055c8eb6d02be264bff1d8d Mon Sep 17 00:00:00 2001 From: gobo72 Date: Fri, 26 Aug 2011 04:28:53 +0000 Subject: [PATCH] =?utf8?q?-Chaque=20paquet=20install=C3=A9=20avec=20succ?= =?utf8?q?=C3=A8s=20a=20maintenant=20un=20fichier=20paquet.done?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- functions/fpkg | 2 ++ functions/main | 90 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/functions/fpkg b/functions/fpkg index dd855d9..7a17a83 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -61,6 +61,8 @@ update_packages_init() # downloading other packages export RCMD_NO_EXIT=1 + test_presence_of_packages_directory + # First create log directory if it does not exists. if [ ! -d ${LFS_LOG_DIR} ]; then install -m755 -d ${LFS_LOG_DIR} || exit 1 diff --git a/functions/main b/functions/main index 21f8a31..b02efa8 100644 --- a/functions/main +++ b/functions/main @@ -30,14 +30,14 @@ source ../config/packages-list # Load default values source ../config/sysinfos.default +# Load user-defined configuration values if [ ! -f ../config/sysinfos ]; then echo "Missing config/sysinfos configuration file." return ${EXIT_FAILURE} +else + source ../config/sysinfos fi -# Load user-defined configuration values -source ../config/sysinfos - # We want hvtrap_setup called only with the first sourcing of this script. if [ -z "${HVTRAP_SETUP_DONE1}" ]; then hvtrap_setup @@ -126,6 +126,14 @@ fi CLFS=${LFS} +test_presence_of_packages_directory() +{ + if [ ! -d "$(dirname $(pwd))/packages" ]; then + echo "Error, could not find packages directory \"$(dirname $(pwd))/packages\", aborting." + exit 1 + fi +} + # Create log directory and log file for current stage if necessary # This should be done automatically... init_log_file() @@ -133,10 +141,7 @@ init_log_file() # Scripts directory export SCRDIR=$(pwd) - if [ ! -d "$(dirname $(pwd))/packages" ]; then - echo "Error, could not find packages directory \"$(dirname $(pwd))/packages\", aborting." - exit 1 - fi + test_presence_of_packages_directory export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} @@ -796,6 +801,28 @@ ipkg_display_build_infos() echo " GCC CPU OPTIONS: ${GCCCPUOPT}" } +# Arg. #1: Package label +indicate_pkg_build_complete() +{ + # Checking for correct number of arguments + if [ $# -ne 1 ]; then + echo "${FUNCNAME}(): Missing argument(s)" + exit ${EXIT_FAILURE} + fi + + local HVLABEL=${1} + + # The following will be renamed to PACKAGE_DONE in one atomic operation. + local PACKAGE_STATUS=${LFS_LOG_DIR}/${HVLABEL}.status + local PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done + + ipkg_display_build_infos > ${PACKAGE_STATUS} + echo -n "Build time: " >> ${PACKAGE_STATUS} + display_build_time >> ${PACKAGE_STATUS} + echo -e "\n" >> ${PACKAGE_STATUS} + mv ${PACKAGE_STATUS} ${PACKAGE_DONE} +} + # Installation of a package # Arg. #1: Package name and version (ex: gcc-4.5.1) # Remaining arguments: Additional configure options @@ -878,9 +905,10 @@ ipkg() fi PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log + PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done # Checking if package was previously successfully installed - if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then + if [ -f ${PACKAGE_DONE} ]; then return $EXIT_SUCCESS fi @@ -893,12 +921,6 @@ 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 @@ -915,12 +937,15 @@ ipkg() exec 1>&6 # Restore stdout. - # Writing success string to the end of the log file - echo "${HVLABEL} successfully installed" 1>> ${LFS_LOG_FILE} - - # Displaying build time after the package name + # Displaying build time after the package name. print_status success + # Indicate success in global log file. + echo "Completed" 1>> ${LFS_LOG_FILE} + + # Report successfull installation of the package. + indicate_pkg_build_complete ${HVLABEL} + ipkg_trap_end return $EXIT_SUCCESS @@ -973,10 +998,11 @@ rscr() fi PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log + PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done if [ "x${SCRMODE}" = "xonce" ]; then # Checking if package was previously successfully installed - if grep -q "^${HVLABEL} successfully installed" ${LFS_LOG_FILE}; then + if [ -f ${PACKAGE_DONE} ]; then return $EXIT_SUCCESS fi fi @@ -991,14 +1017,17 @@ rscr() # Executing script ${SCRDIR}/${SCRIPT} ${SCRIPT_ARGS} 1>> ${PACKAGE_LOG} 2>&1 + # Displaying build time after the package name. + print_status success + + # Indicate success in global log file. + echo "Completed" 1>> ${LFS_LOG_FILE} + if [ "x${SCRMODE}" = "xonce" ]; then - # Writing success string to the end of the log file - echo "${HVLABEL} successfully installed" 1>> ${LFS_LOG_FILE} + # Report successfull installation of the package. + indicate_pkg_build_complete ${HVLABEL} fi - # Displaying build time after the package name - print_status success - ipkg_trap_end return $EXIT_SUCCESS @@ -1085,7 +1114,7 @@ get_total_build_time() exit ${EXIT_FAILURE} fi - TIMES=$(cat ${INFILE} | grep "Build time:" | sed "s!Build time: \(.*\)h!\1!g") + TIMES=$(cat ${LFS_LOG_DIR}/*.done | grep "Build time:" | sed "s!Build time: \(.*\)h!\1!g") for time in ${TIMES}; do HOURS=$(( $HOURS + $(echo ${time} | sed "s!^\([0-9]*\)\..*!\1!g") )) @@ -1107,27 +1136,22 @@ display_build_time() END_TIME=$(echo `date +%s`) HOURS=$(( ( ${END_TIME} - ${START_TIME} ) / 3600 )) - echo -n " ("${HOURS}"." - echo -n " Build time: ${HOURS}." 1>> ${LFS_LOG_FILE} + echo -n ${HOURS}"." # Time is inferior to 1 hour... MINUTES=$(( ( ( ${END_TIME} - ${START_TIME} ) % 3600 ) / 36 )) if [ ${MINUTES} -lt 10 ]; then echo -n "0" - echo -n "0" 1>> ${LFS_LOG_FILE} fi if [ ${MINUTES} -eq 0 ]; then echo -n "1" - echo -n "1" 1>> ${LFS_LOG_FILE} else echo -n ${MINUTES} - echo -n ${MINUTES} 1>> ${LFS_LOG_FILE} fi - echo -n "h)" - echo "h" 1>> ${LFS_LOG_FILE} + echo -n "h" } # Global variable: MSGSTRING @@ -1175,7 +1199,9 @@ print_status() echo -en "${BRACKET}[${COLOR}X${BRACKET}]${NORMAL} ${MSGSTRING}" if [ "x${MSGSTRING}" != "x" ]; then + echo -n " (" display_build_time + echo -n ")" fi echo -- 2.20.1