Correction emacsrc pour les fichiers .mak
[hvlinux.git] / functions / main
index b02efa8..14f39a9 100644 (file)
@@ -2,6 +2,10 @@
 set -o errtrace # Let shell functions inherit ERR trap.
 set -o errexit
 
+# Don' t locate and remember (hash) commands as they are looked up for
+# execution (don' t remember path):
+set +h
+
 hvtrap_setup()
 {
     # Setting ERR trap does implicit `set -o errexit'.
@@ -75,8 +79,6 @@ TAR_OPTS="-b8"
 # List of default archive extensions to try
 DEFAULT_ARCH_EXT_LIST="tar.bz2 tar.gz tgz tar.Z tar.xz zip"
 
-HV_FONTS_PATH="/usr/share/fonts"
-
 DEFAULT_IPKG_SCRIPT="ipkg.def"
 
 HVMAKE="make -j ${MAKEJOBS}"
@@ -232,37 +234,6 @@ get_pkg_name()
     echo ${1} | sed "s!\([^-][^0-9]*\)-[0-9].*!\1!"
 }
 
-# Saves the content of CFLAGS and CXXFLAGS environment variables.
-save_flags()
-{
-    export OLDCFLAGS=${CFLAGS}
-    export OLDCXXFLAGS=${CXXFLAGS}
-
-    return ${EXIT_SUCCESS}
-}
-
-# Saves the content of CFLAGS and CXXFLAGS environment variables, and then
-# set them to empty strings.
-save_flags_no_optimizations()
-{
-    export OLDCFLAGS=${CFLAGS}
-    export OLDCXXFLAGS=${CXXFLAGS}
-    export CFLAGS=""
-    export CXXFLAGS=""
-
-    return ${EXIT_SUCCESS}
-}
-
-# Restores the previous values of CFLAGS and CXXFLAGS environment variables. These
-# must have been saved first using save_flags().
-restore_flags()
-{
-    export CFLAGS=${OLDCFLAGS}
-    export CXXFLAGS=${OLDCXXFLAGS}
-
-    return ${EXIT_SUCCESS}
-}
-
 # Create symbolic links for start/stop scripts in /etc/rc.d
 #
 # Arg #1: script name
@@ -576,7 +547,7 @@ hv_groupadd()
     done
 
     if ! cat /etc/group | egrep -q "^${groupname}:"; then
-        groupadd ${arguments}    
+        groupadd ${arguments}
     fi
 }
 
@@ -599,11 +570,19 @@ hv_useradd()
 
 # Applying patch
 # First argument is the name of the patch
