From: gobo72 Date: Sat, 6 Nov 2010 04:53:23 +0000 (+0000) Subject: -Completed transition to new ipkg method (ipkg.def), but still problem with eglibc... X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=0028eaa73ae0c3bd1dbf90c4bd508ae705bc386f;p=hvlinux.git -Completed transition to new ipkg method (ipkg.def), but still problem with eglibc linker after booting into stage 1. --- diff --git a/TODO b/TODO index b32888c..d26a9ad 100644 --- a/TODO +++ b/TODO @@ -60,8 +60,6 @@ SPIP: mysql database name: -ldconfig et source /etc/profile: éxécuter automatiquement après chaque installation d'un package. --Mettre "local" devant chaque variable des fonctions dans functions et functions-update. - -BIND: run in IPV4 mode only (option "-4") Mounting network volumes: check if networking is up. @@ -92,7 +90,4 @@ Ajouter une variable "package_location" dans sysinfos Faire un script de test (tester la présence de certains programmes à la toute fin de l'installation (ou dans chaque script d'installation) -Vérifier si tous les packages acceptent correctement les CFLAGS. Sinon, les passer -directement au script... - "ls --timestyle=long-iso" --> /etc/bashrc ??? diff --git a/functions b/functions index 9c863ea..7497f3a 100644 --- a/functions +++ b/functions @@ -22,10 +22,17 @@ BRACKET="\033[1;34m" TAR_OPTS="-b8" +# List of default archive extensions to try +MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z zip" + HV_FONTS_PATH="/usr/share/fonts" DEFAULT_EDITOR=nano +DEFAULT_IPKG_SCRIPT="ipkg.def" + +source ./stage.def + # It seems that when compiling bash-4.0, using # "make -j 1" is causing problems... if [ "x${MAKEJOBS}" = "x1" ]; then @@ -68,17 +75,33 @@ CLFS_HOST="$(echo $MACHTYPE | \ export CLFS_BUILDFLAGS CLFS_TARGET CLFS_ARCH CLFS_HOST CLFS_ENDIAN CLFS_NOT_ENDIAN +if [ -z "${LFS_STAGE}" ]; then + echo "LFS_STAGE is undefined (see stage.def)" + return ${EXIT_FAILURE} +fi + +if [ "x${LFS_STAGE}" != "xstage0" -a "x${LFS_STAGE}" != "xstage1" ] ;then + LFS="" +fi + CLFS=${LFS} -function function_exists +# Create log directory and log file for current stage if necessary +# This should be done automatically... +init_log_file() { - local FUNCTION_NAME=$1 - - [ -z "$FUNCTION_NAME" ] && return 1 + # Scripts directory + export SCRDIR=$(pwd) - declare -F "$FUNCTION_NAME" > /dev/null 2>&1 + export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" + export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} + export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log + export LFS_TMP="${LFS}/tmp" - return $? + mkdir -p ${LFS_LOG_DIR} && + if [ ! -f ${LFS_LOG_FILE} ]; then + touch ${LFS_LOG_FILE} || exit 1 + fi } # Extracting the version number from a complete package name. @@ -167,16 +190,6 @@ restore_flags() return ${EXIT_SUCCESS} } -# Create log directory and log file for current stage if necessary -# This should be done automatically... -init_log_file() -{ - mkdir -p ${LFS_LOG_DIR} && - if [ ! -f ${LFS_LOG_FILE} ]; then - touch ${LFS_LOG_FILE} || exit 1 - fi -} - # Create symbolic links for start/stop scripts in /etc/rc.d # # Arg #1: script name @@ -205,27 +218,27 @@ static_bootscript_add() fi # Making sure bootscript has correct permissions - chmod -v 740 ${LFS}/etc/rc.d/init.d/${SCRIPTNAME} && + chmod -v 740 ${LFS}/etc/rc.d/init.d/${SCRIPTNAME} # Removing any old links for level in sysinit 0 1 2 3 4 5 6; do - cd ${LFS}/etc/rc.d/rc${level}.d && - rm -v -f $(find . -name "???${SCRIPTNAME}") || exit 1 - done && + cd ${LFS}/etc/rc.d/rc${level}.d + rm -v -f $(find . -name "???${SCRIPTNAME}") + done if [ ${START} -ne 0 ]; then # Creating new start links for level in ${START_LEVELS}; do - cd ${LFS}/etc/rc.d/rc${level}.d && - ln -v -s ../init.d/${SCRIPTNAME} S${START}${SCRIPTNAME} || exit 1 + cd ${LFS}/etc/rc.d/rc${level}.d + ln -v -s ../init.d/${SCRIPTNAME} S${START}${SCRIPTNAME} done - fi && + fi if [ ${STOP} -ne 0 ]; then # Creating new stop links for level in ${STOP_LEVELS}; do - cd ${LFS}/etc/rc.d/rc${level}.d && - ln -v -s ../init.d/${SCRIPTNAME} K${STOP}${SCRIPTNAME} || exit 1 + cd ${LFS}/etc/rc.d/rc${level}.d + ln -v -s ../init.d/${SCRIPTNAME} K${STOP}${SCRIPTNAME} done fi } @@ -244,22 +257,22 @@ bootscript_add_manual() local STOP=${4} # Making sure bootscript has correct permissions - chmod 740 ${LFS}/etc/rc.d/init.d/${SCRIPTNAME} && + chmod 740 ${LFS}/etc/rc.d/init.d/${SCRIPTNAME} # Removing any old links - cd ${LFS}/etc/rc.d/rc${RCLEVEL}.d && - rm -v -f $(find . -name "???${SCRIPTNAME}") && + cd ${LFS}/etc/rc.d/rc${RCLEVEL}.d + rm -v -f $(find . -name "???${SCRIPTNAME}") if [ ${START} -ne 0 ]; then # Creating new start link - cd ${LFS}/etc/rc.d/rc${RCLEVEL}.d && - ln -v -s ../init.d/${SCRIPTNAME} S${START}${SCRIPTNAME} || exit 1 - fi && + cd ${LFS}/etc/rc.d/rc${RCLEVEL}.d + ln -v -s ../init.d/${SCRIPTNAME} S${START}${SCRIPTNAME} + fi if [ ${STOP} -ne 0 ]; then # Creating new stop link - cd ${LFS}/etc/rc.d/rc${RCLEVEL}.d && - ln -v -s ../init.d/${SCRIPTNAME} K${STOP}${SCRIPTNAME} || exit 1 + cd ${LFS}/etc/rc.d/rc${RCLEVEL}.d + ln -v -s ../init.d/${SCRIPTNAME} K${STOP}${SCRIPTNAME} fi } @@ -369,10 +382,10 @@ var_add() # PATH=... matches but not MANPATH=... if grep "^${VARIABLE}=\"" ${FILE} 1> /dev/null 2>&1; then # Variable value is enclosed by double-quotes - sed -i "s!\(^${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE} || exit 1 + sed -i "s!\(^${VARIABLE}=\".*\)\(\"\)!\1${SEP}${VALUE}\"!" ${FILE} else # Variable value is NOT enclosed by double-quotes - sed -i "s!\(^${VARIABLE}=.*\)!\1${SEP}${VALUE}!" ${FILE} || exit 1 + sed -i "s!\(^${VARIABLE}=.*\)!\1${SEP}${VALUE}!" ${FILE} fi # Adding new value to variable (case with export before) @@ -529,54 +542,6 @@ hv_useradd() exit ${EXIT_FAILURE} fi } - -# Evaluates the return value of the process that was run just before this -# function was called. -eval_retval() -{ - if [ $? -ne 0 ]; then - print_status failure - exit ${EXIT_FAILURE} - fi -} - -# Obtain the name of the base directory for the decompressed package. -# First argument: package name -static_decompressed_dirname() -{ - local PACKAGE=${1} - - # List of default archive extensions to try - local MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z zip" - - for arch_ext in ${MY_ARCH_EXT}; do - if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ]; then - # Try next archive extension. - continue; - fi - - case ${arch_ext} in - tar.bz2|tar.gz|tgz|tar.Z) - # Remove optional "./" leading component with sed - # 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}') - echo ${DIRNAME} - ;; - zip) - # TODO - echo ${PACKAGE} - ;; - esac - - return $? - done - - # Failure or file not found - echo "${FUNCNAME}(): Missing source package for \"${PACKAGE}\"" > /dev/stderr - return ${EXIT_FAILURE} -} # Applying patch # First argument is the name of the patch @@ -631,13 +596,48 @@ apply_patches() 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} || exit 1 + apply_patch ${patch} ${TARGET_DIR} done fi return $? } +# Obtain the name of the base directory for the decompressed package. +# First argument: package name +static_decompressed_dirname() +{ + local PACKAGE=${1} + + for arch_ext in ${MY_ARCH_EXT}; do + if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ]; then + # Try next archive extension. + continue; + fi + + case ${arch_ext} in + tar.bz2|tar.gz|tgz|tar.Z) + # Remove optional "./" leading component with sed + # 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}') + echo ${DIRNAME} + ;; + zip) + # TODO + echo ${PACKAGE} + ;; + esac + + return $? + done + + # Failure or file not found + echo "${FUNCNAME}(): Missing source package for \"${PACKAGE}\"" > /dev/stderr + return ${EXIT_FAILURE} +} + # Decompression of a package # First argument: package name # Second argument: directory where decompressing (optional) @@ -655,9 +655,6 @@ decompress_package() local PACKAGE=${1} - # List of default archive extensions to try - local MY_ARCH_EXT="tar.bz2 tar.gz tgz tar.Z zip" - for arch_ext in ${MY_ARCH_EXT}; do if [ ! -f ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ]; then # Try next archive extension. @@ -666,27 +663,24 @@ decompress_package() if [ -d ${TOPDIR}/${PACKAGE} ]; then # Removing old source directory (if any) - rm -v -rf ${TOPDIR}/${PACKAGE} || exit 1 + rm -rf ${TOPDIR}/${PACKAGE} fi - cd ${TOPDIR} - # Decompressing package case ${arch_ext} in tar.bz2) - tar ${TAR_OPTS} -jxvf ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} || return 1 + tar -C ${TOPDIR} ${TAR_OPTS} -jxf \ + ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ;; tar.gz|tgz|tar.Z) - tar ${TAR_OPTS} -zxvf ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} || return 1 + tar -C ${TOPDIR} ${TAR_OPTS} -zxf \ + ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ;; zip) - echo ZIPZIPZIP - unzip ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} || return 1 + unzip -qq -d ${TOPDIR} ${LFS_PKG_DIR}/${PACKAGE}.${arch_ext} ;; esac - cd - 1> /dev/null 2>&1 - return $? done @@ -695,6 +689,50 @@ decompress_package() return ${EXIT_FAILURE} } +hvtrap_setup() +{ + # Setting ERR trap does implicit `set -o errexit'. + trap hvtrap_err ERR + trap hvtrap_int INT +} + +hvtrap_err() +{ + echo + echo "*** An error occured during ${LFS_STAGE}" + exit 1 +} + +hvtrap_int() +{ + echo + echo "*** Installation interrupted during ${LFS_STAGE}" + exit 1 +} + +ipkg_trap_setup() +{ + exec 6>&1 # Save current "value" of stdout. + trap ipkg_trap_handler INT TERM EXIT ERR +} + +ipkg_trap_end() +{ + trap - INT TERM EXIT ERR + + # Restore global trap + hvtrap_setup +} + +ipkg_trap_handler() +{ + exec 1>&6 6>&- # Restore stdout and close file descriptor #6. + print_status failure + + ipkg_trap_end + exit 1 +} + # Installation of a package # Arg. #1: Package name and version (ex: gcc-4.5.1) # Remaining arguments: Additional configure options @@ -709,14 +747,15 @@ decompress_package() # gnome # xorg # pm -# -s Name of script to execute (default is ipkg.sh) +# -s Name of script to execute or name of definition file (default is +# to source ipkg.def) ipkg() { START_TIME=$(echo `date +%s`) export IPKG_MODE="ac" export HVLABEL="" # Global variable - local SCRIPT=./ipkg.sh + local SCRIPT=${DEFAULT_IPKG_SCRIPT} while getopts "hl:m:" flag ;do case ${flag} in @@ -739,6 +778,12 @@ ipkg() s) # Alternate script name SCRIPT=${OPTARG} + + # Checking if script is valid and executable + if [ ! -x ${SCRIPT} ]; then + echo "${FUNCNAME}(): cannot execute script: ${SCRIPT}" + exit ${EXIT_FAILURE} + fi ;; ?) echo "${FUNCNAME}(): Invalid option: ${OPTARG}." @@ -752,7 +797,7 @@ ipkg() unset OPTIND unset OPTARG - local PACKAGE_NAME=${1} + export PACKAGE=${1} # Checking for correct number of arguments if [ $# -lt 1 ]; then @@ -763,18 +808,11 @@ ipkg() fi shift - local CONFIGURE_OPTS=${*} + export CONFIGURE_OPTS=${*} if [ -z "${HVLABEL}" ]; then # Default label = package name and version - HVLABEL=${PACKAGE_NAME} - fi - - # Checking if script is valid and executable - if [ ! -x ${SCRIPT} ]; then - echo - echo "${FUNCNAME}(): cannot execute script: ${SCRIPT}" - exit ${EXIT_FAILURE} + HVLABEL=${PACKAGE} fi PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log @@ -789,57 +827,28 @@ ipkg() MSGSTRING="Installing ${HVLABEL}" display_checkbox_msg ${MSGSTRING} + ipkg_trap_setup + echo "------------------------" 1>> ${LFS_LOG_FILE} echo "${MSGSTRING}" 1>> ${LFS_LOG_FILE} - echo "Decompressing package" 1>> ${PACKAGE_LOG} 2>&1 && - decompress_package ${PACKAGE_NAME} 1> /dev/null 2>> ${PACKAGE_LOG} - eval_retval - - local DECOMPRESSED_DIRNAME=$(static_decompressed_dirname ${PACKAGE_NAME}) + # All output from commands in this block sent to file $PACKAGE_LOG. + exec > ${PACKAGE_LOG} 2>&1 - # Rename the decompressed package as per the package name if necessary - if [ "x${DECOMPRESSED_DIRNAME}" != "x${PACKAGE_NAME}" ]; then - mv ${LFS_TMP}/${DECOMPRESSED_DIRNAME} ${LFS_TMP}/${PACKAGE_NAME} - eval_retval + if [ "x${SCRIPT}" = "x${DEFAULT_IPKG_SCRIPT}" ]; then + # Executing standard ac script. + source ${SCRDIR}/../functions-ac + source ${SCRDIR}/${DEFAULT_IPKG_SCRIPT} + ipkg_script + else + # Executing custom script. + ${SCRIPT} ${PACKAGE} ${CONFIGURE_OPTS} fi - # Displaying package source size in log file - echo " Source size:" $(du -h -s ${LFS_TMP}/${PACKAGE_NAME} | awk '{ print $1 }') 1>> ${LFS_LOG_FILE} + # Make sure we are at a known location + cd ${SCRDIR} - # Removing old build directory (if any) - if [ -d ${LFS_TMP}/${PACKAGE_NAME}-build ]; then - echo "Removing old build directory" 1>> ${PACKAGE_LOG} 2>&1 && - rm -v -rf ${LFS_TMP}/${PACKAGE_NAME}-build 1> /dev/null 2>> ${PACKAGE_LOG} - eval_retval - fi - - # Creating build directory - mkdir -v ${LFS_TMP}/${PACKAGE_NAME}-build 1>> ${PACKAGE_LOG} 2>&1 - eval_retval - - # Executing script. - ${SCRIPT} ${PACKAGE_NAME} ${CONFIGURE_OPTS} 1>> ${PACKAGE_LOG} 2>&1 - eval_retval - - # Displaying package build size in log file - BUILD_SIZE=$(du -h -s -c ${LFS_TMP}/${PACKAGE_NAME} ${LFS_TMP}/${PACKAGE_NAME}-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_NAME} ]; then - # Removing source directory - echo "Removing source directory" 1>> ${PACKAGE_LOG} 2>&1 && - rm -v -rf ${LFS_TMP}/${PACKAGE_NAME} 1> /dev/null 2>> ${PACKAGE_LOG} - eval_retval - fi - if [ -d ${LFS_TMP}/${PACKAGE_NAME}-build ]; then - # Removing build directory - echo "Removing build directory" 1>> ${PACKAGE_LOG} 2>&1 && - rm -v -rf ${LFS_TMP}/${PACKAGE_NAME}-build 1> /dev/null 2>> ${PACKAGE_LOG} - eval_retval - fi + exec 1>&6 # Restore stdout. # Writing success string to the end of the log file echo "${HVLABEL} successfully installed" 1>> ${LFS_LOG_FILE} @@ -847,43 +856,7 @@ ipkg() # Displaying build time after the package name print_status success - return $EXIT_SUCCESS -} - -# Run command, no log -# First argument: Message to display during script -# Second argument: command + arguments -rcmd() -{ - START_TIME=$(echo `date +%s`) - - # Checking for correct number of arguments - if [ $# -lt 2 ]; then - echo "${FUNCNAME}(): Missing argument(s)" - exit ${EXIT_FAILURE} - fi - - local MSGSTRING=${1} - local CMD=${2} - shift - local CMD_WITH_ARGS=${*} - - display_checkbox_msg ${MSGSTRING} - echo ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} - - # Executing command - ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} 2>&1 - if [ $? -ne 0 ]; then - print_status failure - if [ -n "${RCMD_NO_EXIT}" ]; then - return ${EXIT_FAILURE} - else - exit ${EXIT_FAILURE} - fi - fi - - # Displaying build time after the package name - print_status success + ipkg_trap_end return $EXIT_SUCCESS } @@ -914,6 +887,9 @@ rscr() shift SCRIPT_ARGS=${*} + # Make sure we are at a known location + cd ${SCRDIR} + # Checking script mode: if [ "x${SCRMODE}" != "xonce" -a "x${SCRMODE}" != "xmult" ]; then echo "${FUNCNAME}(): First argument invalid, must be \"once\" or \"mult\" (\"${SCRMODE}\" given)" @@ -921,7 +897,7 @@ rscr() fi # Checking if script is valid and executable - if [ ! -x ./${SCRIPT} ]; then + if [ ! -x ${SCRDIR}/${SCRIPT} ]; then echo "${FUNCNAME}(): script not found: ${SCRIPT}" exit ${EXIT_FAILURE} fi @@ -936,12 +912,14 @@ rscr() fi display_checkbox_msg ${MSGSTRING} + + ipkg_trap_setup + echo "------------------------" 1>> ${LFS_LOG_FILE} echo ${HVLABEL} 1>> ${LFS_LOG_FILE} # Executing script - ./${SCRIPT} ${SCRIPT_ARGS} 1>> ${PACKAGE_LOG} 2>&1 - eval_retval + ${SCRDIR}/${SCRIPT} ${SCRIPT_ARGS} 1>> ${PACKAGE_LOG} 2>&1 if [ "x${SCRMODE}" = "xonce" ]; then # Writing success string to the end of the log file @@ -951,6 +929,47 @@ rscr() # Displaying build time after the package name print_status success + ipkg_trap_end + + return $EXIT_SUCCESS +} + +# Run command, no log +# First argument: Message to display during script +# Second argument: command + arguments +rcmd() +{ + START_TIME=$(echo `date +%s`) + + # Checking for correct number of arguments + if [ $# -lt 2 ]; then + echo "${FUNCNAME}(): Missing argument(s)" + exit ${EXIT_FAILURE} + fi + + local MSGSTRING=${1} + local CMD=${2} + shift + local CMD_WITH_ARGS=${*} + + display_checkbox_msg ${MSGSTRING} + + echo ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} + + # Executing command + ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} 2>&1 + if [ $? -ne 0 ]; then + print_status failure + if [ -n "${RCMD_NO_EXIT}" ]; then + return ${EXIT_FAILURE} + else + exit ${EXIT_FAILURE} + fi + fi + + # Displaying build time after the package name + print_status success + return $EXIT_SUCCESS } @@ -1050,6 +1069,7 @@ print_status() # Reposition cursor at start of line echo -en "${SET_CURSOR_START_LINE}" + # Display colored 'X' echo -en "${BRACKET}[${COLOR}X${BRACKET}]${NORMAL} ${MSGSTRING}" if [ "x${MSGSTRING}" != "x" ]; then diff --git a/functions-ac b/functions-ac new file mode 100644 index 0000000..d4b3fbf --- /dev/null +++ b/functions-ac @@ -0,0 +1,149 @@ +#!/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_cache +unset -f hvconfig_pre +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() +{ + echo "Running configure with options:" + echo " <${CONFIGURE_OPTS}>" + + if [ "x${IPKG_MODE}" = "xacnb" ]; then + # Broken autoconf package that must build in source dir + cd ${LFS_TMP}/${PACKAGE} + else + # Standard autoconf mode + cd ${LFS_TMP}/${PACKAGE}-build + fi + + ${LFS_TMP}/${PACKAGE}/configure ${CONFIGURE_OPTS} +} + +# Default build function +hvbuild() +{ + if [ "x${IPKG_MODE}" = "xnoac" ]; then + 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 +ipkg_script() +{ + ipkg_decompress_package + + PACKAGE_DEF=${SCRDIR}/pkg/$(get_pkg_name ${PACKAGE}) + + if [ -f ${PACKAGE_DEF} ]; then + echo "Load custom package functions and definitions" + source ${PACKAGE_DEF} + fi + + hvpatch + + # 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 + + # Execute pre-configure function if applicable + if function_exists hvconfig_pre ; then + echo "Running configure pre-script" + hvconfig_pre + fi + + 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 +} diff --git a/stage0/install-1 b/stage0/install-1 index 749d949..22fb3aa 100755 --- a/stage0/install-1 +++ b/stage0/install-1 @@ -1,32 +1,15 @@ #!/bin/bash - -LFS_STAGE=stage0 - -# Let shell functions inherit ERR trap. Same as `set -E'. -set -o errtrace - -# Setting ERR trap does implicit `set -o errexit'. -trap myerr ERR - -function myerr() -{ - echo - echo "*** An error occured during ${LFS_STAGE}" - exit 1 -} +set -o errtrace # Let shell functions inherit ERR trap. Same as `set -E'. # Reading system configuration informations, functions and package versions. source ../sysinfos source ../functions +hvtrap_setup source ../packages-list -export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" -export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} -export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log -export LFS_TMP="${LFS}/tmp" +init_log_file -echo "Performing pre-install" -./pre-install +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 diff --git a/stage0/install-2 b/stage0/install-2 index 75e54f0..6bcd4d2 100755 --- a/stage0/install-2 +++ b/stage0/install-2 @@ -2,23 +2,13 @@ source ~/.bashrc -LFS_STAGE=stage0 - # Reading system configuration informations, functions and package versions. source ../sysinfos source ../functions source ../packages-list -export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" -export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} -export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log -export LFS_TMP="${LFS}/tmp" - init_log_file -# Scripts directory -export SCRDIR=$(pwd) - ipkg -m noac ${KERNEL} case "${HVL_TARGET}" in diff --git a/stage0/ipkg.def b/stage0/ipkg.def new file mode 100644 index 0000000..2f22bfe --- /dev/null +++ b/stage0/ipkg.def @@ -0,0 +1,6 @@ +#!/bin/bash + +# Setting default configure options for all scripts +CONFIGURE_OPTS="\ + --prefix=/cross-tools \ + ${CONFIGURE_OPTS}" diff --git a/stage0/ipkg.sh b/stage0/ipkg.sh deleted file mode 100755 index 2abb327..0000000 --- a/stage0/ipkg.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -o errexit - -# First argument of this script is the package name. -# Remaining arguments are additional configure options. - -PACKAGE=${1} -shift -CONFIGURE_OPTS=${*} - -# Reading system configuration informations, functions and package versions. -source ${SCRDIR}/../sysinfos -source ${SCRDIR}/../functions -source ${SCRDIR}/../packages-list - -# Setting default configure options for all scripts -CONFIGURE_OPTS="\ - --prefix=/cross-tools \ - ${CONFIGURE_OPTS}" - -source ${SCRDIR}/../functions-ac - -exit $? diff --git a/stage0/pre-install b/stage0/pre-install index 5183a23..c891f37 100755 --- a/stage0/pre-install +++ b/stage0/pre-install @@ -19,14 +19,13 @@ if [ ! -d ${LFS} ]; then fi # Testing for the presence of the lfs user -# We cannot always automatically create the user 'lfs' because the installation media -# can be a CD-ROM (read-only) -# If installing from some kind of live-CD, simply install as root without the LFS -# user :) +# We cannot always automatically create the user 'lfs' because the installation +# media can be a CD-ROM (read-only) If installing from some kind of live-CD, +# simply install as root without the LFS user :) if ! grep "lfs" /etc/passwd 1> /dev/null 2>&1; then + groupadd -f lfs # The option '-k /dev/null' prevents possible copying of files from a # skeleton directory (default is /etc/skel). - groupadd lfs useradd -s /bin/bash -g lfs -m -k /dev/null lfs fi diff --git a/stage0/stage.def b/stage0/stage.def new file mode 100644 index 0000000..32f39f9 --- /dev/null +++ b/stage0/stage.def @@ -0,0 +1,3 @@ +#!/bin/bash + +LFS_STAGE=stage0 diff --git a/stage1/install-1 b/stage1/install-1 index 886d265..50fbe55 100755 --- a/stage1/install-1 +++ b/stage1/install-1 @@ -1,30 +1,12 @@ #!/bin/bash - -LFS_STAGE=stage1 - -# Let shell functions inherit ERR trap. Same as `set -E'. -set -o errtrace - -# Setting ERR trap does implicit `set -o errexit'. -trap myerr ERR - -function myerr() -{ - echo - echo "*** An error occured during ${LFS_STAGE}" - exit 1 -} +set -o errtrace # Let shell functions inherit ERR trap. Same as `set -E'. # Reading system configuration informations, functions and package versions. source ../sysinfos source ../functions +hvtrap_setup source ../packages-list -export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" -export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/${LFS_STAGE} -export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log -export LFS_TMP="${LFS}/tmp" - init_log_file rscr mult "Performing pre-install" pre-install diff --git a/stage1/install-2 b/stage1/install-2 index ce63d88..4dfe6e7 100755 --- a/stage1/install-2 +++ b/stage1/install-2 @@ -8,11 +8,6 @@ source ../sysinfos source ../functions source ../packages-list -export LFS_PKG_DIR="$(dirname $(pwd))/packages/stage1" -export LFS_LOG_DIR=${LFS}/var/log/hvlinux-install/stage1 -export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log -export LFS_TMP="${LFS}/tmp" - init_log_file # Building temporary system @@ -24,9 +19,6 @@ export RANLIB="${CLFS_TARGET}-ranlib" export LD="${CLFS_TARGET}-ld" export STRIP="${CLFS_TARGET}-strip" -# Scripts directory -export SCRDIR=$(pwd) - HOST_CC=gcc CPPFLAGS=-fexceptions \ ipkg ${GMP} "--enable-cxx" ipkg ${MPFR} "--enable-shared" diff --git a/stage1/ipkg.def b/stage1/ipkg.def new file mode 100644 index 0000000..7545a87 --- /dev/null +++ b/stage1/ipkg.def @@ -0,0 +1,11 @@ +#!/bin/bash + +# Setting default configure options for all scripts +CONFIGURE_OPTS="\ + --prefix=/tools \ + --build=${CLFS_HOST} \ + --host=${CLFS_TARGET} \ + ${CONFIGURE_OPTS}" + +CC="${CC} ${CLFS_BUILDFLAGS}" +CXX="${CXX} ${CLFS_BUILDFLAGS}" diff --git a/stage1/ipkg.sh b/stage1/ipkg.sh deleted file mode 100755 index 8f0b294..0000000 --- a/stage1/ipkg.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -set -o errexit - -# First argument of this script is the package name. -# Remaining arguments are additional configure options. - -PACKAGE=${1} -shift -CONFIGURE_OPTS=${*} - -# Reading system configuration informations, functions and package versions. -source ${SCRDIR}/../sysinfos -source ${SCRDIR}/../functions -source ${SCRDIR}/../packages-list - -# Setting default configure options for all scripts -CONFIGURE_OPTS="\ - --prefix=/tools \ - --build=${CLFS_HOST} \ - --host=${CLFS_TARGET} \ - ${CONFIGURE_OPTS}" - -CC="${CC} ${CLFS_BUILDFLAGS}" -CXX="${CXX} ${CLFS_BUILDFLAGS}" - -source ${SCRDIR}/../functions-ac - -ldconfig - -exit $? diff --git a/stage1/pkg/binutils b/stage1/pkg/binutils index 293b0f1..cc0ae1b 100644 --- a/stage1/pkg/binutils +++ b/stage1/pkg/binutils @@ -1,12 +1,12 @@ #!/bin/bash CONFIGURE_OPTS="\ + ${CONFIGURE_OPTS} \ --target=${CLFS_TARGET} \ --with-lib-path=/tools/lib \ --disable-nls \ --enable-shared \ - --disable-multilib \ - ${CONFIGURE_OPTS}" + --disable-multilib" hvconfig_pre() { diff --git a/stage1/pkg/gcc b/stage1/pkg/gcc index 85d8a73..eccf480 100644 --- a/stage1/pkg/gcc +++ b/stage1/pkg/gcc @@ -1,6 +1,7 @@ #!/bin/bash CONFIGURE_OPTS="\ + ${CONFIGURE_OPTS} \ --target=${CLFS_TARGET} \ --disable-multilib \ --with-local-prefix=/tools \ @@ -12,8 +13,7 @@ CONFIGURE_OPTS="\ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ - --enable-languages=c,c++ \ - ${CONFIGURE_OPTS}" + --enable-languages=c,c++" hvpatch() { diff --git a/stage1/stage.def b/stage1/stage.def new file mode 100644 index 0000000..7c4ff90 --- /dev/null +++ b/stage1/stage.def @@ -0,0 +1,3 @@ +#!/bin/bash + +LFS_STAGE=stage1 diff --git a/stage2/install-1 b/stage2/install-1 index 279066d..abc1b9b 100755 --- a/stage2/install-1 +++ b/stage2/install-1 @@ -1,15 +1,10 @@ #!/bin/bash - -LFS_STAGE=stage2 - -export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" -export LFS_LOG_DIR=/var/log/hvlinux-install/${LFS_STAGE} -export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log -export LFS_TMP=/tmp +set -o errtrace # Let shell functions inherit ERR trap. Same as `set -E'. # Reading system configuration informations, functions and package versions. source ../sysinfos source ../functions +hvtrap_setup source ../packages-list source /etc/profile @@ -20,9 +15,6 @@ fi init_log_file -# Scripts directory -export SCRDIR=$(pwd) - ipkg -l "${PERL}-pass1" ${PERL} ipkg -m noac ${KERNEL} ipkg -m noac ${MANPAGES} diff --git a/stage2/install-2 b/stage2/install-2 index 34c3d45..da231bb 100755 --- a/stage2/install-2 +++ b/stage2/install-2 @@ -1,22 +1,12 @@ #!/bin/bash -LFS_STAGE=stage2 - # Reading system configuration informations, functions and package versions. source ../sysinfos source ../functions source ../packages-list -export LFS_PKG_DIR="$(dirname $(pwd))/packages/${LFS_STAGE}" -export LFS_LOG_DIR=/var/log/hvlinux-install/${LFS_STAGE} -export LFS_LOG_FILE=${LFS_LOG_DIR}/install.log -export LFS_TMP=/tmp - init_log_file -# Scripts directory -export SCRDIR=$(pwd) - ipkg ${GDBM} ipkg ${INETUTILS} ipkg -m noac ${BZIP2} diff --git a/stage2/stage.def b/stage2/stage.def new file mode 100644 index 0000000..6f7260f --- /dev/null +++ b/stage2/stage.def @@ -0,0 +1,3 @@ +#!/bin/bash + +LFS_STAGE=stage2 diff --git a/stage3/cis-ac b/stage3/cis-ac deleted file mode 120000 index 9214a69..0000000 --- a/stage3/cis-ac +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac \ No newline at end of file diff --git a/stage3/cis-apache b/stage3/cis-apache index 2a4fe27..2aa25e1 100755 --- a/stage3/cis-apache +++ b/stage3/cis-apache @@ -11,7 +11,7 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd ${APACHE_USER} +groupadd -f ${APACHE_USER} hv_useradd -c WebServer -d /dev/null -g ${APACHE_USER} -s /bin/false ${APACHE_USER} cd ${LFS_TMP}/${1}-build diff --git a/stage3/cis-bind b/stage3/cis-bind index a29c4c5..a908d68 100755 --- a/stage3/cis-bind +++ b/stage3/cis-bind @@ -11,7 +11,7 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd named +groupadd -f named hv_useradd -c BindOwner -g named -m -s /bin/false named cd ${LFS_TMP}/${1} diff --git a/stage3/cis-clamav b/stage3/cis-clamav index 902299d..afdaec3 100755 --- a/stage3/cis-clamav +++ b/stage3/cis-clamav @@ -11,7 +11,7 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd clamav +groupadd -f clamav hv_useradd -g clamav -s /bin/false -c Clam-AntiVirus clamav cd ${LFS_TMP}/${1} diff --git a/stage3/cis-fcron b/stage3/cis-fcron index 3abce90..4f12551 100755 --- a/stage3/cis-fcron +++ b/stage3/cis-fcron @@ -11,7 +11,7 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd fcron +groupadd -f fcron hv_useradd -c fcron -g fcron fcron cd ${LFS_TMP}/${1} diff --git a/stage3/cis-mailman b/stage3/cis-mailman index 3d10711..c27c30f 100755 --- a/stage3/cis-mailman +++ b/stage3/cis-mailman @@ -13,7 +13,7 @@ apply_patches ${1} MMPREFIX="/usr/lib/mailman" -hv_groupadd mailman +groupadd -f mailman hv_useradd -c "GNU-Mailman" -d ${MMPREFIX} -g mailman -s /bin/false mailman # Creating installation directory with correct permissions and ownerships. diff --git a/stage3/cis-mysql b/stage3/cis-mysql index 7256041..08d9f88 100755 --- a/stage3/cis-mysql +++ b/stage3/cis-mysql @@ -11,7 +11,7 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd mysql +groupadd -f mysql hv_useradd -c mysql -d /dev/null -g mysql -s /bin/false mysql cd ${LFS_TMP}/${1} diff --git a/stage3/cis-openssh b/stage3/cis-openssh index 1e2d5e2..2e36ee0 100755 --- a/stage3/cis-openssh +++ b/stage3/cis-openssh @@ -14,7 +14,7 @@ apply_patches ${1} install -v -m700 -d /var/lib/sshd chown -v root:sys /var/lib/sshd -hv_groupadd sshd +groupadd -f sshd hv_useradd -c sshd-privsep -d /var/lib/sshd -g sshd -s /bin/false sshd cd ${LFS_TMP}/${1}-build diff --git a/stage3/cis-pulseaudio b/stage3/cis-pulseaudio index 7767ed2..2dd8a07 100755 --- a/stage3/cis-pulseaudio +++ b/stage3/cis-pulseaudio @@ -11,8 +11,8 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd pulse -hv_groupadd pulse-access +groupadd -f pulse +groupadd -f pulse-access hv_useradd -g pulse -d /var/run/pulse pulse gpasswd -a hugo pulse-access diff --git a/stage3/cis-sendmail b/stage3/cis-sendmail index 5f8c206..c503ba1 100755 --- a/stage3/cis-sendmail +++ b/stage3/cis-sendmail @@ -11,8 +11,8 @@ source ../packages-list # Applying patches (if any) apply_patches ${1} -hv_groupadd smmsp -hv_groupadd mail +groupadd -f smmsp +groupadd -f mail hv_useradd -g smmsp -G mail smmsp chmod 1777 /var/mail mkdir -p /var/spool/mqueue diff --git a/stage4/cis-ac b/stage4/cis-ac deleted file mode 120000 index 9214a69..0000000 --- a/stage4/cis-ac +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac \ No newline at end of file diff --git a/stage4/cis-ac-nobuild b/stage4/cis-ac-nobuild deleted file mode 120000 index 06c3fe7..0000000 --- a/stage4/cis-ac-nobuild +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac-nobuild \ No newline at end of file diff --git a/stage4/cis-dbus b/stage4/cis-dbus index a627331..cd7ff64 100755 --- a/stage4/cis-dbus +++ b/stage4/cis-dbus @@ -16,7 +16,7 @@ CONFIGURE_OPTS=${*} # Applying patches (if any) apply_patches ${PACKAGE} -hv_groupadd -g 18 messagebus +hvgroupadd -g 18 messagebus hv_useradd -c D-BUS-Message-Daemon-User -d /dev/null \ -u 18 -g messagebus -s /bin/false messagebus diff --git a/stage5/cis-ac b/stage5/cis-ac deleted file mode 120000 index 9214a69..0000000 --- a/stage5/cis-ac +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac \ No newline at end of file diff --git a/stage5/cis-ac-nobuild b/stage5/cis-ac-nobuild deleted file mode 120000 index 06c3fe7..0000000 --- a/stage5/cis-ac-nobuild +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac-nobuild \ No newline at end of file diff --git a/stage6/cis-ac b/stage6/cis-ac deleted file mode 120000 index 9214a69..0000000 --- a/stage6/cis-ac +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac \ No newline at end of file diff --git a/stage6/cis-ac-nobuild b/stage6/cis-ac-nobuild deleted file mode 120000 index 06c3fe7..0000000 --- a/stage6/cis-ac-nobuild +++ /dev/null @@ -1 +0,0 @@ -../stage2/cis-ac-nobuild \ No newline at end of file