- if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 ]; then
- echo "${FUNCNAME}(): Missing source package: \"${PACKAGE}.tar.bz2\""
- return ${EXIT_FAILURE}
- fi
-
- local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE})
-
- if [ -d ${TOPDIR}/${DECOMPRESSED_DIRNAME} ]; then
- # Removing old source directory (if any)
- rm -v -rf ${TOPDIR}/${DECOMPRESSED_DIRNAME} || exit 1
- fi
-
- # Decompressing package
- # Option 'U' of tar is to remove each file prior to extracting over it
- cd ${TOPDIR} &&
- tar -jxvf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 &&
- cd - 1> /dev/null 2>&1
-}
-
-# Installation of a package, removing source and build directories after.
-#
-# First argument: package name
-# Second argument: script name
-# Remaining arguments: additional configure options
-ipkg()
-{
- # Checking for correct number of arguments
- if [ $# -ne 2 ]; then
- echo
- echo "${FUNCNAME}(): Wrong number of arguments"
- echo " command was: \"${FUNCNAME}() $*\""
- exit ${EXIT_FAILURE}
- fi
-
- static_ipkg ${1} ${2} ${1}
-}
-
-# Installation of a package conforming to GNU autotools.
-# The package must be able to be built outside the
-# source directory.
-#
-# First argument: package name
-# Remaining arguments: additional configure options
-ipkg_ac()
-{
- # Checking for correct number of arguments
- if [ $# -lt 1 ]; then
- echo
- echo "${FUNCNAME}(): Wrong number of arguments"
- echo " command was: \"${FUNCNAME}() $*\""
- exit ${EXIT_FAILURE}
- fi
-
- local PACKAGE=${1}
- shift
- local CONFIGURE_OPTS=${*}
-
- static_ipkg ${PACKAGE} cis-ac ${PACKAGE} ${CONFIGURE_OPTS}
-}
-
-# Installation of a package conforming to GNU autotools,
-# but that must be built inside the source directory.
-#
-# First argument: package name
-# Remaining arguments: additional configure options
-ipkg_ac_nb()
-{
- # Checking for correct number of arguments
- if [ $# -lt 1 ]; then
- echo
- echo "${FUNCNAME}(): Wrong number of arguments"
- echo " command was: \"${FUNCNAME}() $*\""
- exit ${EXIT_FAILURE}
- fi
-
- local PACKAGE=${1}
- shift
- local CONFIGURE_OPTS=${*}
-
- static_ipkg ${PACKAGE} cis-ac-nobuild ${PACKAGE} ${CONFIGURE_OPTS}
-}
-
-# Installation of a GNOME package.
-#
-# First argument: package name
-ipkg_gnome()
-{
- # Checking for correct number of arguments
- if [ $# -ne 1 ]; then
- echo
- echo "${FUNCNAME}(): Wrong number of arguments"
- echo " command was: \"${FUNCNAME}() $*\""
- exit ${EXIT_FAILURE}
- fi
-
- static_ipkg ${1} cis-gnome ${1}
-}
-
-# Installation of a PERL module
-#
-# First argument: package name
-ipkg_pm()
-{
- # Checking for correct number of arguments
- if [ $# -ne 1 ]; then
- echo
- echo "${FUNCNAME}(): Wrong number of arguments"
- echo " command was: \"${FUNCNAME}() $*\""
- exit ${EXIT_FAILURE}
- fi
-
- static_ipkg ${1} cis-pm ${1}
-}
-
-# Multiple installation of a package. This is usefull for packages
-# that may need to be installed multiple times, at different
-# times of the build process, like for GCC pas 1 and GCC pass 2.
-#
-# First argument: Real package name
-# Second argument: Installation script name
-# Third argument: Unique identification label in 'install.log'
-ipkg_mult()
-{
- # Checking for correct number of arguments
- if [ $# -ne 3 ]; then
- echo
- echo "${FUNCNAME}(): Wrong number of arguments"
- echo " command was: \"${FUNCNAME}() $*\""
- exit ${EXIT_FAILURE}
- 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