From 166111908c2cff78986972e0d2668feb7ee9d42b Mon Sep 17 00:00:00 2001 From: gobo72 Date: Mon, 22 Aug 2011 01:19:47 +0000 Subject: [PATCH] =?utf8?q?Ajout=20support=20pour=20archives=20xz,=20et=20a?= =?utf8?q?jout=20fonction=20pour=20v=C3=A9rifier=20qu'on=20est=20bien=20l'?= =?utf8?q?usager=20root.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- functions/fpkg | 4 +++- functions/main | 34 +++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/functions/fpkg b/functions/fpkg index 406175b..dd855d9 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -274,10 +274,12 @@ test_archive_integrity() TESTCMD="bzip2 -t" elif is_archive_tar_gzip "${EXT}"; then TESTCMD="gunzip -t" + elif [ "x${EXT}" = "xtar.xz" ]; then + TESTCMD="unxz -t" elif [ "x${EXT}" = "xzip" ]; then TESTCMD="unzip -t" else - # Can only test gzip, bzip2 and zip archives. + # Can only test gzip, bzip2, xz and zip archives. return 0 fi diff --git a/functions/main b/functions/main index 25e1bcb..21f8a31 100644 --- a/functions/main +++ b/functions/main @@ -73,7 +73,7 @@ BRACKET="\033[1;34m" TAR_OPTS="-b8" # List of default archive extensions to try -DEFAULT_ARCH_EXT_LIST="tar.bz2 tar.gz tgz tar.Z zip" +DEFAULT_ARCH_EXT_LIST="tar.bz2 tar.gz tgz tar.Z tar.xz zip" HV_FONTS_PATH="/usr/share/fonts" @@ -133,6 +133,11 @@ init_log_file() # Scripts directory export SCRDIR=$(pwd) + if [ ! -d "$(dirname $(pwd))/packages" ]; then + echo "Error, could not find packages directory \"$(dirname $(pwd))/packages\", aborting." + exit 1 + fi + export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log @@ -144,6 +149,15 @@ init_log_file() fi } +# Check that we are logged in as the root user, and exit if this is not the case. +check_for_root_user() +{ + if [ "x${USER}" != "xroot" ]; then + echo "You must be the superuser to install hvlinux." + exit 1 + fi +} + # Extracting the version number from a complete package name. # Arg. #1: Complete package name with version (ex: firefox-3.5.5.source will output 3.5.5) get_pkg_ver() @@ -653,7 +667,7 @@ static_decompressed_dirname() local DIRNAME="" case ${arch_ext} in - tar.bz2|tar.gz|tgz|tar.Z) + tar.bz2|tar.gz|tgz|tar.Z|tar.xz) # Remove optional "./" leading component with sed # and extract base directory name with awk. # tar 1.23 reports an error when using pipes, so @@ -682,6 +696,7 @@ static_decompressed_dirname() # Decompression of a package # First argument: package name # Second argument: directory where decompressing (optional, defaults to LFS_TMP) +# Third argument: directory levels to strip (optional) decompress_package() { # Checking for correct number of arguments @@ -689,8 +704,11 @@ decompress_package() local TOPDIR=${LFS_TMP} elif [ $# -eq 2 ]; then local TOPDIR=${2} + elif [ $# -eq 3 ]; then + local TOPDIR=${2} + local STRIP_LEVEL="--strip-components=${3}" else - echo "${FUNCNAME}(): Incorrect number of arguments (must be 1 or 2)" > /dev/stderr + echo "${FUNCNAME}(): Incorrect number of arguments (must be 1, 2 or 3)" > /dev/stderr return ${EXIT_FAILURE} fi @@ -707,17 +725,15 @@ decompress_package() rm -rf ${TOPDIR}/${PACKAGE} fi + # Decompressing package case ${arch_ext} in - tar.bz2) - tar -C ${TOPDIR} ${TAR_OPTS} -jxf \ - ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} - ;; - tar.gz|tgz|tar.Z) - tar -C ${TOPDIR} ${TAR_OPTS} -zxf \ + tar.bz2|tar.gz|tgz|tar.Z|tar.xz) + tar -C ${TOPDIR} ${TAR_OPTS} ${STRIP_LEVEL} -xf \ ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ;; zip) + # Support STRIP_LEVEL??? unzip -qq -d ${TOPDIR} ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ;; esac -- 2.20.1