# 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
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()
# 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}
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
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
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
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
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
# 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
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") ))
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
echo -en "${BRACKET}[${COLOR}X${BRACKET}]${NORMAL} ${MSGSTRING}"
if [ "x${MSGSTRING}" != "x" ]; then
+ echo -n " ("
display_build_time
+ echo -n ")"
fi
echo