From 50e0479441669b1be25b0097be3d10db0949f031 Mon Sep 17 00:00:00 2001 From: gobo72 Date: Mon, 29 Aug 2011 20:43:00 +0000 Subject: [PATCH] =?utf8?q?R=C3=A9gl=C3=A9=20probl=C3=A8me=20avec=20d=C3=A9?= =?utf8?q?tection=20du=20type=20de=20fichier=20=C3=A0=20t=C3=A9l=C3=A9char?= =?utf8?q?ger=20selon=20l'extension=20au=20lieu=20de=20le=20sp=C3=A9cifier?= =?utf8?q?=20manuellement.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- functions/fpkg | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/functions/fpkg b/functions/fpkg index fed9089..6a8bf4b 100644 --- a/functions/fpkg +++ b/functions/fpkg @@ -16,9 +16,25 @@ BLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-blfs.html CLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-clfs.html HV_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-hv.html -FTYPE_ARCHIVE="0" -FTYPE_PATCH="1" -FTYPE_OTHER="2" +# Test if the given file extension correspond to a compressed archive +# Arg. #1: File extension +is_extension_archive() +{ + if [ ${#} -ne 1 ]; then + echo "${FUNCNAME}(), wrong number of arguments: ${*}" + return 1 + fi + + local EXT=${1} + + for k in "gz" "tgz" "Z" "zip" "xz" "bz2"; do + if [ "x${EXT}" = "x${k}" ]; then + return 0 + fi + done + + return 1 +} # Test if the given file extension correspond to a tar/gzip archive # Arg. #1: File extension @@ -68,23 +84,19 @@ remove_partial_file() # Download a file, and making sure it is valid (at least it's header!) # Arg. #1: Source URL. # Arg. #2: Source filename (on server) -# Arg. #3: File type: 0 : Archive -# 2 : Patch -# 1 : Other # # Return: 0 : success # 1 : wget error -# 2 : File not found or not an archive +# 2 : File not found or not an archive (if file extension was archive type) wget_wrapper() { - if [ ${#} -lt 2 -a ${#} -gt 3 ]; then + if [ ${#} -lt 2 ]; then echo "${FUNCNAME}(), wrong number of arguments: ${*}" return 1 fi local URL=${1} local SOURCE=${2} - local FTYPE=${3} remove_partial_file ${LFS_PKG_DIR}/${SOURCE} @@ -117,7 +129,8 @@ wget_wrapper() return 1 fi - if [ "x${FTYPE}" = "x${FTYPE_ARCHIVE}" ]; then + local FEXT=${SOURCE##*.} + if is_extension_archive "${FEXT}"; then # Just to be sure, test if downloaded file is really an archive: if ! is_archive ${LFS_PKG_DIR}/${SOURCE}.part; then # Partial failure if file is invalid. @@ -224,7 +237,7 @@ static_checkpatch() if [ ! -f ${LFS_PKG_DIR}/${PATCH_NAME} ]; then # String uses $PATCH_NAME and not $p ??? #####rcmd "Fetching ${PATCH_NAME} from ${PATCHES_URL}" wget_wrapper ${PATCHES_URL} ${p} ${FTYPE_OTHER} - wget_wrapper ${PATCHES_URL} ${p} ${FTYPE_PATCH} + wget_wrapper ${PATCHES_URL} ${p} fi done fi @@ -303,7 +316,7 @@ static_getpkg() fi for arch_ext in ${PREFERRED_EXT}; do - wget_wrapper ${URL} ${PACK}.${arch_ext} ${FTYPE_ARCHIVE} + wget_wrapper ${URL} ${PACK}.${arch_ext} wget_wrapper_status=$? if [ ${wget_wrapper_status} -eq 1 ]; then -- 2.20.1