-# Second argument is the package name (target dir in $LFS_TMP)
+# Second argument is the package name
+# Third argument: optional target directory (default is $LFS_TMP)
 apply_patch()
 {
     local PATCH_FILE=${1}
-    local TARGET_DIR=${2}
+    local PACKAGE=${2}
+    local TARGET_DIR=""
+
+    if [ $# -eq 3 ]; then
+       TARGET_DIR=${3}/${PACKAGE}
+    else
+       TARGET_DIR=${LFS_TMP}/${PACKAGE}
+    fi
 
     if [ -z "${PATCH_FILE}" ]; then
         echo
@@ -618,7 +597,7 @@ apply_patch()
     fi
 
     echo "Applying patch: ${PATCH_FILE}"
-    patch -Np1 -d ${LFS_TMP}/${TARGET_DIR} -i ${LFS_PKG_DIR}/${PATCH_FILE}
+    patch -Np1 -d ${TARGET_DIR} -i ${LFS_PKG_DIR}/${PATCH_FILE}
 }
 
 # Applying any patch(es) found for the current package.
@@ -631,7 +610,7 @@ apply_patch()
 apply_patches()
 {
     PACKAGE=${1}
-    local TARGET_DIR=${PACKAGE}
+    local TARGET_DIR=""
 
     # Checking for correct number of arguments
     if [ $# -gt 2 ]; then
@@ -642,15 +621,13 @@ apply_patches()
 
     if [ $# -eq 2 ]; then
        TARGET_DIR=${2}
-    else
-       TARGET_DIR=${PACKAGE}
     fi
 
     # Checking if we can find at least one patch.
     if ls ${LFS_PKG_DIR}/${1}-*.patch 1> /dev/null 2>&1; then
        cd ${LFS_PKG_DIR}
        for patch in ${1}-*.patch; do
-            apply_patch ${patch} ${TARGET_DIR}
+            apply_patch ${patch} ${PACKAGE} ${TARGET_DIR}
        done
     fi
 
@@ -786,7 +763,7 @@ ipkg_display_build_infos()
     echo "  BUILD64:  ${BUILD64}"
     echo "  CFLAGS:   ${CFLAGS}"
     echo "  CPPFLAGS: ${CPPFLAGS}"
-    echo "  CXXFLAGS: ${CFLAGS}"
+    echo "  CXXFLAGS: ${CXXFLAGS}"
     echo "  LDFLAGS:  ${LDFLAGS}"
     echo "  RANLIB:   ${RANLIB}"
     echo "  CC:       ${CC}"
@@ -817,6 +794,8 @@ indicate_pkg_build_complete()
     local PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done
 
     ipkg_display_build_infos > ${PACKAGE_STATUS}
+    echo "Source size: " ${SOURCE_SIZE} >> ${PACKAGE_STATUS}
+    echo "Build  size: " ${BUILD_SIZE}  >> ${PACKAGE_STATUS}
     echo -n "Build time: " >> ${PACKAGE_STATUS}
     display_build_time >> ${PACKAGE_STATUS}
     echo -e "\n" >> ${PACKAGE_STATUS}
@@ -827,6 +806,7 @@ indicate_pkg_build_complete()
 # Arg. #1: Package name and version (ex: gcc-4.5.1)
 # Remaining arguments: Additional configure options
 # Options:
+#   -c     Do not decompress package
 #   -j     Disable parallel make for this package
 #   -l     Unique identification label in 'install.log'
 #          (default is package name and version)
@@ -843,15 +823,21 @@ ipkg()
     START_TIME=$(echo `date +%s`)
 
     unset ALT_SCRIPT_NAME
+
+    export DECOMPRESS="1"
     export IPKG_MODE="ac" # Default mode if not specified
     export HVLABEL="" # Global variable
 
     local HVMAKE_ORIG=${HVMAKE}
 
-    while getopts "jl:m:s:" flag ;do
+    while getopts "cjl:m:s:" flag ;do
         case ${flag} in
+            c)
+                # Do not decompress package
+                DECOMPRESS="0"
+                ;;
             j)
-                # Disable parallel make onlyfor this package
+                # Disable parallel make only for this package
                 HVMAKE="make"
                 ;;
            l)
@@ -906,12 +892,16 @@ ipkg()
 
     PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log
     PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done
+    PACKAGE_STATUS=${LFS_LOG_DIR}/${HVLABEL}.status
 
     # Checking if package was previously successfully installed
     if [ -f ${PACKAGE_DONE} ]; then
        return $EXIT_SUCCESS
     fi
 
+    # Create or empty status file
+    cp /dev/null ${PACKAGE_STATUS}
+
     # Displaying label
     MSGSTRING="Installing ${HVLABEL}"
     display_checkbox_msg ${MSGSTRING}
@@ -935,6 +925,12 @@ ipkg()
     # Make sure we are at a known location
     cd ${SCRDIR}
 
+    if [ "x${LFS_STAGE}" != "xstage0" -a "x${LFS_STAGE}" != "xstage1" ]; then
+       # Make sure to update dynamic linker run-time bindings, except for
+       # stages 0 and 1 where we run as the LFS user.
+       ldconfig
+    fi
+
     exec 1>&6 # Restore stdout.
 
     # Displaying build time after the package name.
@@ -999,12 +995,16 @@ rscr()
 
     PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log
     PACKAGE_DONE=${LFS_LOG_DIR}/${HVLABEL}.done
+    PACKAGE_STATUS=${LFS_LOG_DIR}/${HVLABEL}.status
 
     if [ "x${SCRMODE}" = "xonce" ]; then
         # Checking if package was previously successfully installed
         if [ -f ${PACKAGE_DONE} ]; then
            return $EXIT_SUCCESS
         fi
+
+        # Create or empty status file
+        cp /dev/null ${PACKAGE_STATUS}
     fi
 
     display_checkbox_msg ${MSGSTRING}
@@ -1012,7 +1012,7 @@ rscr()
     ipkg_trap_setup
 
     echo "------------------------" 1>> ${LFS_LOG_FILE}
-    echo ${HVLABEL} 1>> ${LFS_LOG_FILE}
+    echo "Running script ${HVLABEL}" 1>> ${LFS_LOG_FILE}
 
     # Executing script
     ${SCRDIR}/${SCRIPT} ${SCRIPT_ARGS} 1>> ${PACKAGE_LOG} 2>&1
@@ -1024,7 +1024,7 @@ rscr()
     echo "Completed" 1>> ${LFS_LOG_FILE}
 
     if [ "x${SCRMODE}" = "xonce" ]; then
-        # Report successfull installation of the package.
+        # Report successfull installation of the script.
         indicate_pkg_build_complete ${HVLABEL}
     fi