Finalisation Wifi selon tests concluants du HP-Mini
[hvlinux.git] / functions / fpkg
index 020443b..cffb6f1 100644 (file)
@@ -71,6 +71,16 @@ update_packages_init()
        install -v -m755 -d ${LFS_PKG_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
     fi
 
+    if [ -n "${TEST_INTEGRITY}" ]; then
+        # En mode test intégrité, on ne veut pas télécharger quoi que ce soit
+        return 0
+    fi
+
+    if [ ! -x /usr/bin/wget ]; then
+       echo "${FUNCNAME}() error, the wget package was not found."
+       return 1
+    fi
+
     if [ -n "${USE_LFS_PATCHES}" ]; then
         # Getting list of all patches from LFS server.
         rcmd "Fetching LFS patches list" static_fetch_patches_list ${LFS_PATCHES_URL} ${LFS_PATCHES_LIST}
@@ -153,17 +163,15 @@ static_getpatch()
 
 detect_file_not_found()
 {
-    # HTTP: will return error code 404.
+    # HTTP: will return "ERROR 404: Not Found"
     # FTP: will say "File not found"
-    if grep "404" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
-        #echo "404 NOTFOUND"
-        return 0
-    elif grep "No such file" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
-        #echo "No such file"
+    if grep --ignore-case "not found" ${WGET_LOG_FILE} \
+        1> /dev/null 2>&1; then
+        echo "404 NOTFOUND"
         return 0
-    else
-        return 1
     fi
+    
+    return 1
 }
 
 # Get package if it is not in the repository
@@ -198,7 +206,8 @@ static_getpkg()
         # 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}
+        rcmd "Fetching ${PACK}.${arch_ext}" \
+            ${WGETCMD} ${URL}/${PACK}.${arch_ext}
         wget_status=$?
 
         # Append log to global log file
@@ -255,7 +264,8 @@ test_archive_integrity()
     local EXT=${3}
 
     if [ ! -f ${FILE} ]; then
-        return 1
+        # The file may be absent, in this case simply abort without error
+        return 0
     fi
 
     local TESTCMD=""
@@ -498,22 +508,29 @@ fpkg()
     DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT}
 
     if [ ! -f ${DEST_FILE} ]; then
-        set +e
-        static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT}
-        set -e
-
-        # Move file if source filename is not equal to package name and/or
-        # destination directory is not the default:
-        DOWNLOADED_FILE=${LFS_PKG_DIR}/${SRC_FILENAME}.${FINAL_EXT}
-        DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT}
-
-        if [ "${DEST_FILE}" != "${DOWNLOADED_FILE}" ]; then
-           mv ${DOWNLOADED_FILE} ${DEST_FILE}
-       fi
+        if [ -z "${TEST_INTEGRITY}" ]; then
+            # Fetch package, unless we are testing integrity
+            set +e
+            static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT}
+            set -e
+
+            # Move file if source filename is not equal to package name and/or
+            # destination directory is not the default:
+            DOWNLOADED_FILE=${LFS_PKG_DIR}/${SRC_FILENAME}.${FINAL_EXT}
+            DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT}
+
+            if [ "${DEST_FILE}" != "${DOWNLOADED_FILE}" ]; then
+               mv ${DOWNLOADED_FILE} ${DEST_FILE}
+           fi
+        fi
     fi
 
     if [ -n "${TEST_INTEGRITY}" ]; then
         test_archive_integrity "${PACK}" "${DEST_FILE}" "${FINAL_EXT}"
+        
+        # We do not want to fetch patches when testing integrity,
+        # so return immediately
+        return 0
     fi
 
     # Check for available patches with PACKAGE (TARGET) name.