From: Michael Tremer Date: Sun, 15 Mar 2009 13:23:56 +0000 (+0100) Subject: Fastened bash build scripts. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=355ea3e718d2aa851813d8cd7799cf5b38e06243;p=ipfire-3.x.git Fastened bash build scripts. --- diff --git a/tools/make-beautify b/tools/make-beautify index 181409ed1..9713d3480 100644 --- a/tools/make-beautify +++ b/tools/make-beautify @@ -146,23 +146,24 @@ beautify() { echo -ne "${BOLD}*** ${MESSAGE}${SET_OPT_COL} options${SET_VER_COL} version " echo -ne "${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n" ;; - make_pkg) - echo "$2" | while read PKG_VER PROGRAM OPTIONS - do - SET_VER_COL_REAL=`position_cursor $TIME_COL $PKG_VER -3` - - echo -ne "${PROGRAM}" - if ! [ "$OPTIONS" == "" ]; then - echo -ne "${SET_OPT_COL}${BRACKET_L} ${BOLD}${OPTIONS}${NORMAL} ${BRACKET_R}" - fi - - if [ "${PKG_VER}" == "${SNAME}" ] || [ "${PKG_VER}" == "LFS" ]; then - echo -ne "${SET_RESULT_COL}" - else - echo -ne "${SET_VER_COL}${BRACKET_L} ${BOLD}${SET_VER_COL_REAL}${PKG_VER}" - echo -ne "${NORMAL} ${BRACKET_R}${SET_RESULT_COL}" - fi - done + package) + local PKG_NAME=$2 + local PKG_VER=$(shrink_string $VER_WIDTH $3) + local OPTIONS=$4 + + SET_VER_COL_REAL=`position_cursor $TIME_COL "$PKG_VER" -3` + + echo -ne "${PKG_NAME}" + if ! [ "$OPTIONS" == "" ]; then + echo -ne "${SET_OPT_COL}${BRACKET_L} ${BOLD}${OPTIONS}${NORMAL} ${BRACKET_R}" + fi + + if [ -z "${PKG_VER}" ]; then + echo -ne "${SET_RESULT_COL}" + else + echo -ne "${SET_VER_COL}${BRACKET_L} ${BOLD}${SET_VER_COL_REAL}${PKG_VER}" + echo -ne "${NORMAL} ${BRACKET_R}${SET_RESULT_COL}" + fi ;; result) RESULT=$2 @@ -184,26 +185,24 @@ beautify() { esac } # End of beautify() -get_pkg_ver() { - PKG_VER=`grep ^PKG_VER $1 | awk '{print $3}'` - - if [ -z $PKG_VER ]; then - PKG_VER=`grep "Exp " $1 | awk '{print $4}'` - fi +function shrink_string() { + local LENGTH=$1 + shift + local STRING=$@ - if [ ${#PKG_VER} -gt $VER_WIDTH ]; then - # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters - # and replace enough characters to fit the resulting string on the screen. We'll replace - # the extra character with .. (two dots). That's why the "+ 2" in the formula below. - # Example: if we have a 21-long version number that we want to fit into a 10-long space, + if [ ${#STRING} -gt $LENGTH ]; then + # If a string is greater than $LENGTH, we keep the first 4 characters + # and replace enough characters to fit the resulting string on the screen. We'll replace + # the extra character with .. (two dots). That's why the "+ 2" in the formula below. + # Example: if we have a 21-long string that we want to fit into a 10-long space, # we have to remove 11 characters. But if we replace 11 characters with 2 characters, we'll # end up with a 12-character long string. That's why we replace 12 characters with .. - REMOVE=`expr substr "$PKG_VER" 4 $[ ${#PKG_VER} - $VER_WIDTH + 2 ]` - PKG_VER=`echo ${PKG_VER/$REMOVE/..}` + REMOVE=$(expr substr "$STRING" 4 $[ ${#STRING} - $LENGTH + 2 ]) + STRING=$(echo ${STRING/$REMOVE/..}) fi - echo "$PKG_VER" -} # End of get_pkg_ver() + echo "$STRING" +} # End of shrink_string() dialogerror() { beautify message FAIL diff --git a/tools/make-include b/tools/make-include index 8cbf6e0f1..2c2c7a568 100644 --- a/tools/make-include +++ b/tools/make-include @@ -166,23 +166,25 @@ entershell() { ################################################################################ lfsmakecommoncheck() { - unset NAME VERSION - eval $(pkg_info $1) - - logger "Building $*" - build_spy package $1 - # Script present? if [ ! -f $BASEDIR/lfs/$1 ]; then exiterror "No such file or directory: $BASEDIR/lfs/$1" fi - beautify make_pkg "$VERSION $*" + unset NAME VERSION + eval $(pkg_info $1) + logger "Building $*" + + shift 1 + + build_spy package $NAME + + beautify package "$NAME" "$VERSION" "$*" # Script slipped? local i for i in $SKIP_PACKAGE_LIST; do - if [ "$i" == "$1" ]; then + if [ "$i" == "$NAME" ]; then beautify result SKIP return 1 fi @@ -190,20 +192,18 @@ lfsmakecommoncheck() # On debug build, we don't strip if [ "$STAGE" != "toolchain" -a \ - "$1" == "strip" -a "$BUILD_DEBUG" == "1" ]; then + "$NAME" == "strip" -a "$BUILD_DEBUG" == "1" ]; then beautify result SKIP return 1 fi # Don't create addons? - local EXTRA=$(grep ^EXTRA $BASEDIR/lfs/$1 | awk '{print $3}') if [ "$EXTRA" == "yes" ] && [ "$BUILD_EXTRAS" == "0" ]; then beautify result SKIP return 1 fi # Don't create debugging tools? - local DEBUG=$(grep ^DEBUG $BASEDIR/lfs/$1 | awk '{print $3}') if [ "$DEBUG" == "yes" ] && [ "$BUILD_DEBUG" == "0" ]; then beautify result SKIP return 1 @@ -211,7 +211,7 @@ lfsmakecommoncheck() # Searching for dependencies local found message - for dep in $(pkg_deps $1); do + for dep in ${DEPS}; do found=0 for package in $PACKAGES_DONE; do if [ "$dep" = "$package" ]; then @@ -232,11 +232,6 @@ lfsmakecommoncheck() fi fi - cd $BASEDIR/lfs && make -s -f $* MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1 - if [ $? -ne 0 ]; then - exiterror "Download error in $1" - fi - distcc_reload & return 0 # pass all! @@ -249,12 +244,8 @@ toolchain_make() { lfsmakecommoncheck $* [ $? == 1 ] && return 0 - local PKG_VER=$(get_pkg_ver $BASEDIR/lfs/$1) - - local EXTRA_MAKE=$EXTRA_MAKE - local PKG_TIME_START=$(date +%s) - cd $BASEDIR/lfs && $EXTRA_MAKE make -f $* \ + cd $BASEDIR/lfs && make -f $* \ CONFIG_ROOT=$CONFIG_ROOT \ LINKER=$LINKER \ TOOLS_DIR=$TOOLS_DIR \ @@ -293,17 +284,6 @@ ipfire_make() { lfsmakecommoncheck $* [ $? == 1 ] && return 0 - local PKG_VER=$(get_pkg_ver $BASEDIR/lfs/$1) - - local EXTRA_MAKE=$EXTRA_MAKE - # When cross-compiling, make sure the kernel is compiled for the target - [ "$MACHINE" != "$MACHINE_REAL" -a "$1" == "linux" ] && unset EXTRA_MAKE - - # Also, make sure external kernel modules are compiled 64bit - if grep -qEi 'KERNEL_MOD = yes' $1 ; then - unset EXTRA_MAKE - fi - local PKG_TIME_START=$(date +%s) chroot $LFS $TOOLS_DIR/bin/env -i \ HOME=/root \ @@ -341,16 +321,16 @@ ipfire_make() { IMAGENAME=$IMAGENAME \ LOGFILE=$(echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g") \ bash -x -c "cd /usr/src/lfs && \ - $EXTRA_MAKE make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 + make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 local COMPILE_SUCCESS=$? local PKG_TIME_END=$(date +%s) if [ $COMPILE_SUCCESS -ne 0 ]; then - beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE + beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ] exiterror "Building $*" else - beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE + beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ] PACKAGES_DONE="$PACKAGES_DONE $1" fi @@ -366,8 +346,6 @@ package_make() { lfsmakecommoncheck $* [ $? == 1 ] && return 0 - local PKG_VER=$(get_pkg_ver $BASEDIR/lfs/$1) - local PKG_TIME_START=$(date +%s) chroot $LFS $TOOLS_DIR/bin/env -i \ HOME=/root \ @@ -397,16 +375,16 @@ package_make() { ROOTFILE=$(rootfiles_findone $1 | sed "s,$BASEDIR,/usr/src,g") \ LOGFILE=$(echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g") \ bash -x -c "cd /usr/src/lfs && \ - $EXTRA_MAKE make -f $* LFS_BASEDIR=/usr/src package" >>$LOGFILE 2>&1 + make -f $* LFS_BASEDIR=/usr/src package" >>$LOGFILE 2>&1 local COMPILE_SUCCESS=$? local PKG_TIME_END=$(date +%s) if [ $COMPILE_SUCCESS -ne 0 ]; then - beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE + beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ] exiterror "Packageing $*" else - beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE + beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ] PACKAGES_DONE="$PACKAGES_DONE $1" fi @@ -474,7 +452,6 @@ prepareenv() { exiterror "Not building as root" fi - ############################################################################## # Checking for necessary temporary space # ##############################################################################