From: gobo72 Date: Mon, 29 Aug 2011 20:43:00 +0000 (+0000) Subject: Réglé problème avec détection du type de fichier à télécharger selon l'extension... X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=50e0479441669b1be25b0097be3d10db0949f031;p=hvlinux.git Réglé problème avec détection du type de fichier à télécharger selon l'extension au lieu de le spécifier manuellement. --- 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