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
# 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}
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.
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
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