X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions;h=1fb9fa43c3af5728aede071c0b4586a48b338fb0;hb=6a47d6d86ad7ac2d58c56499baaedb9fdd0aa800;hp=7afb02363f41d887b727e2f71099425cf7d2e4a4;hpb=b2f91df3e7c1d1ca93ced97b5001e3134243666b;p=hvlinux.git diff --git a/functions b/functions index 7afb023..1fb9fa4 100644 --- a/functions +++ b/functions @@ -20,8 +20,16 @@ WARNING="echo -en \\033[1;33m" # FAILURE prints text in a red colour FAILURE="echo -en \\033[1;31m" +# It seems that when compiling bash-4.0, using +# "make -j 1" is causing problems... +if [ "x${MAKEJOBS}" == "x1" ]; then + HVMAKE="make" +else + HVMAKE="make -j ${MAKEJOBS}" +fi + # Extracting the version number from a complete package name. -# Arg. #1: Complete package name with version (ex: gcc-3.4.4 will output 3.4.4) +# Arg. #1: Complete package name with version (ex: firefox-3.5.5.source will output 3.5.5) get_pkg_ver() { # Checking for correct number of arguments @@ -30,7 +38,7 @@ get_pkg_ver() return 1 fi - echo ${1} | sed "s!^.*-\(.*\)!\1!g" + echo ${1} | sed "s!.*-\(\([0-9]\.\)*\).*!\1!g" | sed 's!\.$!!g' } # Extracting the base version number from a complete package name. @@ -487,11 +495,7 @@ static_decompressed_dirname() { local PACKAGE=${1} - local DIRNAME=$(dirname $(tar -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 | head -n1)) - - if [ "x${DIRNAME}" == "x." ]; then - DIRNAME=$(basename $(tar -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 | head -n1)) - fi + local DIRNAME=$(tar -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 | head -n1 | awk -F \/ '{print $1}') echo ${DIRNAME} } @@ -518,7 +522,7 @@ apply_patches() if [ $# -eq 2 ]; then TARGET_DIR=${2} else - TARGET_DIR=$(static_decompressed_dirname ${PACKAGE}) + TARGET_DIR=${PACKAGE} fi # Checking if we can find at least one patch. @@ -584,11 +588,9 @@ decompress_package() return ${EXIT_FAILURE} fi - local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE}) - - if [ -d ${TOPDIR}/${DECOMPRESSED_DIRNAME} ]; then + if [ -d ${TOPDIR}/${PACKAGE} ]; then # Removing old source directory (if any) - rm -v -rf ${TOPDIR}/${DECOMPRESSED_DIRNAME} || exit 1 + rm -v -rf ${TOPDIR}/${PACKAGE} || exit 1 fi # Decompressing package @@ -606,14 +608,20 @@ decompress_package() ipkg() { # Checking for correct number of arguments - if [ $# -ne 2 ]; then + if [ $# -lt 2 ]; then echo echo "${FUNCNAME}(): Wrong number of arguments" echo " command was: \"${FUNCNAME}() $*\"" exit ${EXIT_FAILURE} fi - static_ipkg ${1} ${2} ${1} + local PACKAGE=${1} + shift + local CUSTOM_SCRIPT=${1} + shift + local CONFIGURE_OPTS=${*} + + static_ipkg ${PACKAGE} ${CUSTOM_SCRIPT} ${PACKAGE} ${CONFIGURE_OPTS} } # Installation of a package conforming to GNU autotools. @@ -746,7 +754,7 @@ static_ipkg() exit ${EXIT_FAILURE} fi - PACKAGE_LOG=${LFS_LOG_DIR}/${PACKAGE_NAME}.log + PACKAGE_LOG=${LFS_LOG_DIR}/${LABEL}.log # Checking if package was previously successfully installed if grep "^${LABEL} successfully installed" ${LFS_LOG_FILE} \ @@ -763,11 +771,15 @@ static_ipkg() decompress_package ${PACKAGE_NAME} 1>> ${PACKAGE_LOG} 2>&1 eval_retval2 - # Get the name of the decompressed directory local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE_NAME}) + # Rename the decompressed package as per the package name if necessary + if [ "x${DECOMPRESSED_DIRNAME}" != "x${PACKAGE_NAME}" ]; then + mv ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ${LFS_TMP}/${PACKAGE_NAME} || exit 1 + fi + # Displaying package source size in log file - echo " Source size:" $(du -h -s ${LFS_TMP}/${DECOMPRESSED_DIRNAME} | awk '{ print $1 }') 1>> ${LFS_LOG_FILE} + echo " Source size:" $(du -h -s ${LFS_TMP}/${PACKAGE_NAME} | awk '{ print $1 }') 1>> ${LFS_LOG_FILE} # Removing old build directory (if any) if [ -d ${LFS_TMP}/${PACKAGE_NAME}-build ]; then @@ -784,14 +796,14 @@ static_ipkg() eval_retval2 # Displaying package build size in log file - BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ${LFS_TMP}/${PACKAGE_NAME}-build | grep total | awk '{ print $1 }') + BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${PACKAGE_NAME} ${LFS_TMP}/${PACKAGE_NAME}-build | grep total | awk '{ print $1 }') echo " Build size : ${BUILD_SIZE}" 1>> ${LFS_LOG_FILE} # Some scripts need to preserve the source or build directory. They can # do so by renaming them. - if [ -d ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ]; then + if [ -d ${LFS_TMP}/${PACKAGE_NAME} ]; then # Removing source directory - rm -v -rf ${LFS_TMP}/${DECOMPRESSED_DIRNAME} 1>> ${PACKAGE_LOG} 2>&1 + rm -v -rf ${LFS_TMP}/${PACKAGE_NAME} 1>> ${PACKAGE_LOG} 2>&1 eval_retval2 fi if [ -d ${LFS_TMP}/${PACKAGE_NAME}-build ]; then @@ -873,12 +885,13 @@ action_checkbox_time() # Display the action name, run a command, log its output and display it's # status. Write to install log file when successfully completed so it # won't be called again after a successfull installation. -# First argument: label (string) -# Second argument: script name +# First argument: Message to display during action +# Second argument: script name (will be label) run_script_log() { - LABEL=${1} + MSGSTRING=${1} SCRIPT=${2} + LABEL=${SCRIPT} # Checking for correct number of arguments if [ $# -lt 2 ]; then @@ -905,7 +918,7 @@ run_script_log() fi # Displaying script name - echo -n "[ ] ${LABEL}" + echo -n "[ ] ${MSGSTRING}" echo "------------------------" 1>> ${LFS_LOG_FILE} echo "Running " ${LABEL} 1>> ${LFS_LOG_FILE} echo 1>> ${LFS_LOG_FILE}