- if detect_file_not_found; then
- # If file was not found, maybe a .tar.gz file exist...
- ${WGETCMD} ${URL}/${PACK}.tar.gz
-
- if [ ${?} -eq 0 ]; then
- gztobz2 ${LFS_PKG_DIR}/${PACK}.tar.gz || return 1
- return 0
- else
- if detect_file_not_found; then
- # If file was not found, maybe a .tgz file exist...
- ${WGETCMD} ${URL}/${PACK}.tgz
- if [ ${?} -eq 0 ]; then
- gztobz2 ${LFS_PKG_DIR}/${PACK}.tgz || return 1
- return 0
- else
- if detect_file_not_found; then
- # If file was not found, maybe a .tar.Z file exist... (uw-imap...)
- ${WGETCMD} ${URL}/${PACK}.tar.Z
- if [ ${?} -eq 0 ]; then
- gztobz2 ${LFS_PKG_DIR}/${PACK}.tar.Z || return 1
- return 0
- fi
- fi
- fi
- fi
+ for arch_ext in ${MY_ARCH_EXT}; do
+ # Don't take any chance: remove any partially downloaded file.
+ # If we arrive here, it means the final destination file was not found
+ # so we can safely remove any file prior to trying to download it.
+ rm -f ${LFS_PKG_DIR}/${PACK}.${arch_ext}
+
+ rcmd "Fetching ${PACK}.${arch_ext}" ${WGETCMD} ${URL}/${PACK}.${arch_ext}
+ wget_status=$?
+
+ # Append log to global log file
+ cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE}
+
+ # Failure: if it was a connection timeout, don't try for other file
+ # extensions.
+ if grep "failed: Connection timed out" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
+ echo "Error, wget reported: Connection timed out"
+ return 1
+ fi
+
+ if detect_file_not_found; then
+ # Try next archive extension if web server reported that file is not
+ # found.
+ continue;
+ fi
+
+ if [ ${wget_status} -ne 0 ]; then
+ echo "Error fetching package ${PACK}.${arch_ext}"
+ return 1