Ajout Makefile stage0
authorgobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Fri, 4 Mar 2011 04:55:43 +0000 (04:55 +0000)
committergobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Fri, 4 Mar 2011 04:55:43 +0000 (04:55 +0000)
20 files changed:
functions
functions-ac [deleted file]
functions-fpkg [new file with mode: 0644]
functions-ipkg [new file with mode: 0644]
functions-update [deleted file]
stage0/INSTALL
stage0/Makefile [new file with mode: 0644]
stage0/hv-install-1 [new file with mode: 0755]
stage0/hv-install-2 [new file with mode: 0755]
stage0/install-1 [deleted file]
stage0/install-2 [deleted file]
stage0/packages-update
stage1/packages-update
stage2/INSTALL
stage2/packages-update
stage3/packages-update
stage4/packages-update
stage5/packages-update
stage6/packages-update
sysinfos

index 17dcbdb..89230b9 100644 (file)
--- a/functions
+++ b/functions
@@ -496,23 +496,14 @@ hv_groupadd()
 {
     arguments=${*}
 
-    set +e
-
+    # The last argument is the group name
     while [ $# -ne 0 ]; do
-       last_argument=${*}
+       groupname=${*}
        shift
     done
 
-    groupadd ${arguments}
-    error=$?
-
-    set -e
-
-    if [ ${error} -eq 0 -o ${error} -eq 9 ]; then
-        # 9 means the group already exists
-        return ${EXIT_SUCCESS}
-    else
-        exit ${EXIT_FAILURE}
+    if ! cat /etc/group | egrep "^${groupname}:" 1> /dev/null 2>&1; then
+        groupadd ${arguments}    
     fi
 }
 
@@ -522,7 +513,7 @@ hv_useradd()
 {
     arguments="${*}"
 
-    # The last argument is the username
+    # The last argument is the user name
     while [ $# -ne 0 ]; do
        username=${*}
        shift
@@ -753,9 +744,9 @@ ipkg_display_build_infos()
 #   -l     Unique identification label in 'install.log'
 #          (default is package name and version)
 #   -m     Installation mode:
-#            ac   Standard autoconf package, build in separate dir
-#            acnb Standard autoconf package, building in source dir
-#            nb   No autoconf (configure)
+#            ac   Standard autoconf package, build in separate dir (default)
+#            acnb Standard autoconf package, build in source dir
+#            noac No autoconf (configure)
 #            gnome
 #            xorg
 #            pm
@@ -847,7 +838,7 @@ ipkg()
     exec > ${PACKAGE_LOG} 2>&1
 
     # Sourcing standard ac script.
-    source ${SCRDIR}/../functions-ac
+    source ${SCRDIR}/../functions-ipkg
     source ${SCRDIR}/${DEFAULT_IPKG_SCRIPT}
     ipkg_script ${ALT_SCRIPT_NAME}
 
diff --git a/functions-ac b/functions-ac
deleted file mode 100644 (file)
index f8669af..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/bin/bash
-
-function_exists()
-{
-    local FUNCTION_NAME=$1
-
-    [ -z "$FUNCTION_NAME" ] && return 1
-
-    declare -F "$FUNCTION_NAME" > /dev/null 2>&1
-
-    return $?
-}
-
-unset -f hvconfig_pre
-unset -f hvconfig_cache
-unset -f hvconfig_post
-unset -f hvbuild_post
-
-ipkg_decompress_package()
-{
-    echo "Decompressing package"
-    decompress_package ${PACKAGE}
-
-    local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE})
-
-    # Rename the decompressed package as per the package name if necessary
-    if [ "x${DECOMPRESSED_DIRNAME}" != "x${PACKAGE}" ]; then
-        mv -v ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ${LFS_TMP}/${PACKAGE}
-    fi
-
-    # Displaying package source size in log file
-    echo "  Source size:" $(du -h -s ${LFS_TMP}/${PACKAGE} | awk '{ print $1 }') 1>> ${LFS_LOG_FILE}
-
-    # Removing old build directory (if any)
-    if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then
-        echo "Removing old build directory"
-       rm -rf ${LFS_TMP}/${PACKAGE}-build
-    fi
-
-    # Creating build directory
-    mkdir -v ${LFS_TMP}/${PACKAGE}-build
-}
-
-# Default configure function
-hvconfig()
-{
-    if [ "x${IPKG_MODE}" = "xacnb" -o "x${IPKG_MODE}" = "xpm" ]; then
-        # Broken autoconf package that must build in source dir, or Perl module.
-        cd ${LFS_TMP}/${PACKAGE}
-    else
-        # Standard autoconf mode
-        cd ${LFS_TMP}/${PACKAGE}-build
-    fi
-
-    if [ "x${IPKG_MODE}" = "xpm" ]; then
-        # Configure Perl module.
-        # The option "-n" is used to avoid having to answer a question and
-        # accept the default configuration.
-        perl Makefile.PL -n ${CONFIGURE_OPTS}
-    else
-        # Standard configure script
-        ${LFS_TMP}/${PACKAGE}/configure ${CONFIGURE_OPTS}
-    fi
-}
-
-# Default build function
-hvbuild()
-{
-    if [ "x${IPKG_MODE}" = "xacnb" -o \
-        "x${IPKG_MODE}" = "xnoac" -o \
-        "x${IPKG_MODE}" = "xpm" ]; then
-        # Broken autoconf package that must build in source dir, or Perl module.
-        cd ${LFS_TMP}/${PACKAGE}
-    fi
-
-    ${HVMAKE}
-    ${HVMAKE} install
-}
-
-# Default patch applying function
-hvpatch()
-{
-    # Applying patches (if any)
-    apply_patches ${PACKAGE}
-}
-
-ipkg_finish()
-{
-    # Make sure to return to scripts directory
-    cd ${SCRDIR}
-
-    # Displaying package build size in log file
-    BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${PACKAGE} ${LFS_TMP}/${PACKAGE}-build | grep total | awk '{ print $1 }')
-    echo "  Build size : ${BUILD_SIZE}" 1>> ${LFS_LOG_FILE}
-
-    # Some scripts need to preserve the source or build directory. They can
-    # do so by renaming them.
-    if [ -d ${LFS_TMP}/${PACKAGE} ]; then
-       # Removing source directory
-        echo "Removing source directory"
-       rm -rf ${LFS_TMP}/${PACKAGE}
-    fi
-    if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then
-       # Removing build directory
-        echo "Removing build directory"
-       rm -rf ${LFS_TMP}/${PACKAGE}-build
-    fi
-}
-
-# This is the main function doing all the work
-# Arg #1: alternate script name (optional)
-ipkg_script()
-{
-    if [ $# -eq 1 ]; then
-        # Use supplied script name
-        PACKAGE_DEF=${SCRDIR}/pkg/${1}
-    else
-        # Use default script name
-        PACKAGE_DEF=${SCRDIR}/pkg/$(get_pkg_name ${PACKAGE})
-
-    fi
-
-    ipkg_decompress_package
-
-    if [ -f ${PACKAGE_DEF} ]; then
-        echo "Load custom package functions and definitions from ${PACKAGE_DEF}"
-        source ${PACKAGE_DEF}
-    fi
-
-    hvpatch
-
-    # Execute pre-configure function if applicable
-    if function_exists hvconfig_pre ; then
-        echo "Running configure pre-script"
-        hvconfig_pre
-    fi
-
-    # Execute config-cache function if applicable
-    if function_exists hvconfig_cache ; then
-        echo "Running configure cache script"
-        hvconfig_cache
-        CONFIGURE_OPTS="\
-            ${CONFIGURE_OPTS} \
-            --cache-file=${LFS_TMP}/${PACKAGE}-build/config.cache"
-    fi
-
-    ipkg_display_build_infos
-
-    if [ "x${IPKG_MODE}" = "xnoac" ]; then
-        echo "Not calling configure because ${PACKAGE} has no configure script"
-    else
-        hvconfig
-    fi
-
-    # Execute post-configure function if applicable
-    if function_exists hvconfig_post ; then
-        echo "Running configure post-script"
-        hvconfig_post
-    fi
-
-    hvbuild
-
-    # Execute post-build function if applicable
-    if function_exists hvbuild_post ; then
-        echo "Running build post-script"
-        hvbuild_post
-    fi
-
-    ipkg_finish
-}
diff --git a/functions-fpkg b/functions-fpkg
new file mode 100644 (file)
index 0000000..a72b304
--- /dev/null
@@ -0,0 +1,556 @@
+#!/bin/bash
+
+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"
+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"
+BLFS_PATCHES_URL="${LFS_BASE_URL}/patches/blfs/svn"
+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://cdnetworks-us-1.dl.sourceforge.net"
+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"
+BLFS_XORG_URL="http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg"
+XORG_URL="http://xorg.freedesktop.org/releases/individual"
+
+WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=15 --tries=3 -nc --continue --no-check-certificate --no-verbose --output-file=${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()
+{
+    PATCHES_URL=${1}
+    PATCHES_LIST_FILENAME=${2}
+
+    ${WGETCMD} "${PATCHES_URL}/" &&
+
+    # Append log to global log file
+    cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE} &&
+
+    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()
+{
+    # Execute a return statement instead of exit, to be able to continue with
+    # downloading other packages
+    export RCMD_NO_EXIT=1
+
+    # First create log directory if it does not exists.
+    if [ ! -d ${LFS_LOG_DIR} ]; then
+       install -m755 -d ${LFS_LOG_DIR} || exit 1
+    fi
+
+    # Then create destination directory if it does not exists.
+    if [ ! -d ${LFS_PKG_DIR} ]; then
+       install -v -m755 -d ${LFS_PKG_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
+    fi
+
+    if [ -n "${USE_LFS_PATCHES}" ]; then
+        # Getting list of all patches from LFS server.
+        rcmd "Fetching LFS patches list" static_fetch_patches_list ${LFS_PATCHES_URL} ${LFS_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}
+    fi
+
+    if [ -n "${USE_CLFS_PATCHES}" ]; then
+        # Getting list of all patches from CLFS server.
+        rcmd "Fetching CLFS patches list" static_fetch_patches_list ${CLFS_PATCHES_URL} ${CLFS_PATCHES_LIST}
+    fi
+
+    if [ -n "${USE_HV_PATCHES}" ]; then
+        # Getting list of all patches from hugovil.com server.
+        rcmd "Fetching hugovil.com patches list" static_fetch_patches_list ${HV_PATCHES_URL} ${HV_PATCHES_LIST}
+    fi
+}
+
+# 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()
+{
+    local PACK=${1}
+    local PATCHES_LIST=${2}
+    local PATCHES_URL=${3}
+
+    # 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/")
+    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
+               rcmd "Fetching ${PATCH_NAME} 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()
+{
+    PACK=${1}
+
+    # Checking for correct number of arguments
+    if [ $# -ne 1 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    if [ -n "${USE_LFS_PATCHES}" ]; then
+        # Checking if patch is available from LFS.
+        static_checkpatch ${PACK} ${LFS_PATCHES_LIST} ${LFS_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}
+    fi
+
+    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]
+gztobz2()
+{
+    if [ $# = 0 ]; then
+       echo "$0: -- Convert multiple compressed gzip files to bzip2."
+       echo "Usage: $0: [FILES]"
+       return 1
+    fi
+    
+    while [ $# -ne 0 ]; do
+       local ORIG_GZIPPED_FILENAME=${1}
+       
+       # Checking if input file exist.
+       if [ ! -f $1 ]; then
+           echo "$0: File ${ORIG_GZIPPED_FILENAME} not found."
+           return 1
+       fi
+       
+       # Checking if input file is a valid gzipped file.
+       gzip -t ${ORIG_GZIPPED_FILENAME}
+       if [ $? -ne 0 ] ; then
+           echo "$0: File ${ORIG_GZIPPED_FILENAME} is not a valid gzip file."
+           return 1
+       fi
+       
+       # Obtaining uncompressed name of file
+       local FILENAME=$(gunzip -l ${ORIG_GZIPPED_FILENAME} | sed '1d' | sed 's/\(.*\)% \(.*\)/\2/')
+       
+       # Decompressing file to standard output and piping result to bzip2
+       gunzip ${ORIG_GZIPPED_FILENAME} --stdout | bzip2 --best > ${FILENAME}.bz2
+       if [ $? -ne 0 ] ; then
+           echo "$0: Error converting file ${ORIG_GZIPPED_FILENAME} to bzip2."
+           return 1
+       fi
+       
+       # Keeping the original file's timestamp
+       touch --reference=${ORIG_GZIPPED_FILENAME} ${FILENAME}.bz2
+       
+       # Deleting original gzipped file
+       if [ -f ${FILENAME}.bz2 ]; then
+           rm ${ORIG_GZIPPED_FILENAME}
+       fi
+       
+       shift
+    done
+}
+
+detect_file_not_found()
+{
+    # HTTP: will return error code 404.
+    # FTP: will say "File not found"
+    if grep "404" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
+        echo "404 NOTFOUND"
+        return 0
+    elif grep "No such file" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
+        echo "No such file"
+        return 0
+    else
+        return 1
+    fi
+}
+
+# Get package if it is not in the repository
+# Arg. #1: Package name and version
+# Arg. #2: URL
+# Arg. #3: Optional extension
+static_getpkg()
+{
+    local PACK=${1}
+    local URL=${2}
+    local MY_ARCH_EXT=${3}
+
+    # Checking for correct number of arguments
+    if [ $# -ne 2 -a $# -ne 3 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    if [ -z "${MY_ARCH_EXT}" ]; then
+        # List of default archive extensions to try
+        MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z"
+    fi
+
+    for arch_ext in ${MY_ARCH_EXT}; do
+        # Don't take any chance: remove any partially downloaded file.
+        # If we arrive here, it means the final destination file was not found
+        # so we can safely remove any file prior to trying to download it.
+        rm -f ${LFS_PKG_DIR}/${PACK}.${arch_ext}
+
+        rcmd "Fetching ${PACK}.${arch_ext}" ${WGETCMD} ${URL}/${PACK}.${arch_ext}
+        wget_status=$?
+
+        # Append log to global log file
+        cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE}
+
+        # Failure: if it was a connection timeout, don't try for other file
+        # extensions.
+        if grep "failed: Connection timed out" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
+            echo "Error, wget reported: Connection timed out"
+            return 1
+        fi
+
+        if detect_file_not_found; then
+            # Try next archive extension if web server reported that file is not
+            # found.
+            continue;
+        fi
+
+        if [ ${wget_status} -ne 0 ]; then
+            echo "Error fetching package ${PACK}.${arch_ext}"
+            return 1
+        fi
+
+        # If we are here, it means the file was successfully downloaded.
+        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 $?
+    done
+
+    # Failure or file not found
+    return 1
+}
+
+# Get package if it is not in the repository
+# Arg. #1: Package name and version
+# Arg. #2: URL
+# Options:
+#   -e     File extension (default is tar.bz2)
+#   -d     Fetch directory (default is LFS_PKG_DIR)
+#   -f     Filename on server (default is PACKAGE)
+#   -h     Display this help and returns
+#   -s     Subdirectory on server
+fpkg()
+{
+    local FILE_EXT=""
+    local DEST_DIR=""
+    local SRC_FILENAME=""
+    local SRC_DIR=""
+
+    while getopts "e:d:f:hs:" flag ;do
+        case ${flag} in
+           e)
+                # File extension
+                FILE_EXT=${OPTARG}
+               ;;
+           d)
+                # Fetch directory (where to put file)
+                DEST_DIR=${OPTARG}
+               ;;
+           f)
+                # Filename if different than package name
+                SRC_FILENAME=${OPTARG}
+               ;;
+           s)
+               SRC_DIR=${OPTARG}
+                ;;
+           ?)
+               echo "${FUNCNAME}(): Invalid option: ${OPTARG}."
+               return 1
+               ;;
+        esac
+    done
+    shift `expr "${OPTIND}" - 1`
+
+    unset OPTSTRING
+    unset OPTIND
+    unset OPTARG
+
+    # Checking for correct number of arguments
+    if [ $# -ne 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    local PACK=${1}
+    local URL=${2}
+
+    if [ -z "${SRC_FILENAME}" ]; then
+        # Default source filename = name of package
+        SRC_FILENAME=${PACK}
+    fi
+
+    if [ -z "${FILE_EXT}" -o \
+        "x${FILE_EXT}" = "xtar.gz" -o \
+        "x${FILE_EXT}" = "xtgz" -o \
+        "x${FILE_EXT}" = "xtar.Z" -o \
+        "x${FILE_EXT}" = "xtar.bz2" \
+        ]; then
+        FINAL_EXT=tar.bz2
+    else
+        FINAL_EXT=${FILE_EXT}
+    fi
+
+    if [ -z "${DEST_DIR}" ]; then
+        # Default destination directory
+        DEST_DIR=${LFS_PKG_DIR}
+    fi
+
+    mkdir -v -p ${DEST_DIR} >> ${LFS_LOG_FILE} 2>&1
+
+    if [ -z "${SRC_DIR}" ]; then
+        # Default source subdirectory on server
+        SRC_DIR=""
+    else
+        URL=${URL}/${SRC_DIR}
+    fi
+
+    DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT}
+
+    if [ ! -f ${DEST_FILE} ]; then
+        set +e
+        static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT}
+        set -e
+
+        # Move file if source filename is not equal to package name and/or destination
+        # directory is not the default:
+        DOWNLOADED_FILE=${LFS_PKG_DIR}/${SRC_FILENAME}.${FINAL_EXT}
+
+        if [ "${DEST_FILE}" != "${DOWNLOADED_FILE}" ]; then
+           mv ${DOWNLOADED_FILE} ${DEST_FILE}
+       fi
+    fi
+
+    # Test integrity of archive if requested
+    if [ -f ${DEST_FILE} -a -n "${TEST_INTEGRITY}" -a "x${FINAL_EXT}" = "xtar.bz2" ]; then
+        rcmd "Testing integrity of ${PACK}.${FINAL_EXT}" bzip2 -t ${DEST_FILE}
+    fi
+
+    # Check for available patches with PACKAGE (TARGET) name.
+    static_getpatch ${PACK}
+
+    if [ ${SRC_FILENAME} != ${PACK} ]; then
+        # Check for available patches with SRC_FILENAME name.
+        static_getpatch ${SRC_FILENAME}
+
+        # Rename any patch fetched (in fpkg call) and replace SOURCE by TARGET
+        # in patch name.
+        if ls ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch 1> /dev/null 2>&1; then
+            echo "CMD=${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch"
+           rename ${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch
+        fi
+    fi
+}
+
+# Get package if it is not in the repository
+# Arg. #1: Package name and version
+# Arg. #2: Directory name (optional)
+fpkg_gnu()
+{
+    local PACK=${1}
+
+    if [ $# -eq 2 ]; then
+       NAME=${2}
+    else
+       NAME=$(get_pkg_name ${PACK})
+    fi
+
+    # Checking for correct number of arguments
+    if [ $# -lt 1 -o $# -gt 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    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()
+{
+    PACK=${1}
+
+    if [ $# -eq 2 ]; then
+       NAME=${2}
+    else
+       NAME=$(get_pkg_name ${PACK})
+    fi
+
+    # Checking for correct number of arguments
+    if [ $# -lt 1 -o $# -gt 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    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()
+{
+    PACK=${1}
+
+    if [ $# -eq 2 ]; then
+       NAME=${2}
+    else
+       NAME=$(get_pkg_name ${PACK})
+    fi
+    
+    # Checking for correct number of arguments
+    if [ $# -lt 1 -o $# -gt 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    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()
+{
+    PACK=${1}
+
+    # Checking for correct number of arguments
+    if [ $# -lt 1 -o $# -gt 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    if [ $# -eq 2 ]; then
+       fpkg ${PACK} "${HV_PACKAGES_URL}/${2}"
+    else
+       fpkg ${PACK} ${HV_PACKAGES_URL}
+    fi
+}
+
+# Get package if it is not in the repository
+# Arg. #1: Package name and version
+# Arg. #2: Directory name (optional)
+fpkg_lfs()
+{
+    PACK=${1}
+
+    # Checking for correct number of arguments
+    if [ $# -lt 1 -o $# -gt 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    if [ $# -eq 2 ]; then
+       fpkg ${PACK} "${LFS_PACKAGES_URL}/${2}"
+    else
+       fpkg ${PACK} ${LFS_PACKAGES_URL}
+    fi
+}
+
+# Get package if it is not in the repository
+# Arg. #1: Package name and version
+# Arg. #2: Subdirectory name (module name)
+fpkg_xorg()
+{
+    local PACK=${1}
+    local SUBDIR=${2}
+
+    # Checking for correct number of arguments
+    if [ $# -ne 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    fpkg -d ${LFS_PKG_DIR}/${SUBDIR} -s ${SUBDIR} ${PACK} ${XORG_URL}
+}
+
+# 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()
+{
+    SRCSTAGE="stage${1}"
+    FILE="${2}.tar.bz2"
+    PACKAGE_NAME="${2}"
+
+    # Checking for correct number of arguments
+    if [ $# -ne 2 ]; then
+       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
+       return 1
+    fi
+
+    if [ ! -h ${LFS_PKG_DIR}/${FILE} ]; then
+       # Issue a warning if source file doesn't exist.
+       if [ ! -f ${LFS_PKG_BASE}/${SRCSTAGE}/${FILE} ]; then
+            source_link_status=" (missing source file)"
+        else
+            source_link_status=""
+       fi
+
+       # Create link if it doesn't exist
+       rcmd "Linking ${PACKAGE_NAME}${source_link_status}" ln -s ../${SRCSTAGE}/${FILE} ${LFS_PKG_DIR}/${FILE}
+    fi
+
+    # Create link for patches corresponding to that package:
+    if ls ${LFS_PKG_BASE}/${SRCSTAGE}/${PACKAGE_NAME}-*.patch 1> /dev/null 2>&1; then
+       for patch in ${LFS_PKG_BASE}/${SRCSTAGE}/${PACKAGE_NAME}-*.patch; do
+           PATCHFILE=$(basename ${patch})
+           if [ ! -h ${LFS_PKG_DIR}/${PATCHFILE} ]; then
+               # Create link if it doesn't exist
+               rcmd "Linking ${PATCHFILE}" ln -s ../${SRCSTAGE}/${PATCHFILE} ${LFS_PKG_DIR}/${PATCHFILE}
+           fi
+       done
+    fi
+}
diff --git a/functions-ipkg b/functions-ipkg
new file mode 100644 (file)
index 0000000..f8669af
--- /dev/null
@@ -0,0 +1,170 @@
+#!/bin/bash
+
+function_exists()
+{
+    local FUNCTION_NAME=$1
+
+    [ -z "$FUNCTION_NAME" ] && return 1
+
+    declare -F "$FUNCTION_NAME" > /dev/null 2>&1
+
+    return $?
+}
+
+unset -f hvconfig_pre
+unset -f hvconfig_cache
+unset -f hvconfig_post
+unset -f hvbuild_post
+
+ipkg_decompress_package()
+{
+    echo "Decompressing package"
+    decompress_package ${PACKAGE}
+
+    local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE})
+
+    # Rename the decompressed package as per the package name if necessary
+    if [ "x${DECOMPRESSED_DIRNAME}" != "x${PACKAGE}" ]; then
+        mv -v ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ${LFS_TMP}/${PACKAGE}
+    fi
+
+    # Displaying package source size in log file
+    echo "  Source size:" $(du -h -s ${LFS_TMP}/${PACKAGE} | awk '{ print $1 }') 1>> ${LFS_LOG_FILE}
+
+    # Removing old build directory (if any)
+    if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then
+        echo "Removing old build directory"
+       rm -rf ${LFS_TMP}/${PACKAGE}-build
+    fi
+
+    # Creating build directory
+    mkdir -v ${LFS_TMP}/${PACKAGE}-build
+}
+
+# Default configure function
+hvconfig()
+{
+    if [ "x${IPKG_MODE}" = "xacnb" -o "x${IPKG_MODE}" = "xpm" ]; then
+        # Broken autoconf package that must build in source dir, or Perl module.
+        cd ${LFS_TMP}/${PACKAGE}
+    else
+        # Standard autoconf mode
+        cd ${LFS_TMP}/${PACKAGE}-build
+    fi
+
+    if [ "x${IPKG_MODE}" = "xpm" ]; then
+        # Configure Perl module.
+        # The option "-n" is used to avoid having to answer a question and
+        # accept the default configuration.
+        perl Makefile.PL -n ${CONFIGURE_OPTS}
+    else
+        # Standard configure script
+        ${LFS_TMP}/${PACKAGE}/configure ${CONFIGURE_OPTS}
+    fi
+}
+
+# Default build function
+hvbuild()
+{
+    if [ "x${IPKG_MODE}" = "xacnb" -o \
+        "x${IPKG_MODE}" = "xnoac" -o \
+        "x${IPKG_MODE}" = "xpm" ]; then
+        # Broken autoconf package that must build in source dir, or Perl module.
+        cd ${LFS_TMP}/${PACKAGE}
+    fi
+
+    ${HVMAKE}
+    ${HVMAKE} install
+}
+
+# Default patch applying function
+hvpatch()
+{
+    # Applying patches (if any)
+    apply_patches ${PACKAGE}
+}
+
+ipkg_finish()
+{
+    # Make sure to return to scripts directory
+    cd ${SCRDIR}
+
+    # Displaying package build size in log file
+    BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${PACKAGE} ${LFS_TMP}/${PACKAGE}-build | grep total | awk '{ print $1 }')
+    echo "  Build size : ${BUILD_SIZE}" 1>> ${LFS_LOG_FILE}
+
+    # Some scripts need to preserve the source or build directory. They can
+    # do so by renaming them.
+    if [ -d ${LFS_TMP}/${PACKAGE} ]; then
+       # Removing source directory
+        echo "Removing source directory"
+       rm -rf ${LFS_TMP}/${PACKAGE}
+    fi
+    if [ -d ${LFS_TMP}/${PACKAGE}-build ]; then
+       # Removing build directory
+        echo "Removing build directory"
+       rm -rf ${LFS_TMP}/${PACKAGE}-build
+    fi
+}
+
+# This is the main function doing all the work
+# Arg #1: alternate script name (optional)
+ipkg_script()
+{
+    if [ $# -eq 1 ]; then
+        # Use supplied script name
+        PACKAGE_DEF=${SCRDIR}/pkg/${1}
+    else
+        # Use default script name
+        PACKAGE_DEF=${SCRDIR}/pkg/$(get_pkg_name ${PACKAGE})
+
+    fi
+
+    ipkg_decompress_package
+
+    if [ -f ${PACKAGE_DEF} ]; then
+        echo "Load custom package functions and definitions from ${PACKAGE_DEF}"
+        source ${PACKAGE_DEF}
+    fi
+
+    hvpatch
+
+    # Execute pre-configure function if applicable
+    if function_exists hvconfig_pre ; then
+        echo "Running configure pre-script"
+        hvconfig_pre
+    fi
+
+    # Execute config-cache function if applicable
+    if function_exists hvconfig_cache ; then
+        echo "Running configure cache script"
+        hvconfig_cache
+        CONFIGURE_OPTS="\
+            ${CONFIGURE_OPTS} \
+            --cache-file=${LFS_TMP}/${PACKAGE}-build/config.cache"
+    fi
+
+    ipkg_display_build_infos
+
+    if [ "x${IPKG_MODE}" = "xnoac" ]; then
+        echo "Not calling configure because ${PACKAGE} has no configure script"
+    else
+        hvconfig
+    fi
+
+    # Execute post-configure function if applicable
+    if function_exists hvconfig_post ; then
+        echo "Running configure post-script"
+        hvconfig_post
+    fi
+
+    hvbuild
+
+    # Execute post-build function if applicable
+    if function_exists hvbuild_post ; then
+        echo "Running build post-script"
+        hvbuild_post
+    fi
+
+    ipkg_finish
+}
diff --git a/functions-update b/functions-update
deleted file mode 100644 (file)
index a72b304..0000000
+++ /dev/null
@@ -1,556 +0,0 @@
-#!/bin/bash
-
-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"
-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"
-BLFS_PATCHES_URL="${LFS_BASE_URL}/patches/blfs/svn"
-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://cdnetworks-us-1.dl.sourceforge.net"
-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"
-BLFS_XORG_URL="http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg"
-XORG_URL="http://xorg.freedesktop.org/releases/individual"
-
-WGETCMD="wget --directory-prefix=${LFS_PKG_DIR} --timeout=15 --tries=3 -nc --continue --no-check-certificate --no-verbose --output-file=${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()
-{
-    PATCHES_URL=${1}
-    PATCHES_LIST_FILENAME=${2}
-
-    ${WGETCMD} "${PATCHES_URL}/" &&
-
-    # Append log to global log file
-    cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE} &&
-
-    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()
-{
-    # Execute a return statement instead of exit, to be able to continue with
-    # downloading other packages
-    export RCMD_NO_EXIT=1
-
-    # First create log directory if it does not exists.
-    if [ ! -d ${LFS_LOG_DIR} ]; then
-       install -m755 -d ${LFS_LOG_DIR} || exit 1
-    fi
-
-    # Then create destination directory if it does not exists.
-    if [ ! -d ${LFS_PKG_DIR} ]; then
-       install -v -m755 -d ${LFS_PKG_DIR} 1> ${LFS_LOG_FILE} 2>&1 || exit 1
-    fi
-
-    if [ -n "${USE_LFS_PATCHES}" ]; then
-        # Getting list of all patches from LFS server.
-        rcmd "Fetching LFS patches list" static_fetch_patches_list ${LFS_PATCHES_URL} ${LFS_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}
-    fi
-
-    if [ -n "${USE_CLFS_PATCHES}" ]; then
-        # Getting list of all patches from CLFS server.
-        rcmd "Fetching CLFS patches list" static_fetch_patches_list ${CLFS_PATCHES_URL} ${CLFS_PATCHES_LIST}
-    fi
-
-    if [ -n "${USE_HV_PATCHES}" ]; then
-        # Getting list of all patches from hugovil.com server.
-        rcmd "Fetching hugovil.com patches list" static_fetch_patches_list ${HV_PATCHES_URL} ${HV_PATCHES_LIST}
-    fi
-}
-
-# 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()
-{
-    local PACK=${1}
-    local PATCHES_LIST=${2}
-    local PATCHES_URL=${3}
-
-    # 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/")
-    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
-               rcmd "Fetching ${PATCH_NAME} 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()
-{
-    PACK=${1}
-
-    # Checking for correct number of arguments
-    if [ $# -ne 1 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    if [ -n "${USE_LFS_PATCHES}" ]; then
-        # Checking if patch is available from LFS.
-        static_checkpatch ${PACK} ${LFS_PATCHES_LIST} ${LFS_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}
-    fi
-
-    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]
-gztobz2()
-{
-    if [ $# = 0 ]; then
-       echo "$0: -- Convert multiple compressed gzip files to bzip2."
-       echo "Usage: $0: [FILES]"
-       return 1
-    fi
-    
-    while [ $# -ne 0 ]; do
-       local ORIG_GZIPPED_FILENAME=${1}
-       
-       # Checking if input file exist.
-       if [ ! -f $1 ]; then
-           echo "$0: File ${ORIG_GZIPPED_FILENAME} not found."
-           return 1
-       fi
-       
-       # Checking if input file is a valid gzipped file.
-       gzip -t ${ORIG_GZIPPED_FILENAME}
-       if [ $? -ne 0 ] ; then
-           echo "$0: File ${ORIG_GZIPPED_FILENAME} is not a valid gzip file."
-           return 1
-       fi
-       
-       # Obtaining uncompressed name of file
-       local FILENAME=$(gunzip -l ${ORIG_GZIPPED_FILENAME} | sed '1d' | sed 's/\(.*\)% \(.*\)/\2/')
-       
-       # Decompressing file to standard output and piping result to bzip2
-       gunzip ${ORIG_GZIPPED_FILENAME} --stdout | bzip2 --best > ${FILENAME}.bz2
-       if [ $? -ne 0 ] ; then
-           echo "$0: Error converting file ${ORIG_GZIPPED_FILENAME} to bzip2."
-           return 1
-       fi
-       
-       # Keeping the original file's timestamp
-       touch --reference=${ORIG_GZIPPED_FILENAME} ${FILENAME}.bz2
-       
-       # Deleting original gzipped file
-       if [ -f ${FILENAME}.bz2 ]; then
-           rm ${ORIG_GZIPPED_FILENAME}
-       fi
-       
-       shift
-    done
-}
-
-detect_file_not_found()
-{
-    # HTTP: will return error code 404.
-    # FTP: will say "File not found"
-    if grep "404" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
-        echo "404 NOTFOUND"
-        return 0
-    elif grep "No such file" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
-        echo "No such file"
-        return 0
-    else
-        return 1
-    fi
-}
-
-# Get package if it is not in the repository
-# Arg. #1: Package name and version
-# Arg. #2: URL
-# Arg. #3: Optional extension
-static_getpkg()
-{
-    local PACK=${1}
-    local URL=${2}
-    local MY_ARCH_EXT=${3}
-
-    # Checking for correct number of arguments
-    if [ $# -ne 2 -a $# -ne 3 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    if [ -z "${MY_ARCH_EXT}" ]; then
-        # List of default archive extensions to try
-        MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z"
-    fi
-
-    for arch_ext in ${MY_ARCH_EXT}; do
-        # Don't take any chance: remove any partially downloaded file.
-        # If we arrive here, it means the final destination file was not found
-        # so we can safely remove any file prior to trying to download it.
-        rm -f ${LFS_PKG_DIR}/${PACK}.${arch_ext}
-
-        rcmd "Fetching ${PACK}.${arch_ext}" ${WGETCMD} ${URL}/${PACK}.${arch_ext}
-        wget_status=$?
-
-        # Append log to global log file
-        cat ${WGET_LOG_FILE} >> ${LFS_LOG_FILE}
-
-        # Failure: if it was a connection timeout, don't try for other file
-        # extensions.
-        if grep "failed: Connection timed out" ${WGET_LOG_FILE} 1> /dev/null 2>&1; then
-            echo "Error, wget reported: Connection timed out"
-            return 1
-        fi
-
-        if detect_file_not_found; then
-            # Try next archive extension if web server reported that file is not
-            # found.
-            continue;
-        fi
-
-        if [ ${wget_status} -ne 0 ]; then
-            echo "Error fetching package ${PACK}.${arch_ext}"
-            return 1
-        fi
-
-        # If we are here, it means the file was successfully downloaded.
-        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 $?
-    done
-
-    # Failure or file not found
-    return 1
-}
-
-# Get package if it is not in the repository
-# Arg. #1: Package name and version
-# Arg. #2: URL
-# Options:
-#   -e     File extension (default is tar.bz2)
-#   -d     Fetch directory (default is LFS_PKG_DIR)
-#   -f     Filename on server (default is PACKAGE)
-#   -h     Display this help and returns
-#   -s     Subdirectory on server
-fpkg()
-{
-    local FILE_EXT=""
-    local DEST_DIR=""
-    local SRC_FILENAME=""
-    local SRC_DIR=""
-
-    while getopts "e:d:f:hs:" flag ;do
-        case ${flag} in
-           e)
-                # File extension
-                FILE_EXT=${OPTARG}
-               ;;
-           d)
-                # Fetch directory (where to put file)
-                DEST_DIR=${OPTARG}
-               ;;
-           f)
-                # Filename if different than package name
-                SRC_FILENAME=${OPTARG}
-               ;;
-           s)
-               SRC_DIR=${OPTARG}
-                ;;
-           ?)
-               echo "${FUNCNAME}(): Invalid option: ${OPTARG}."
-               return 1
-               ;;
-        esac
-    done
-    shift `expr "${OPTIND}" - 1`
-
-    unset OPTSTRING
-    unset OPTIND
-    unset OPTARG
-
-    # Checking for correct number of arguments
-    if [ $# -ne 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    local PACK=${1}
-    local URL=${2}
-
-    if [ -z "${SRC_FILENAME}" ]; then
-        # Default source filename = name of package
-        SRC_FILENAME=${PACK}
-    fi
-
-    if [ -z "${FILE_EXT}" -o \
-        "x${FILE_EXT}" = "xtar.gz" -o \
-        "x${FILE_EXT}" = "xtgz" -o \
-        "x${FILE_EXT}" = "xtar.Z" -o \
-        "x${FILE_EXT}" = "xtar.bz2" \
-        ]; then
-        FINAL_EXT=tar.bz2
-    else
-        FINAL_EXT=${FILE_EXT}
-    fi
-
-    if [ -z "${DEST_DIR}" ]; then
-        # Default destination directory
-        DEST_DIR=${LFS_PKG_DIR}
-    fi
-
-    mkdir -v -p ${DEST_DIR} >> ${LFS_LOG_FILE} 2>&1
-
-    if [ -z "${SRC_DIR}" ]; then
-        # Default source subdirectory on server
-        SRC_DIR=""
-    else
-        URL=${URL}/${SRC_DIR}
-    fi
-
-    DEST_FILE=${DEST_DIR}/${PACK}.${FINAL_EXT}
-
-    if [ ! -f ${DEST_FILE} ]; then
-        set +e
-        static_getpkg ${SRC_FILENAME} ${URL} ${FILE_EXT}
-        set -e
-
-        # Move file if source filename is not equal to package name and/or destination
-        # directory is not the default:
-        DOWNLOADED_FILE=${LFS_PKG_DIR}/${SRC_FILENAME}.${FINAL_EXT}
-
-        if [ "${DEST_FILE}" != "${DOWNLOADED_FILE}" ]; then
-           mv ${DOWNLOADED_FILE} ${DEST_FILE}
-       fi
-    fi
-
-    # Test integrity of archive if requested
-    if [ -f ${DEST_FILE} -a -n "${TEST_INTEGRITY}" -a "x${FINAL_EXT}" = "xtar.bz2" ]; then
-        rcmd "Testing integrity of ${PACK}.${FINAL_EXT}" bzip2 -t ${DEST_FILE}
-    fi
-
-    # Check for available patches with PACKAGE (TARGET) name.
-    static_getpatch ${PACK}
-
-    if [ ${SRC_FILENAME} != ${PACK} ]; then
-        # Check for available patches with SRC_FILENAME name.
-        static_getpatch ${SRC_FILENAME}
-
-        # Rename any patch fetched (in fpkg call) and replace SOURCE by TARGET
-        # in patch name.
-        if ls ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch 1> /dev/null 2>&1; then
-            echo "CMD=${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch"
-           rename ${SRC_FILENAME} ${PACK} ${LFS_PKG_DIR}/${SRC_FILENAME}-*.patch
-        fi
-    fi
-}
-
-# Get package if it is not in the repository
-# Arg. #1: Package name and version
-# Arg. #2: Directory name (optional)
-fpkg_gnu()
-{
-    local PACK=${1}
-
-    if [ $# -eq 2 ]; then
-       NAME=${2}
-    else
-       NAME=$(get_pkg_name ${PACK})
-    fi
-
-    # Checking for correct number of arguments
-    if [ $# -lt 1 -o $# -gt 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    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()
-{
-    PACK=${1}
-
-    if [ $# -eq 2 ]; then
-       NAME=${2}
-    else
-       NAME=$(get_pkg_name ${PACK})
-    fi
-
-    # Checking for correct number of arguments
-    if [ $# -lt 1 -o $# -gt 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    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()
-{
-    PACK=${1}
-
-    if [ $# -eq 2 ]; then
-       NAME=${2}
-    else
-       NAME=$(get_pkg_name ${PACK})
-    fi
-    
-    # Checking for correct number of arguments
-    if [ $# -lt 1 -o $# -gt 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    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()
-{
-    PACK=${1}
-
-    # Checking for correct number of arguments
-    if [ $# -lt 1 -o $# -gt 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    if [ $# -eq 2 ]; then
-       fpkg ${PACK} "${HV_PACKAGES_URL}/${2}"
-    else
-       fpkg ${PACK} ${HV_PACKAGES_URL}
-    fi
-}
-
-# Get package if it is not in the repository
-# Arg. #1: Package name and version
-# Arg. #2: Directory name (optional)
-fpkg_lfs()
-{
-    PACK=${1}
-
-    # Checking for correct number of arguments
-    if [ $# -lt 1 -o $# -gt 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    if [ $# -eq 2 ]; then
-       fpkg ${PACK} "${LFS_PACKAGES_URL}/${2}"
-    else
-       fpkg ${PACK} ${LFS_PACKAGES_URL}
-    fi
-}
-
-# Get package if it is not in the repository
-# Arg. #1: Package name and version
-# Arg. #2: Subdirectory name (module name)
-fpkg_xorg()
-{
-    local PACK=${1}
-    local SUBDIR=${2}
-
-    # Checking for correct number of arguments
-    if [ $# -ne 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    fpkg -d ${LFS_PKG_DIR}/${SUBDIR} -s ${SUBDIR} ${PACK} ${XORG_URL}
-}
-
-# 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()
-{
-    SRCSTAGE="stage${1}"
-    FILE="${2}.tar.bz2"
-    PACKAGE_NAME="${2}"
-
-    # Checking for correct number of arguments
-    if [ $# -ne 2 ]; then
-       echo "${FUNCNAME}(), wrong number of arguments: ${*}"
-       return 1
-    fi
-
-    if [ ! -h ${LFS_PKG_DIR}/${FILE} ]; then
-       # Issue a warning if source file doesn't exist.
-       if [ ! -f ${LFS_PKG_BASE}/${SRCSTAGE}/${FILE} ]; then
-            source_link_status=" (missing source file)"
-        else
-            source_link_status=""
-       fi
-
-       # Create link if it doesn't exist
-       rcmd "Linking ${PACKAGE_NAME}${source_link_status}" ln -s ../${SRCSTAGE}/${FILE} ${LFS_PKG_DIR}/${FILE}
-    fi
-
-    # Create link for patches corresponding to that package:
-    if ls ${LFS_PKG_BASE}/${SRCSTAGE}/${PACKAGE_NAME}-*.patch 1> /dev/null 2>&1; then
-       for patch in ${LFS_PKG_BASE}/${SRCSTAGE}/${PACKAGE_NAME}-*.patch; do
-           PATCHFILE=$(basename ${patch})
-           if [ ! -h ${LFS_PKG_DIR}/${PATCHFILE} ]; then
-               # Create link if it doesn't exist
-               rcmd "Linking ${PATCHFILE}" ln -s ../${SRCSTAGE}/${PATCHFILE} ${LFS_PKG_DIR}/${PATCHFILE}
-           fi
-       done
-    fi
-}
index 485fe6d..9ac34f1 100644 (file)
@@ -9,4 +9,4 @@ Installation
 2. Modify the 'sysinfos' configuration file to reflect your
    system configuration.
 
-3. Launch './install-1'
+3. Launch './hv-install-1'
diff --git a/stage0/Makefile b/stage0/Makefile
new file mode 100644 (file)
index 0000000..5fd7c05
--- /dev/null
@@ -0,0 +1,24 @@
+# Makefile for hvlinux
+
+# Pour émuler option command-line --silent ?
+#.SILENT:
+
+# Idées pour future targets:
+#   clean
+#   strip
+#   compress -> compressdoc (à partir du stage2)
+#   dep
+#   list -> list installed packages and versions
+
+.PHONY: get test
+
+all: get
+       @./hv-install-1
+
+# Fetch packages from network
+get:
+       @./packages-update
+
+# Test integrity of packages
+test:
+       @./packages-update test
diff --git a/stage0/hv-install-1 b/stage0/hv-install-1
new file mode 100755 (executable)
index 0000000..260e3c4
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+hvtrap_setup
+source ../packages-list
+
+init_log_file
+
+rscr mult "Performing pre-install" pre-install
+
+# Logging-in as 'lfs' user, and executing the hv-install-2 script. The
+# 'su -' command starts with a clean environment and enters the home
+# directory of the user.
+su - lfs -c "cd ${PWD}; ./hv-install-2"
+
+echo "Total build time: $(get_total_build_time ${LFS_LOG_FILE})h"
+
+exit 0
diff --git a/stage0/hv-install-2 b/stage0/hv-install-2
new file mode 100755 (executable)
index 0000000..6bcd4d2
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+source ~/.bashrc
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+init_log_file
+
+ipkg -m noac ${KERNEL}
+
+case "${HVL_TARGET}" in
+    x86*)
+        ipkg ${FILE_PKG}
+        ipkg ${NCURSES}
+        ;;
+esac
+
+CPPFLAGS=-fexceptions \
+    ipkg ${GMP} "--enable-cxx"
+
+export LDFLAGS="-Wl,-rpath,/cross-tools/lib"
+
+ipkg ${MPFR} "\
+    --enable-shared \
+    --with-gmp=/cross-tools"
+ipkg ${MPC} "\
+    --with-gmp=/cross-tools \
+    --with-mpfr=/cross-tools"
+ipkg ${PPL} "\
+    --enable-shared \
+    --enable-interfaces=c,cxx \
+    --disable-optimization \
+    --with-libgmp-prefix=/cross-tools \
+    --with-libgmpxx-prefix=/cross-tools"
+ipkg ${CLOOG_PPL} "\
+    --enable-shared \
+    --with-bits=gmp \
+    --with-gmp=/cross-tools \
+    --with-ppl=/cross-tools"
+
+LDFLAGS=""
+
+ipkg ${BINUTILS}
+ipkg -l "${GCC}-pass1" ${GCC}
+ipkg ${EGLIBC}
+ipkg -l "${GCC}-pass2" ${GCC}
+
+exit $?
diff --git a/stage0/install-1 b/stage0/install-1
deleted file mode 100755 (executable)
index 1d6b6c8..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-hvtrap_setup
-source ../packages-list
-
-init_log_file
-
-rscr mult "Performing pre-install" pre-install
-
-# Logging-in as 'lfs' user, and executing the install-2 script. The
-# 'su -' command starts with a clean environment and enters the home
-# directory of the user.
-su - lfs -c "cd ${PWD}; ./install-2"
-
-echo "Total build time: $(get_total_build_time ${LFS_LOG_FILE})h"
-
-exit 0
diff --git a/stage0/install-2 b/stage0/install-2
deleted file mode 100755 (executable)
index 6bcd4d2..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-source ~/.bashrc
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-init_log_file
-
-ipkg -m noac ${KERNEL}
-
-case "${HVL_TARGET}" in
-    x86*)
-        ipkg ${FILE_PKG}
-        ipkg ${NCURSES}
-        ;;
-esac
-
-CPPFLAGS=-fexceptions \
-    ipkg ${GMP} "--enable-cxx"
-
-export LDFLAGS="-Wl,-rpath,/cross-tools/lib"
-
-ipkg ${MPFR} "\
-    --enable-shared \
-    --with-gmp=/cross-tools"
-ipkg ${MPC} "\
-    --with-gmp=/cross-tools \
-    --with-mpfr=/cross-tools"
-ipkg ${PPL} "\
-    --enable-shared \
-    --enable-interfaces=c,cxx \
-    --disable-optimization \
-    --with-libgmp-prefix=/cross-tools \
-    --with-libgmpxx-prefix=/cross-tools"
-ipkg ${CLOOG_PPL} "\
-    --enable-shared \
-    --with-bits=gmp \
-    --with-gmp=/cross-tools \
-    --with-ppl=/cross-tools"
-
-LDFLAGS=""
-
-ipkg ${BINUTILS}
-ipkg -l "${GCC}-pass1" ${GCC}
-ipkg ${EGLIBC}
-ipkg -l "${GCC}-pass2" ${GCC}
-
-exit $?
index a719bb4..b110c61 100755 (executable)
@@ -8,7 +8,7 @@ USE_HV_PATCHES=1
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 update_packages_init
index 7add361..bd39bce 100755 (executable)
@@ -6,7 +6,7 @@ USE_HV_PATCHES=1
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 update_packages_init
index d009cd4..bb329b6 100644 (file)
@@ -1,57 +1,24 @@
+stage2: Installing basic system software
+Installation
+------------
 
-Installation instructions
--------------------------
+1. Launch ./hv-install-1
 
-Note: In this example, the destination partition is /dev/hda6, and
-      the sources partition is /dev/hda10.
+2. Compile new kernel (enable loadable modules support)
 
-1. Create and/or format the destination partition:
-       >$ mkreiserfs /dev/hda6
+3. Type 'exit'
 
-2. Mount the partition:
-       >$ mount -t reiserfs /dev/hda6 /mnt/linux
+4. Reboot.
 
-3. In the destination partition root, create a directory that will
-   be used to mount the CD or hard disk partition containing the sources:
-       >$ cd /mnt/linux
-       >$ mkdir -p mnt/hvlinux
+5. Run script /usr/local/bin/udev-create-persistent-net.sh
 
-4. Mount the sources partition:
-       >$ mount -t reiserfs /dev/hda10 /mnt/linux/mnt/hvlinux
-
-5. Copy the tools directory to the LFS (/mnt/linux) partition:
-       >$ cp -a /mnt/linux/mnt/hvlinux/tools /mnt/linux
-   This is needed only if you did not run stage1 installation
-  
-6. Modify the "/mnt/linux/mnt/hvlinux/scripts/sysinfos" file to
-   reflect your configuration.
-
-7. If you want a separate boot partition, make sure it is mounted
-   under ${LFS}/boot.
-
-8. Launch the installation of stage 2:
-       >$ /mnt/linux/mnt/hvlinux/scripts/stage2/install-1
-
-9. After that, compile a fresh kernel.
-   (réactiver support pour les modules)
-
-10. type 'exit'
-
-11. You can now remove the /mnt/linux/tools directory.
-
-12. Reboot.
-
-13. When the GRUB prompt appears, install grub on the MBR with:
+6. Optional. To install GRUB, launch 'grub'. When the GRUB prompt appears,
+   install grub on the MBR with (example with boot partition on first partition
+   of first disk):
     grub> root (hd0,0)
     grub> setup (hd0)
     grub> reboot
 
-14. login as root, and create the password for the regular user:
+7. Login as root, and create the password for the regular user:
     >$ passwd reguser
-
-Post-install guide
-------------------
-    1. Compiler nouveau kernel
-    2. Ajouter une entrée à /boot/grub/menu.lst
-    3. Effacer le répertoire /tools et /cross-tools
-    4. Rouler le script /usr/local/bin/udev-create-persistent-net.sh
index fd9ba07..9bb528a 100755 (executable)
@@ -8,7 +8,7 @@ USE_HV_PATCHES=1
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 update_packages_init
index 8d5f230..3d0b79b 100755 (executable)
@@ -7,7 +7,7 @@ USE_HV_PATCHES=1
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 update_packages_init
index 5d0f82a..dd607d5 100755 (executable)
@@ -7,7 +7,7 @@ USE_HV_PATCHES=1
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 # Execute a return statement instead of exit, to be able to continue with
index 247ef96..7532cdf 100755 (executable)
@@ -7,7 +7,7 @@ USE_HV_PATCHES=1
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 # Execute a return statement instead of exit, to be able to continue with
index 3213409..1ca8aed 100644 (file)
@@ -3,7 +3,7 @@
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
 source ../functions
-source ../functions-update
+source ../functions-fpkg
 source ../packages-list
 
 update_packages_init
index 4607dfb..f5a38dc 100644 (file)
--- a/sysinfos
+++ b/sysinfos
@@ -17,7 +17,7 @@ REGUSER="hugo"
 # Destination path where to install new Linux-HV system. This is usually where
 # you have mounted your new LFS partition, but it can also be any directory.
 # This is relevant only for stage 0 and 1.
-LFS="/mnt/hvlinux"
+LFS="/mnt/stockage/hvlinux-hp-mini"
 
 # Destination partition where to install new Linux-HV system
 LFS_PARTITION="/dev/sdb7"
@@ -33,10 +33,13 @@ SWAP_PARTITION="/dev/sdb2"
 # arm926t - ARM 926T little endian
 # x86 (i686)
 # x86_64 (AMD Athlon 64)
-HVL_TARGET="x86_64"
+HVL_TARGET="x86"
 
 # Used for setting '-march=xxx' option in CFLAGS and CPPFLAGS
-MACHINE_ARCHITECTURE=""
+# GCC-4.5
+MARCH_FLAGS="-march=atom -mssse3 -mfpmath=sse -fomit-frame-pointer"
+# GCC < 4.5
+MARCH_FLAGS="-march=core2 -mtune=generic -mssse3 -mfpmath=sse -fomit-frame-pointer"
 
 # Keyboard mapping (example: us)
 KEYBOARD="us"