Menage fonts
[hvlinux.git] / functions-update
index d602572..742d9f1 100644 (file)
@@ -23,7 +23,7 @@ GNOME_URL="http://ftp.gnome.org/pub/gnome/sources"
 GNU_URL="http://ftp.gnu.org/pub/gnu"
 TETEX_URL="http://www.tug.org/ftp/tex-archive/systems/unix/teTeX"
 
-WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=5 --tries=3 -nc -c -o ${WGET_LOG_FILE}"
+WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=15 --tries=3 -nc -c -o ${WGET_LOG_FILE}"
 
 LFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-lfs.html
 BLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-blfs.html
@@ -198,23 +198,27 @@ detect_file_not_found()
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: URL
+# Arg. #3: Optional extension
 static_getpkg()
 {
-    PACK=${1}
-    URL=${2}
+    local PACK=${1}
+    local URL=${2}
+    local MY_ARCH_EXT=${3}
 
     # Checking for correct number of arguments
-    if [ $# -ne 2 ]; then
+    if [ $# -ne 2 -a $# -ne 3 ]; then
        echo "${FUNCNAME}(), wrong number of arguments: ${*}"
        return 1
     fi
 
     if [ -z "${ARCH_EXT}" ]; then
         # List of default archive extensions to try
-        ARCH_EXT="tar.bz2 tar.gz tgz tar.Z"
+        MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z"
     fi
 
-    for arch_ext in ${ARCH_EXT}; do
+    echo "  MY_ARCH_EXT=${MY_ARCH_EXT}"
+
+    for arch_ext in ${MY_ARCH_EXT}; do
         ${WGETCMD} ${URL}/${PACK}.${arch_ext}
 
         # Failure: if it was a connection timeout, don't try for other file extensions.
@@ -229,7 +233,7 @@ static_getpkg()
         fi
 
         # If we arrive here, it means we were able to download the file.
-        if [ "x${arch_ext}" != "xtar.bz2" ]; then
+        if [ "x${arch_ext}" = "xtar.gz" -o "x${arch_ext}" = "xtgz" -o "x${arch_ext}" = "xtar.Z" ]; then
            gztobz2 ${LFS_PKG_DIR}/${PACK}.${arch_ext}
         fi
         return $?
@@ -253,8 +257,34 @@ fpkg()
        return 1
     fi
 
-    if [ ! -f ${LFS_PKG_DIR}/${PACK}.tar.bz2 ]; then
-       rcmd "Fetching ${PACK}" static_getpkg ${PACK} ${URL}
+    # Default extension
+    local FINAL_EXT=tar.bz2
+
+    local FETCH_STRING="Fetching ${PACK}"
+
+    if [ -n "${ARCH_EXT}" ]; then
+        FINAL_EXT=${ARCH_EXT}
+        FETCH_STRING="${FETCH_STRING}.${ARCH_EXT}"
+    fi
+
+    # Default destination directory
+    local MY_FETCH_DIR=${LFS_PKG_DIR}
+
+    if [ -n "${FETCH_DIR}" ]; then
+        local MY_FETCH_DIR=${FETCH_DIR}
+        local MOVE_FILE=1
+    fi
+
+    DEST_FILE=${MY_FETCH_DIR}/${PACK}.${FINAL_EXT}
+
+    ##########echo "DEST_FILE=${DEST_FILE}"
+    if [ ! -f ${DEST_FILE} ]; then
+       rcmd "${FETCH_STRING}" static_getpkg ${PACK} ${URL} ${ARCH_EXT}
+
+        # Move to final directory if alternate directory specified
+       if [ -f ${LFS_PKG_DIR}/${PACK}.${FINAL_EXT} -a -n "${MOVE_FILE}" ]; then
+           mv ${LFS_PKG_DIR}/${PACK}.${FINAL_EXT} ${DEST_FILE}
+       fi
     fi
 
     # Check if a patch is available.
@@ -279,11 +309,18 @@ fpkg_mis()
        reurn 1
     fi
 
-    if [ ! -f ${LFS_PKG_DIR}/${TARGET}.tar.bz2 ]; then
+    if [ -z "${ARCH_EXT}" ]; then
+        # Default extension
+        FINAL_EXT=tar.bz2
+    else
+        FINAL_EXT=${ARCH_EXT}
+    fi
+
+    if [ ! -f ${LFS_PKG_DIR}/${TARGET}.${FINAL_EXT} ]; then
        fpkg ${SOURCE} ${URL}
        
-       if [ -f ${LFS_PKG_DIR}/${SOURCE}.tar.bz2 ]; then
-           mv ${LFS_PKG_DIR}/${SOURCE}.tar.bz2 ${LFS_PKG_DIR}/${TARGET}.tar.bz2
+       if [ -f ${LFS_PKG_DIR}/${SOURCE}.${FINAL_EXT} ]; then
+           mv ${LFS_PKG_DIR}/${SOURCE}.${FINAL_EXT} ${LFS_PKG_DIR}/${TARGET}.${FINAL_EXT}
        fi
     fi