Merge stage1 x86_64 dans trunk
[hvlinux.git] / functions-update
index 1fe40ed..8339311 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-LFS_PKG_BASE="$(dirname $(dirname $(pwd)))/packages"
+LFS_PKG_BASE="$(dirname $(pwd))/packages"
 LFS_PKG_DIR="${LFS_PKG_BASE}/${LFS_STAGE}"
 LFS_LOG_DIR="${LFS}/var/log/hvlinux-install/${LFS_STAGE}"
 LFS_LOG_FILE="${LFS_LOG_DIR}/pkg-update.log"
@@ -8,27 +8,32 @@ WGET_LOG_FILE="${LFS_LOG_DIR}/pkg-wget.log"
 
 # URL
 LFS_BASE_URL="http://www.linuxfromscratch.org"
+CLFS_BASE_URL="http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk"
+HV_BASE_URL="http://www.hugovil.com/hvlinux-repository"
+
 LFS_PATCHES_URL="${LFS_BASE_URL}/patches/lfs/development"
-LFS_PACKAGES_URL="ftp://ftp.osuosl.org/pub/lfs/lfs-packages/conglomeration"
 BLFS_PATCHES_URL="${LFS_BASE_URL}/patches/blfs/svn"
-HV_BASE_URL="http://www.hugovil.com/hvlinux-repository"
-HV_PACKAGES_URL="${HV_BASE_URL}/packages"
+CLFS_PATCHES_URL="http://patches.cross-lfs.org/dev"
 HV_PATCHES_URL="${HV_BASE_URL}/patches"
+
+LFS_PACKAGES_URL="ftp://ftp.osuosl.org/pub/lfs/lfs-packages/conglomeration"
+HV_PACKAGES_URL="${HV_BASE_URL}/packages"
 SOURCEFORGE_URL="http://internap.dl.sourceforge.net/sourceforge"
 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 -o ${WGET_LOG_FILE}"
+WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=5 --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
+CLFS_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-clfs.html
 HV_PATCHES_LIST=${LFS_PKG_DIR}/patches-list-hv.html
 
-
 # Arg. #1: URL for patches repository.
 # Arg. #2: Destination filename.
