X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Fmain;h=9e4fc4dd9151ec664e4bcd24798d245726c30d71;hb=6890ab467c34bc0ae1fccf18a521c3cedfa442a2;hp=246031492ef94cac1ccb78d5b8cf55066a1b17a8;hpb=f17ab848cb756cad27489bf0c2746e5ead466658;p=hvlinux.git diff --git a/functions/main b/functions/main index 2460314..9e4fc4d 100644 --- a/functions/main +++ b/functions/main @@ -2,8 +2,8 @@ set -o errtrace # Let shell functions inherit ERR trap. set -o errexit -# Don' t locate and remember (hash) commands as they are looked up for -# execution (don' t remember path): +# Don't locate and remember (hash) commands as they are looked up for +# execution (don't remember path): set +h hvtrap_setup() @@ -94,40 +94,20 @@ DEFAULT_IPKG_SCRIPT="ipkg.def" HVMAKE="make -j ${MAKEJOBS}" -case "${HVL_TARGET}" in - arm*) - CLFS_BUILDFLAGS="-mabi=aapcs-linux -mfloat-abi=soft" - CLFS_TARGET="arm-linux-gnueabi" - CLFS_ARCH=arm - CLFS_ENDIAN=LITTLE - ;; - "x86_64") - CLFS_BUILDFLAGS="-m64" - CLFS_TARGET="${HVL_TARGET}-unknown-linux-gnu" - CLFS_ARCH=${HVL_TARGET} - ;; - "x86") - # No special flags - CLFS_BUILDFLAGS="" - CLFS_TARGET="i686-unknown-linux-gnu" - CLFS_ARCH=${HVL_TARGET} - ;; - m68k*) - #CLFS_BUILDFLAGS="-mcpu=51jm" - CLFS_BUILDFLAGS="" - CLFS_TARGET="${HVL_TARGET}-unknown-linux-gnu" - CLFS_ARCH=${HVL_TARGET} - ;; - *) - echo "Unsupported target architecture: ${HVL_TARGET}" - return ${EXIT_FAILURE} - ;; -esac +# Load default values. They can be overriden +# by a target-specific file +source ../targets/default + +if [ -f ../targets/${HVL_TARGET} ]; then + source ../targets/${HVL_TARGET} +fi + +CLFS_TARGET="${CLFS_ARCH}-${CLFS_OS}-${CLFS_ABI}" CLFS_HOST="$(echo $MACHTYPE | \ sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")" -export CLFS_BUILDFLAGS CLFS_TARGET CLFS_ARCH CLFS_HOST CLFS_ENDIAN +export CLFS_BUILDFLAGS CLFS_TARGET CLFS_ARCH CLFS_HOST test_presence_of_packages_directory() { @@ -138,18 +118,26 @@ test_presence_of_packages_directory() } # Create log directory and log file for current stage if necessary -# This should be done automatically... -init_log_file() +# Arg #1: log file name +static_init_log_file() { + # Checking for correct number of arguments + if [ $# -ne 1 ]; then + echo "${FUNCNAME}(), wrong number of arguments: ${*}" + return 1 + fi + + local LOG_FILE_NAME=${1} + # Scripts directory export SCRDIR=$(pwd) test_presence_of_packages_directory - export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" - export LFS_PATCHES_DIR="${SCRDIR}/patches" + export LFS_PKG_BASE="$(dirname $(pwd))/packages" + export LFS_PKG_DIR="${LFS_PKG_BASE}/${LFS_STAGE}" export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} - export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log + export LFS_LOG_FILE=${LFS_LOG_DIR}/${LOG_FILE_NAME} export LFS_TMP="${LFS}/tmp" mkdir -p ${LFS_LOG_DIR} && @@ -158,6 +146,20 @@ init_log_file() fi } +# Create log directory and install log file for current stage if necessary +init_log_file() +{ + static_init_log_file "install.log" + export LFS_PATCHES_DIR="${SCRDIR}/patches" +} + +# Create log directory and update log file for current stage if necessary +init_log_file_update() +{ + static_init_log_file "pkg-update.log" + export LFS_PATCHES_DIR="${LFS_PKG_DIR}/patches" +} + # Check that we are logged in as the root user, and exit if this is not the case. check_for_root_user() { @@ -1146,15 +1148,15 @@ get_total_build_time() for time in ${TIMES}; do HOURS=$(( $HOURS + $(echo ${time} | sed "s!^\([0-9]*\)\..*!\1!g") )) - + # The first SED command extracts the minutes (fractions of an hour). # The second SED command removed the leading zero, if applicable. MIN=$(( $MIN + $(echo ${time} | sed "s!.*\.\([0-9][0-9]\)!\1!g" | sed "s!^0\([0-9]\)!\1!g" ) )) done - + HOURS=$(( ${HOURS} + ( ${MIN} / 100 ) )) MIN=$(( ${MIN} % 100 )) - + echo "${HOURS}.${MIN}" }