Ajout option pour effacer un fichier avant de le re-telecharger
[hvlinux.git] / functions / main
index c3c0e5d..c0ab98e 100644 (file)
@@ -23,6 +23,10 @@ hvtrap_int()
     exit 1
 }
 
+# Load list of packages and versions.
+# They may be overridden in sysinfos.
+source ../config/packages-list
+
 # Load default values
 source ../config/sysinfos.default
 
@@ -45,9 +49,7 @@ source ./stage.def
 
 # Load functions
 source ../functions/fpkg
-
-# Load list of packages and versions
-source ../config/packages-list
+source ../functions/lpkg
 
 # Constants for return codes
 EXIT_SUCCESS=0
@@ -167,6 +169,20 @@ get_pkg_ver_base()
     echo ${1} | sed "s!^.*-\([0-9]*\.[0-9]*\).*!\1!g"
 }
 
+# Extracting the 3-digit version number from a complete package name.
+# Arg. #1: Complete package name with version
+# (ex: linux-2.6.37.1 will output 2.6.37)
+get_pkg_ver3()
+{
+    # Checking for correct number of arguments
+    if [ $# -ne 1 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    echo ${1} | sed "s!^.*-\([0-9]*\.[0-9]*\.[0-9]*\).*!\1!g"
+}
+
 # Extracting the base version number from a complete package name.
 # Arg. #1: Complete package name with version (ex: gcc-3.4.4 will output 3)
 get_pkg_ver_major()
@@ -639,7 +655,9 @@ static_decompressed_dirname()
                 # and extract base directory name with awk.
                 # tar 1.23 reports an error when using pipes, so
                 # remove error message with "2> /dev/null"
-                local DIRNAME=$(tar ${TAR_OPTS} -tf ${LFS_PKG_DIR}/${PACKAGE}.tar.bz2 2> /dev/null | head -n1 | sed 's!^\./!!' | awk -F \/ '{print $1}')
+                local DIRNAME=$(tar ${TAR_OPTS} -tf \
+                    ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} 2> /dev/null | \
+                    head -n1 | sed 's!^\./!!' | awk -F \/ '{print $1}')
                 echo ${DIRNAME}
                 ;;
             zip)
@@ -750,6 +768,7 @@ ipkg_display_build_infos()
     echo "  AR:       ${AR}"
     echo "  AS:       ${AS}"
     echo "  PATH:     ${PATH}"
+    echo "  HVMAKE:   ${HVMAKE}"
 
     GCCCPUOPT=$(gcc ${MARCH_FLAGS} -E -v - </dev/null 2>&1 | \
         sed -n 's/.* -v - //p')
@@ -760,7 +779,7 @@ ipkg_display_build_infos()
 # Arg. #1: Package name and version (ex: gcc-4.5.1)
 # Remaining arguments: Additional configure options
 # Options:
-#   -h     Display this help and returns
+#   -j     Disable parallel make for this package
 #   -l     Unique identification label in 'install.log'
 #          (default is package name and version)
 #   -m     Installation mode:
@@ -779,8 +798,14 @@ ipkg()
     export IPKG_MODE="ac" # Default mode if not specified
     export HVLABEL="" # Global variable
 
-    while getopts "l:m:s:" flag ;do
+    local HVMAKE_ORIG=${HVMAKE}
+
+    while getopts "jl:m:s:" flag ;do
         case ${flag} in
+            j)
+                # Disable parallel make onlyfor this package
+                HVMAKE="make"
+                ;;
            l)
                 # Alternate label
                 HVLABEL=${OPTARG}
@@ -862,6 +887,9 @@ ipkg()
     source ${SCRDIR}/${DEFAULT_IPKG_SCRIPT}
     ipkg_script ${ALT_SCRIPT_NAME}
 
+    # Restore original value in case it was modified
+    HVMAKE=${HVMAKE_ORIG}
+
     # Make sure we are at a known location
     cd ${SCRDIR}
 
@@ -1093,7 +1121,8 @@ print_status()
     if [ $# -ne 1 ]; then
         # If no parameters are given to the print_status function, print usage
         # information.
-       echo "Usage: ${FUNCNAME}() {success|warning|failure} [STRING] [TIME]"
+       echo "Usage: ${FUNCNAME}() {success|warning|failure}"
+       echo "       got: \"${*}\""
        return ${EXIT_FAILURE}
     fi