X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions;h=3ca8396f2dc69ef499a65e957e00cf34be4f1ba2;hb=667d0b50214627922a46f2740c3aea2b93b080fd;hp=79a57e1b835491bc040e3af9e5ef67b5cdefc27d;hpb=e31a492ed6daa2caeb62aa9ce355c988a62672df;p=hvlinux.git diff --git a/functions b/functions index 79a57e1..3ca8396 100644 --- a/functions +++ b/functions @@ -24,6 +24,8 @@ TAR_OPTS="-b8" HV_FONTS_PATH="/usr/share/fonts" +DEFAULT_EDITOR=nano + # It seems that when compiling bash-4.0, using # "make -j 1" is causing problems... if [ "x${MAKEJOBS}" = "x1" ]; then @@ -530,11 +532,36 @@ 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. + # tar 1.23 reports an error when using pipes, so + # remove error message with "2> /dev/null" + local DIRNAME=$(tar ${TAR_OPTS} -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 2> /dev/null | 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 @@ -614,21 +641,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