X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions;h=1107738f57c0b7757f91e68d2c0583845343c08c;hb=2f337c932e5c659d31b4860d4414dde540cb74bb;hp=5d7d083cc24484d73a337d430e61db6d41e0c92a;hpb=aa229d2908422fce286bbd65710e31b086c8a2a2;p=hvlinux.git diff --git a/functions b/functions index 5d7d083..1107738 100644 --- a/functions +++ b/functions @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This file is 'sourced' by other scripts, therefore the above line is of no # use, except when modifying the file in emacs to have syntax highlighting. @@ -22,6 +22,8 @@ BRACKET="\033[1;34m" TAR_OPTS="-b8" +HV_FONTS_PATH="/usr/share/fonts" + # It seems that when compiling bash-4.0, using # "make -j 1" is causing problems... if [ "x${MAKEJOBS}" = "x1" ]; then @@ -31,14 +33,27 @@ else fi case "${HVL_TARGET}" in + arm*) + CLFS_BUILDFLAGS="-mabi=aapcs-linux -mfloat-abi=soft" + CLFS_TARGET="arm-linux-gnueabi" + CLFS_ARCH=$(echo ${CLFS_TARGET} | sed -e 's/-.*//' -e 's/arm.*/arm/g') + CLFS_ENDIAN=$(echo ${CLFS_ARCH} | sed -e 's/armeb/BIG/' -e 's/arm/LITTLE/') + if [ "${CLFS_ENDIAN}" = "LITTLE" ]; then + CLFS_NOT_ENDIAN="BIG" + else + CLFS_NOT_ENDIAN="LITTLE" + fi + ;; "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} ;; *) echo "Unsupported target architecture: ${HVL_TARGET}" @@ -46,6 +61,11 @@ case "${HVL_TARGET}" in ;; esac +CLFS_HOST="$(echo $MACHTYPE | \ + sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")" + +export CLFS_BUILDFLAGS CLFS_TARGET CLFS_ARCH CLFS_HOST CLFS_ENDIAN CLFS_NOT_ENDIAN + CLFS=${LFS} # Extracting the version number from a complete package name. @@ -97,7 +117,7 @@ get_pkg_name() return 1 fi - echo ${1} | sed "s!^\(.*\)-.*!\1!g" + echo ${1} | sed "s!^\(.*\)-[0-9]*\.[0-9]*.*!\1!g" } # Saves the content of CFLAGS and CXXFLAGS environment variables. @@ -510,11 +530,34 @@ static_decompressed_dirname() { local PACKAGE=${1} - # Remove optional "./" leading component with sed - # and extract base directory name with awk. - local DIRNAME=$(tar ${TAR_OPTS} -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 | head -n1 | sed 's!^\./!!' | awk -F \/ '{print $1}') + # List of default archive extensions to try + local MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z zip" + + for arch_ext in ${MY_ARCH_EXT}; do + if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ]; then + # Try next archive extension. + continue; + fi + + case ${arch_ext} in + tar.bz2|tar.gz|tgz|tar.Z) + # Remove optional "./" leading component with sed + # and extract base directory name with awk. + local DIRNAME=$(tar ${TAR_OPTS} -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 | head -n1 | sed 's!^\./!!' | awk -F \/ '{print $1}') + echo ${DIRNAME} + ;; + zip) + # TODO + echo ${PACKAGE} + ;; + esac + + return $? + done - echo ${DIRNAME} + # Failure or file not found + echo "${FUNCNAME}(): Missing source package for \"${PACKAGE}\"" > /dev/stderr + return ${EXIT_FAILURE} } # Applying patch @@ -594,21 +637,44 @@ decompress_package() local PACKAGE=${1} - if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 ]; then - echo "${FUNCNAME}(): Missing source package: \"${PACKAGE}.tar.bz2\"" > /dev/stderr - return ${EXIT_FAILURE} - fi - - if [ -d ${TOPDIR}/${PACKAGE} ]; then - # Removing old source directory (if any) - rm -v -rf ${TOPDIR}/${PACKAGE} || exit 1 - fi + # List of default archive extensions to try + local MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z zip" + + for arch_ext in ${MY_ARCH_EXT}; do + if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ]; then + # Try next archive extension. + continue; + fi + + if [ -d ${TOPDIR}/${PACKAGE} ]; then + # Removing old source directory (if any) + rm -v -rf ${TOPDIR}/${PACKAGE} || exit 1 + fi + + cd ${TOPDIR} + + # Decompressing package + case ${arch_ext} in + tar.bz2) + tar ${TAR_OPTS} -jxvf ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} || return 1 + ;; + tar.gz|tgz|tar.Z) + tar ${TAR_OPTS} -zxvf ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} || return 1 + ;; + zip) + echo ZIPZIPZIP + unzip ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} || return 1 + ;; + esac + + cd - 1> /dev/null 2>&1 + + return $? + done - # Decompressing package - # Option 'U' of tar is to remove each file prior to extracting over it - cd ${TOPDIR} && - tar ${TAR_OPTS} -jxvf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 && - cd - 1> /dev/null 2>&1 + # Failure or file not found + echo "${FUNCNAME}(): Missing source package for \"${PACKAGE}\"" > /dev/stderr + return ${EXIT_FAILURE} } # Installation of a package