X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions%2Ffpkg;h=6a8bf4b13bbd587a0d7c06cc76ba20d5d2ba985f;hb=e274861f489192ee8e1f59b495dc11fe91a6708d;hp=fed9089c6158fd68b327c58de93d542c893e24a1;hpb=05a63ae322941e807a917d83bed8348202e22807;p=hvlinux.git 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