Add repository for older LFS patches on hugovil.com server
[hvlinux.git] / functions / fpkg
index 6a8bf4b..b4ea48d 100644 (file)
@@ -15,6 +15,9 @@ LFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-lfs.html
 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
+LFS_OLD_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-lfs-old.html
+
+PATCHES_BLACKLIST=../config/patches.blacklist
 
 # Test if the given file extension correspond to a compressed archive
 # Arg. #1: File extension
@@ -125,6 +128,8 @@ wget_wrapper()
     fi
 
     if [ ${wget_status} -ne 0 ]; then
+        echo "Error: wget returned error status ${wget_status}" >> \
+            ${LFS_LOG_FILE}
         remove_partial_file ${LFS_PKG_DIR}/${SOURCE}
         return 1
     fi
@@ -134,6 +139,7 @@ wget_wrapper()
         # 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.
+            echo "Error: failed archive test" >> ${LFS_LOG_FILE}
             remove_partial_file ${LFS_PKG_DIR}/${SOURCE}
             return 2
         fi
@@ -199,6 +205,12 @@ update_packages_init()
         rcmd "Fetching LFS patches list" static_fetch_patches_list ${LFS_PATCHES_URL} ${LFS_PATCHES_LIST}
     fi
 
+    if [ -n "${USE_LFS_OLD_PATCHES}" ]; then
+        # Getting list of all LFS old patches from hugovil.com server.
+        rcmd "Fetching LFS old patches list" static_fetch_patches_list \
+            ${LFS_OLD_PATCHES_URL} ${LFS_OLD_PATCHES_LIST}
+    fi
+
     if [ -n "${USE_BLFS_PATCHES}" ]; then
         # Getting list of all patches from BLFS server.
         rcmd "Fetching BLFS patches list" static_fetch_patches_list ${BLFS_PATCHES_URL} ${BLFS_PATCHES_LIST}
@@ -228,16 +240,33 @@ static_checkpatch()
     # Remplace les "+" par "%2B"
     local PACK_URL=$(echo $PACK | sed s!\+!%2B!g)
 
-    local PATCHES_FOUND=$(cat ${PATCHES_LIST} | grep "${PACK_URL}-" | sed "s/.*\(${PACK_URL}-.*\.patch\).*/\1/")
+    # Patches list formats (patches-list-*.html):
+    #   LFS:     a href="name.patch"
+    #   hugovil: a href="dir/subdir/subdir/name.patch"
+    # We must search for a patch beginning with either a slash or a " to avoid
+    # the possibility of having another package name within a patch name:
+    #   if patch = Mesalib-8.0.4-llvm-3.1-fixes-1.patch
+    #   then we could erroneously try to download patch "llvm-3.1-fixes-1.patch"
+    local PATCHES_FOUND=$(cat ${PATCHES_LIST} | \
+        egrep "\"${PACK_URL}-|/${PACK_URL}-" | \
+        egrep ".patch\"" | \
+        sed "s/.*\(${PACK_URL}-.*\.patch\)\".*/\1/")
+
     if [ -n "${PATCHES_FOUND}" ]; then
        for p in ${PATCHES_FOUND}; do
             # Remplace les "%2B" par "+"
             PATCH_NAME=$(echo ${p} | sed s!%2B!\+!g)
 
            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}
+                # Fetch patch only if it is not blacklisted!
+                local BL=$(cat ${PATCHES_BLACKLIST} | \
+                    egrep "${PATCH_NAME}")
+
+                if [ "x${BL}" == "x" ]; then
+                    wget_wrapper ${PATCHES_URL} ${PATCH_NAME}
+                else
+                    MSGSTRING="Patch ${PATCH_NAME} blacklisted" print_status warning
+                fi
            fi
        done
     fi
@@ -260,6 +289,11 @@ static_getpatch()
         static_checkpatch ${PACK} ${LFS_PATCHES_LIST} ${LFS_PATCHES_URL}
     fi
 
+    if [ -n "${USE_LFS_OLD_PATCHES}" ]; then
+        # Checking if patch is available from LFS old.
+        static_checkpatch ${PACK} ${LFS_OLD_PATCHES_LIST} ${LFS_OLD_PATCHES_URL}
+    fi
+
     if [ -n "${USE_BLFS_PATCHES}" ]; then
         # Checking if patch is available from BLFS.
         static_checkpatch ${PACK} ${BLFS_PATCHES_LIST} ${BLFS_PATCHES_URL}
@@ -476,7 +510,7 @@ fpkg()
                 fi
                 if [ -z "${FILE_EXT}" ]; then
                     # Default file extension is tar.gz
-                    FILE_EXT="tar.gz"
+                    FILE_EXT="tar.xz"
                 fi
                 ;;
             gnome)
@@ -486,6 +520,10 @@ fpkg()
                    SRC_DIR=$(get_pkg_name ${PACK})
                 fi
                 SRC_DIR="${SRC_DIR}/$(get_pkg_ver2 ${PACK})"
+                                if [ -z "${FILE_EXT}" ]; then
+                    # Default file extension is xz
+                    FILE_EXT="tar.xz"
+                fi
                 ;;
             sf)
                 URL=${SOURCEFORGE_URL}