-static_fetch_patches_list() {
+static_fetch_patches_list()
+{
     PATCHES_URL=${1}
     PATCHES_LIST_FILENAME=${2}
 
@@ -36,10 +41,10 @@ static_fetch_patches_list() {
     mv ${LFS_PKG_DIR}/index.html ${PATCHES_LIST_FILENAME}
 }
 
-
 # Arg. #1: URL for patches repository. The trailing
 #          slash is absolutely necessary for this to work.
-update_packages_init() {
+update_packages_init()
+{
     # First create log directory if it does not exists.
     if [ ! -d ${LFS_LOG_DIR} ]; then
        install -m755 -d ${LFS_LOG_DIR} || exit 1
@@ -51,22 +56,24 @@ update_packages_init() {
     fi
 
     # Getting list of all patches from LFS server.
-    ##action_checkbox "Fetching LFS patches list"
-    static_fetch_patches_list ${LFS_PATCHES_URL} ${LFS_PATCHES_LIST}
+    action_checkbox "Fetching LFS patches list" static_fetch_patches_list ${LFS_PATCHES_URL} ${LFS_PATCHES_LIST}
 
     # Getting list of all patches from BLFS server.
     action_checkbox "Fetching BLFS patches list" static_fetch_patches_list ${BLFS_PATCHES_URL} ${BLFS_PATCHES_LIST}
 
+    # Getting list of all patches from CLFS server.
+    action_checkbox "Fetching CLFS patches list" static_fetch_patches_list ${CLFS_PATCHES_URL} ${CLFS_PATCHES_LIST}
+
     # Getting list of all patches from hugovil.com server.
     action_checkbox "Fetching hugovil.com patches list" static_fetch_patches_list ${HV_PATCHES_URL} ${HV_PATCHES_LIST}
 }
 
-
 # Get patch package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: Patches list file (HTML)
 # Arg. #3: Patches URL
-static_checkpatch() {
+static_checkpatch()
+{
     local PACK=${1}
     local PATCHES_LIST=${2}
     local PATCHES_URL=${3}
@@ -75,16 +82,16 @@ static_checkpatch() {
     if [ -n "${PATCHES_FOUND}" ]; then
        for p in ${PATCHES_FOUND}; do
            if [ ! -f ${LFS_PKG_DIR}/${p} ]; then
-               action_checkbox_time "Fetching ${p}" ${WGETCMD} ${PATCHES_URL}/${p}
+               action_checkbox_time "Fetching ${p} from ${PATCHES_URL}" ${WGETCMD} ${PATCHES_URL}/${p}
            fi
        done
     fi
 }
 
-
 # Get patch package if it is not in the repository
 # Arg. #1: Package name and version
-static_getpatch() {
+static_getpatch()
+{
     PACK=${1}
 
     # Checking for correct number of arguments
@@ -93,16 +100,26 @@ static_getpatch() {
        return 1
     fi
 
-    # Checking if patch is available from LFS.
-    static_checkpatch ${PACK} ${LFS_PATCHES_LIST} ${LFS_PATCHES_URL}
+    if [ -n "${USE_LFS_PATCHES}" ]; then
+        # Checking if patch is available from LFS.
+        static_checkpatch ${PACK} ${LFS_PATCHES_LIST} ${LFS_PATCHES_URL}
+    fi
 
-    # Checking if patch is available from BLFS.
-    static_checkpatch ${PACK} ${BLFS_PATCHES_LIST} ${BLFS_PATCHES_URL}
+    if [ -n "${USE_BLFS_PATCHES}" ]; then
+        # Checking if patch is available from BLFS.
+        static_checkpatch ${PACK} ${BLFS_PATCHES_LIST} ${BLFS_PATCHES_URL}
+    fi
 
-    # Checking if patch is available from hugovil.com.
-    static_checkpatch ${PACK} ${HV_PATCHES_LIST} ${HV_PATCHES_URL}
-}
+    if [ -n "${USE_CLFS_PATCHES}" ]; then
+        # Checking if patch is available from CLFS.
+        static_checkpatch ${PACK} ${CLFS_PATCHES_LIST} ${CLFS_PATCHES_URL}
+    fi
 
+    if [ -n "${USE_HV_PATCHES}" ]; then
+        # Checking if patch is available from hugovil.com.
+        static_checkpatch ${PACK} ${HV_PATCHES_LIST} ${HV_PATCHES_URL}
+    fi
+}
 
 # Convert multiple compressed gzip files to bzip2.
 # Usage: gztobz2 [FILES]
@@ -152,12 +169,11 @@ gztobz2()
     done
 }
 
-
 detect_file_not_found()
 {
     # HTTP: will return error code 404.
     # FTP: will say "File not found"
-    if grep "404 Not Found" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
+    if grep "404" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
         return 0
     elif grep "No such file" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
         return 0
@@ -166,11 +182,11 @@ detect_file_not_found()
     fi
 }
 
-
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: URL
-static_getpkg() {
+static_getpkg()
+{
     PACK=${1}
     URL=${2}
 
@@ -219,11 +235,11 @@ static_getpkg() {
     return 1
 }
 
-
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: URL
-fpkg() {
+fpkg()
+{
     PACK=${1}
     URL=${2}
 
@@ -241,14 +257,14 @@ fpkg() {
     static_getpatch ${PACK}
 }
 
-
 # Get package if it is not in the repository.
 # This function is used if the source and target names for the
 # package are different (name mismatch).
 # Arg. #1: Target package name and version (on disk)
 # Arg. #2: Source package name and version (on internet)
 # Arg. #3: URL
-fpkg_mis() {
+fpkg_mis()
+{
     TARGET=${1}
     SOURCE=${2}
     URL=${3}
@@ -280,11 +296,11 @@ fpkg_mis() {
     fi
 }
 
-
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: Directory name (optional)
-fpkg_gnu() {
+fpkg_gnu()
+{
     PACK=${1}
 
     if [ $# -eq 2 ]; then
@@ -302,11 +318,11 @@ fpkg_gnu() {
     fpkg ${PACK} "${GNU_URL}/${NAME}"
 }
 
-
 # Fetch Gnome package (if it is not in the repository).
 # Arg. #1: Package name and version
 # Arg. #2: Directory name (optional)
-fpkg_gnome() {
+fpkg_gnome()
+{
     PACK=${1}
 
     if [ $# -eq 2 ]; then
@@ -324,11 +340,11 @@ fpkg_gnome() {
     fpkg ${PACK} "${GNOME_URL}/${NAME}/$(get_pkg_ver_base ${PACK})"
 }
 
-
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: Directory name (optional)
-fpkg_sf() {
+fpkg_sf()
+{
     PACK=${1}
 
     if [ $# -eq 2 ]; then
@@ -346,11 +362,11 @@ fpkg_sf() {
     fpkg ${PACK} ${SOURCEFORGE_URL}/${NAME}
 }
 
-
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: Directory name (optional)
-fpkg_hv() {
+fpkg_hv()
+{
     PACK=${1}
 
     # Checking for correct number of arguments
@@ -366,11 +382,11 @@ fpkg_hv() {
     fi
 }
 
-
 # Get package if it is not in the repository
 # Arg. #1: Package name and version
 # Arg. #2: Directory name (optional)
-fpkg_lfs() {
+fpkg_lfs()
+{
     PACK=${1}
 
     # Checking for correct number of arguments
@@ -386,12 +402,12 @@ fpkg_lfs() {
     fi
 }
 
-
 # Create a symbolic link to a package that is located in another stage
 # repository (to not have the same file twice).
 # Arg. #1: Source stage number (1, 2, 3, etc)
 # Arg. #2: Package name
-lpkg() {
+lpkg()
+{
     SRCSTAGE="stage${1}"
     FILE="${2}.tar.bz2"
     PACKAGE_NAME="${2}"
@@ -403,15 +419,15 @@ lpkg() {
     fi
 
     if [ ! -h ${LFS_PKG_DIR}/${FILE} ]; then
-       # The link does not exist. First check if source file exist.
+       # Issue a warning if source file doesn't exist.
        if [ ! -f ${LFS_PKG_BASE}/${SRCSTAGE}/${FILE} ]; then
-           echo "${FUNCNAME} ${*}"
-           echo "Missing source file..."
-           exit 1
+            source_link_status=" (missing source file)"
+        else
+            source_link_status=""
        fi
 
        # Create link if it doesn't exist
-       ln -s ../${SRCSTAGE}/${FILE} ${LFS_PKG_DIR}/${FILE}
+       action_checkbox_time "Linking ${PACKAGE_NAME}${source_link_status}" ln -s ../${SRCSTAGE}/${FILE} ${LFS_PKG_DIR}/${FILE}
     fi
 
     # Create link for patches corresponding to that package:
@@ -420,7 +436,7 @@ lpkg() {
            PATCHFILE=$(basename ${patch})
            if [ ! -h ${LFS_PKG_DIR}/${PATCHFILE} ]; then
                # Create link if it doesn't exist
-               ln -s ../${SRCSTAGE}/${PATCHFILE} ${LFS_PKG_DIR}/${PATCHFILE}
+               action_checkbox_time "Linking ${PATCHFILE}" ln -s ../${SRCSTAGE}/${PATCHFILE} ${LFS_PKG_DIR}/${PATCHFILE}
            fi
        done
     fi