Merge stage1 x86_64 dans trunk
authorroot <root@364a67c3-989e-7be9-548d-dae8560ea662>
Mon, 8 Feb 2010 05:23:39 +0000 (05:23 +0000)
committerroot <root@364a67c3-989e-7be9-548d-dae8560ea662>
Mon, 8 Feb 2010 05:23:39 +0000 (05:23 +0000)
56 files changed:
stage1/INSTALL
stage1/TODO
stage1/bootscripts/checkfs [new file with mode: 0755]
stage1/bootscripts/cleanfs [new file with mode: 0755]
stage1/bootscripts/functions [new file with mode: 0644]
stage1/bootscripts/halt [new file with mode: 0755]
stage1/bootscripts/hostname [new file with mode: 0755]
stage1/bootscripts/initlog [new file with mode: 0755]
stage1/bootscripts/modules [new file with mode: 0755]
stage1/bootscripts/mountfs [new file with mode: 0755]
stage1/bootscripts/mountkernfs [new file with mode: 0755]
stage1/bootscripts/rc [new file with mode: 0755]
stage1/bootscripts/reboot [new file with mode: 0755]
stage1/bootscripts/sendsignals [new file with mode: 0755]
stage1/bootscripts/setclock [new file with mode: 0755]
stage1/bootscripts/swap [new file with mode: 0755]
stage1/bootscripts/udev [new file with mode: 0644]
stage1/cis-ac
stage1/cis-bash
stage1/cis-binutils [new file with mode: 0755]
stage1/cis-bootscripts [new file with mode: 0755]
stage1/cis-bzip2
stage1/cis-common [new file with mode: 0755]
stage1/cis-common2 [new file with mode: 0755]
stage1/cis-coreutils [new file with mode: 0755]
stage1/cis-e2fsprogs [new file with mode: 0755]
stage1/cis-findutils [new file with mode: 0755]
stage1/cis-flex [new file with mode: 0755]
stage1/cis-gcc [new file with mode: 0755]
stage1/cis-gettext
stage1/cis-m4 [new file with mode: 0755]
stage1/cis-module-init-tools [new file with mode: 0755]
stage1/cis-perl [deleted file]
stage1/cis-post-install [new file with mode: 0755]
stage1/cis-pre-install [new file with mode: 0755]
stage1/cis-stripping [deleted file]
stage1/cis-sysvinit [new file with mode: 0755]
stage1/cis-tar [new file with mode: 0755]
stage1/cis-texinfo [new file with mode: 0755]
stage1/cis-toolchain-adjust [deleted file]
stage1/cis-udev [new file with mode: 0755]
stage1/cis-util-linux [deleted file]
stage1/cis-util-linux-ng [new file with mode: 0755]
stage1/cis-zlib [new file with mode: 0755]
stage1/create-config-files [new file with mode: 0755]
stage1/create-directories [new file with mode: 0755]
stage1/create-groups [new file with mode: 0755]
stage1/create-logfiles [new file with mode: 0755]
stage1/create-symlinks [new file with mode: 0755]
stage1/create-users [new file with mode: 0755]
stage1/install-1
stage1/install-linux-minimal [new file with mode: 0755]
stage1/misc/DIR_COLORS [new file with mode: 0644]
stage1/misc/inittab [new file with mode: 0644]
stage1/packages-update
stage1/stage1-install

index 9c036d0..78eff66 100644 (file)
@@ -13,3 +13,10 @@ Installation instructions
    system configuration.
 
 4. Launch './stage1-install'
+
+Post-install guide
+------------------
+    1. Compiler nouveau kernel
+    2. Ajouter une entrée à /boot/grub/menu.lst
+    3. Créér ${LFS}/mnt/hvrepos et ajouter entrée dans ${LFS}/mnt/fstab
+    4. Copy hvlinux scripts somewhere in ${LFS}
index 5c39976..e69de29 100644 (file)
@@ -1,4 +0,0 @@
-
--Change all directories to root:root ownership after stage1 installation.
-
--Change svn tree to owner lfs:lfs automatically before starting install.
diff --git a/stage1/bootscripts/checkfs b/stage1/bootscripts/checkfs
new file mode 100755 (executable)
index 0000000..e5eaeb7
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# checkfs
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+# Printing the script name in the init log file
+log_script_name "$0 $*"
+
+# If the /fastboot file exists we don't want to run the partition checks
+if [ -f /fastboot ]; then
+    msg_box_nolog "Fast boot mode (no file systems check)"
+    FSCK_RETURN_CODE=$EXIT_CODE_SUCCESS
+else
+    # Mount the root partition read-only (just in case the kernel mounts it
+    # read-write and we don't want to run fsck on a read-write mounted
+    # partition).
+    cmd_run_log /bin/mount -o remount,ro /
+    if [ $? = 0 ]; then
+        # Check all the file systems mentioned in /etc/fstab that have the
+       # fs_passno value set to 1 or 2 (the 6th field. See man fstab for more
+       # info).
+       cmd_run_log_box_warn_checkfs "Checking file systems" /sbin/fsck -a -A -C -T
+       FSCK_RETURN_CODE=$?
+       if [ ${FSCK_RETURN_CODE} -eq ${EXIT_CODE_FAILURE} ]; then
+            # Start sulogin so we can repair the damage manually.
+            boot_failure "FAILURE: fsck failed. Try running fsck without the -a option."
+       fi
+    else
+       # If the remount to read-only mode didn't work abort the fsck and print
+       # an error.
+       echo "Cannot check root file system because it could not be mounted"
+       echo "in read-only mode."
+       FSCK_RETURN_CODE=$EXIT_CODE_FAILURE
+    fi
+fi
+
+exit ${FSCK_RETURN_CODE}
diff --git a/stage1/bootscripts/cleanfs b/stage1/bootscripts/cleanfs
new file mode 100755 (executable)
index 0000000..4be2a54
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# cleanfs
+# Clean file system
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+clean_files()
+{
+    failed=0
+
+    cd /tmp &&
+    find . -xdev -mindepth 1 ! -name lost+found ! -name trash -delete || failed=1
+
+    cd /var/lock &&
+    find . -type f ! -newer /proc -exec rm -f {} \; || failed=1
+
+    cd /var/run &&
+    find . ! -type d ! -name utmp ! -newer /proc -exec rm -f {} \; || failed=1
+    > /var/run/utmp
+    if grep -q '^utmp:' /etc/group ; then
+       chmod 664 /var/run/utmp
+       chgrp utmp /var/run/utmp
+    fi
+
+    return ${failed}
+}
+
+# Function to create files/directory on boot.
+create_files()
+{
+    failed=0
+
+    # Read in the configuration file.
+    exec 9>&0 < /etc/sysconfig/createfiles
+    while read name type perm usr grp dtype maj min junk; do
+        # Ignore comments and blank lines.
+               case "${name}" in
+           ""|\#*) continue ;;
+       esac
+
+        # Ignore existing files.
+       if [ ! -e "${name}" ]; then
+           # Create stuff based on its type.
+           case "${type}" in
+               dir)
+                   mkdir "${name}"
+                   ;;
+               file)
+                   :> "${name}"
+                   ;;
+               dev)
+                   case "${dtype}" in
+                       char)
+                           mknod "${name}" c ${maj} ${min}
+                           ;;
+                       block)
+                           mknod "${name}" b ${maj} ${min}
+                           ;;
+                       pipe)
+                           mknod "${name}" p
+                           ;;
+                       *) 
+                           echo  "Unknown device type: ${dtype}"
+                           failed=${EXIT_CODE_WARNING}
+                           ;;
+                   esac
+                   ;;
+               *)
+                   echo "Unknown type: ${type}"
+                   failed=${EXIT_CODE_WARNING}
+                   continue
+                   ;;
+           esac
+
+            # Set up the permissions, too.
+           chown ${usr}:${grp} "${name}"
+           chmod ${perm} "${name}"
+       fi
+    done
+    exec 0>&9 9>&-
+
+    return ${failed}
+}
+
+case "${1}" in
+    start)
+       cmd_run_log_box "Cleaning file systems" clean_files
+
+       if [ -e /etc/sysconfig/createfiles ]; then
+           if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
+               cmd_run_log_box_warn "Creating files and directories" create_files
+           fi
+       fi
+        ;;
+    *)
+        echo "Usage: $0 {start}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/functions b/stage1/bootscripts/functions
new file mode 100644 (file)
index 0000000..f0eef13
--- /dev/null
@@ -0,0 +1,519 @@
+#!/bin/sh
+
+# General shell functions
+
+# Return codes definitions
+EXIT_CODE_SUCCESS=0
+EXIT_CODE_FAILURE=1
+EXIT_CODE_WARNING=2
+
+# Setup default values for environment
+umask 022
+export PATH="/tools/bin:/tools/sbin:/bin:/sbin"
+
+## Screen Dimensions
+# Find current screen size
+if [ -z "${COLUMNS}" ]; then
+    COLUMNS=$(stty size)
+    COLUMNS=${COLUMNS##* }
+fi
+
+# When using remote connections, such as a serial port, stty size returns 0
+if [ "${COLUMNS}" = "0" ]; then 
+    COLUMNS=80
+fi
+
+# The starting position for displaying the "X" sign inside the check box [ ]
+CHECK_POSITION=2
+SET_CHECK_POSITION="echo -en \\033[${CHECK_POSITION}G"
+
+# NORMAL prints text in normal color
+NORMAL="\\033[0;39m"
+# SUCCESS prints text in a green colour
+SUCCESS="echo -en \\033[1;32m"
+# WARNING prints text in a yellow colour
+WARNING="echo -en \\033[1;33m"
+# FAILURE prints text in a red colour
+FAILURE="echo -en \\033[1;31m"
+# Brackets are blue
+BRACKET="\\033[1;34m"
+
+# Set the console_loglevel to display only error messages (0,1,2 and 3)
+#   KERN_EMERG   "<0>" /* system is unusable                   */
+#   KERN_ALERT   "<1>" /* action must be taken immediately     */
+#   KERN_CRIT    "<2>" /* critical conditions                  */
+#   KERN_ERR     "<3>" /* error conditions                     */
+#   KERN_WARNING "<4>" /* warning conditions                   */
+#   KERN_NOTICE  "<5>" /* normal but significant condition     */
+#   KERN_INFO    "<6>" /* informational                        */
+#   KERN_DEBUG   "<7>" /* debug-level messages                 */
+# Examples:
+#   LOGLEVEL="1" --> Prevents all messages, expect panic messages, from
+#                    appearing on the console.
+#   LOGLEVEL="8" --> Allow all messages to appear on the console.
+LOGLEVEL="4"
+
+# Timezone
+export TZ="America/Montreal"
+
+INIT_LOG_PATH="/var/log/hvinit"
+INIT_LOG_FILE="$INIT_LOG_PATH/init.log"
+
+# Arguments: Message string(s) to display
+display_checkbox_msg()
+{
+    local LABEL="${*}"
+
+    echo -en "${BRACKET}[ ${BRACKET}]${NORMAL} ${LABEL} "
+}
+
+# The print_status prints a coloured "X" letter inside the checkbox to the left
+# of the screen (the checkbox is displayed with the cmd_run_log_box function).
+print_status()
+{
+    if [ ${#} = 0 ]; then
+        # If no parameters are given, print usage information.
+       echo "Usage: print_status {success|warning|failure}"
+       return ${EXIT_CODE_FAILURE}
+    fi
+    
+    case "$1" in
+       success)
+           ${SUCCESS}
+           ;;
+       warning)
+           ${WARNING}
+           ;;
+       failure)
+           ${FAILURE}
+           ;;
+       *)
+           echo "Usage: print_status {success|warning|failure}"
+           return ${EXIT_CODE_FAILURE}
+           ;;
+    esac
+    echo -n "X"
+    echo -en "${NORMAL}"
+    echo
+}
+
+# Argument #1: message d'erreur
+boot_failure()
+{
+    $FAILURE
+    echo
+    echo $1
+    echo
+    echo "sulogin will now be started. When you logout, the system"
+    echo "will reboot."
+    echo
+    echo -en "${NORMAL}"
+    /sbin/sulogin
+    /sbin/reboot -f
+}
+
+# Write a message to the log file.
+msg_log()
+{
+    echo "<$*>" >> ${INIT_LOG_FILE}
+    return ${EXIT_CODE_SUCCESS}
+}
+
+# Display a message with an orange warning box [X]
+msg_box_nolog()
+{
+    STRING=$1
+    display_checkbox_msg "${STRING}"
+    ${SET_CHECK_POSITION}
+    print_status warning
+}
+
+# Write the command and it's arguments to the log file, without running the command.
+log_script_name()
+{
+    echo ">>> Script: $* <<<" >> ${INIT_LOG_FILE}
+    return ${EXIT_CODE_SUCCESS}
+}
+
+# Write the command and it's arguments to the log file, and run the command.
+cmd_run_log()
+{
+    echo "[$*]" >> ${INIT_LOG_FILE}
+    ${*} 1>> ${INIT_LOG_FILE} 2>&1
+    return ${?}
+}
+
+# Display the action name, run a command, log its output and display it's
+# status
+# First argument: action name (string)
+# Remaining arguments: command name with it's options
+cmd_run_log_box()
+{
+    STRING=$1
+    display_checkbox_msg "${STRING}"
+    shift
+    ${SET_CHECK_POSITION}
+    $* 1>> ${INIT_LOG_FILE} 2>&1
+    ERROR_CODE=${?}
+    if [ $ERROR_CODE = 0 ]; then
+       print_status success
+    else
+       print_status failure
+    fi
+
+    return $ERROR_CODE
+}
+
+# Display the action name, run a command, log its output and display it's
+# status
+# First argument: action name (string)
+# Remaining arguments: command name with it's options
+#    Error codes returned by the command:
+#       0 = success
+#       1 = warning
+#       2 = failure
+cmd_run_log_box_warn()
+{
+    STRING=$1
+    display_checkbox_msg "${STRING}"
+    shift
+    ${SET_CHECK_POSITION}
+    $* 1>> ${INIT_LOG_FILE} 2>&1
+    ERROR_CODE=${?}
+    if [ $ERROR_CODE = ${EXIT_CODE_SUCCESS} ]; then
+       print_status success
+    elif [ $ERROR_CODE = ${EXIT_CODE_WARNING} ]; then
+       print_status warning
+    else
+       print_status failure
+    fi
+
+    return $ERROR_CODE
+}
+
+
+# Display the action name, run a command, log its output and display it's
+# status
+# If something went wrong during the checks of one of the partitions,
+# fsck will exit with a return value greater than 1
+# First argument: action name (string)
+# Remaining arguments: command name with it's options
+#    Error codes returned by the command:
+#       0  = success
+#       1  = warning
+#       >1 = failure
+cmd_run_log_box_warn_checkfs()
+{
+    STRING=$1
+    display_checkbox_msg "${STRING}"
+    shift
+    ${SET_CHECK_POSITION}
+    $* 1>> ${INIT_LOG_FILE} 2>&1
+    ERROR_CODE=${?}
+    if [ $ERROR_CODE = ${EXIT_CODE_SUCCESS} ]; then
+       print_status success
+    elif [ $ERROR_CODE = 1 ]; then
+       print_status warning
+        ERROR_CODE=${EXIT_CODE_WARNING}
+    else
+       print_status failure
+        ERROR_CODE=${EXIT_CODE_FAILURE}
+    fi
+
+    return $ERROR_CODE
+}
+
+
+# Display the action name, run a command and display it's status (no log).
+# First argument: action name (string)
+# Remaining arguments: command name with it's options
+cmd_run_nolog_box()
+{
+    STRING=$1
+    display_checkbox_msg "${STRING}"
+    shift
+    ${SET_CHECK_POSITION}
+    $* 1>> /dev/null 2>&1
+    ERROR_CODE=${?}
+    if [ $ERROR_CODE = 0 ]; then
+       print_status success
+    else
+       print_status failure
+    fi
+
+    return $ERROR_CODE
+}
+
+# loadproc() starts a process (often a daemon) with proper error checking
+loadproc()
+{
+    # If no parameters are given, print usage information.
+    if [ ${#} = 0 ]; then
+       msg_log "Usage: loadproc {program}"
+       return ${EXIT_CODE_FAILURE}
+    fi
+
+    # Find the basename of the first parameter (the daemon's name without the
+    # path that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after
+    # basename ran).
+    base=$(/usr/bin/basename ${1})
+
+    # the pidlist variable will contain the output of the pidof command. pidof
+    # will try to find the PID's that belong to a certain string; $base in
+    # this case.
+    pidlist=$(pidof -o $$ -o $PPID -o %PPID -x ${base})
+    pid=""
+    for apid in ${pidlist}; do
+       if [ -d /proc/${apid} ]; then
+           pid="${pid} ${apid}"
+       fi
+    done
+    
+    # If the $pid variable contains anything (from the previous for loop) it
+    # means the daemon is already running.
+    if [ ! -n "${pid}" ]; then
+       # Empty $pid variable means it's not running, so we run "$@" (all
+        # parameters given to this function from the script) and then check
+       # the return value.
+       "$@"
+
+       if [ ${?} -ne 0 ]; then
+           return ${EXIT_CODE_FAILURE}
+       else
+           return ${EXIT_CODE_SUCCESS}
+       fi
+    else
+       # The variable $pid was not empty, meaning it was already running.
+       msg_log "Already running"
+       return ${EXIT_CODE_WARNING}
+    fi
+}
+
+# killproc() kills a process with proper error checking
+# Arg. #1: Name of process to kill
+# Arg. #2: Optional signal to kill the process with (like -HUP, -TERM, -KILL, etc)
+killproc()
+{
+    # If no parameters are given, print usage information.
+    if [ $# -lt 1 ]; then
+       msg_log "Usage: killproc {program} [signal]"
+       return ${EXIT_CODE_FAILURE}
+    fi
+
+    killproc_path ${1} /var/run ${2}
+    
+    return ${?}
+}
+
+# killproc_path() kills a process with proper error checking
+# Arg. #1: Name of process to kill
+# Arg. #2: Base directory containing PID file
+# Arg. #3: Optional signal to kill the process with (like -HUP, -TERM, -KILL, etc)
+killproc_path()
+{
+    # If no parameters are given, print usage information.
+    if [ $# -lt 2 ]; then
+       msg_log "Usage: killproc_path {program} {pid-directory} [signal]"
+       return ${EXIT_CODE_FAILURE}
+    fi
+    
+    # Find the basename of the first parameter (the daemon's name without the
+    # path).
+    base=$(/usr/bin/basename ${1})
+
+    piddir=${2}
+
+    # Check if we gave a signal to kill the process with (like -HUP, -TERM,
+    # -KILL, etc) to this function (the third parameter).
+    if [ "${3}" != "" ]; then
+       killlevel=-${3}
+    else
+       nolevel=1
+    fi
+    
+    # The pidlist variable will contains the output of the pidof command. pidof
+    # will try to find the PID's that belong to a certain string; $base in this
+    # case.
+    pidlist=$(pidof -o $$ -o $PPID -o %PPID -x ${base})
+    pid=""
+    for apid in ${pidlist}
+      do
+      if [ -d /proc/${apid} ]; then
+         pid="${pid} ${apid}"
+      fi
+    done
+    
+    # If $pid contains something from the previous for loop it means one or
+    # more PID's were found that belongs to the processes to be killed.
+    if [ -n "${pid}" ]; then
+       # If no kill level was specified we'll try -TERM first and then sleep
+        # for 2 seconds to allow the kill to be completed.
+       if [ "${nolevel}" = 1 ]; then
+           cmd_run_log kill -TERM ${pid}
+
+           # If after -TERM the PID still exists we'll wait 2 seconds before
+           # trying to kill it with -KILL. If the PID still exist after that,
+           # wait two more seconds. If the PIDs still exist by then it's safe
+           # to assume that we cannot kill these PIDs.
+           if /bin/ps h ${pid} >/dev/null 2>&1; then
+               cmd_run_log sleep 2
+               if /bin/ps h ${pid} > /dev/null 2>&1; then
+                   cmd_run_log kill -KILL ${pid}
+                   if /bin/ps h ${pid} > /dev/null 2>&1; then
+                       cmd_run_log sleep 2
+                   fi
+               fi
+           fi
+           /bin/ps h ${pid} >/dev/null 2>&1
+           if [ ${?} = 0 ]; then
+               # If after the -KILL it still exists it can't be killed for
+               # some reason.
+               return ${EXIT_CODE_FAILURE}
+           else
+               # It was killed, remove possible stale PID file in ${piddir}.
+               /bin/rm -f ${piddir}/${base}.pid
+               return ${EXIT_CODE_SUCCESS}
+           fi
+       else
+           # A kill level was provided. Kill with the provided kill level and
+           # wait for 2 seconds to allow the kill to be completed.
+           /bin/kill ${killlevel} ${pid}
+           if /bin/ps h ${pid} > /dev/null 2>&1; then
+               cmd_run_log sleep 2
+           fi
+           /bin/ps h ${pid} >/dev/null 2>&1
+           if [ ${?} = 0 ]; then
+               # If ps' return value is 0 it means it ran ok which indicates
+               # that the PID still exists. This means the process wasn't
+               # killed properly with the signal provided.
+               return ${EXIT_CODE_FAILURE}
+           else
+               # If the return value was 1 or higher it means the PID didn't
+               # exist anymore which means it was killed successfully. Remove
+               # possible stale PID file.
+               /bin/rm -f ${piddir}/${base}.pid
+               return ${EXIT_CODE_SUCCESS}
+           fi
+       fi
+    else
+       # The PID didn't exist so we can't attempt to kill it.
+       msg_log "Not running"
+        return ${EXIT_CODE_WARNING}
+    fi
+}
+
+# reloadproc() sends a signal to a daemon telling it to reload it's
+# configuration file. This is almost identical to the killproc function with
+# the exception that it won't try to kill it with a -KILL signal (aka -9).
+# Arg. #1: Name of process to reload
+# Arg. #2: Optional signal to reload the process with (like -HUP)
+reloadproc()
+{
+    # If no parameters are given, print usage information.
+    if [ ${#} = 0 ]; then
+       msg_log "Usage: reloadproc {program} [signal]"
+       return ${EXIT_CODE_FAILURE}
+    fi
+    
+    # Find the basename of the first parameter (the daemon's name without
+    # the path that was provided so /usr/sbin/syslogd becomes plain 'syslogd'
+    # after basename ran).
+    base=$(/usr/bin/basename ${1})
+
+    # Check if we gave a signal to send to the process (like -HUP) to this
+    # function (the second parameter). If no second parameter was provided set
+    # the nolevel variable. Else set the killlevel variable to the value of $2
+    # (the second parameter).
+    if [ -n "${2}" ]; then
+       killlevel="-${2}"
+    else
+       killlevel="-SIGHUP"
+    fi
+    
+    # The pidlist variable will contains the output of the pidof command. pidof
+    # will try to find the PID's that belong to a certain string; $base in this
+    # case.
+    pidlist=$(pidof -o $$ -o $PPID -o %PPID -x ${base})
+    pid=""
+    for apid in ${pidlist}
+      do
+      if [ -d /proc/${apid} ]; then
+         pid="${pid} ${apid}"
+      fi
+    done
+    
+    # If $pid contains something from the previous for loop it means one or
+    # more PID's were found that belongs to the processes to be reloaded.
+    if [ -n "${pid}" ]; then
+       /bin/kill ${killlevel} ${pid}
+
+       if [ ${?} -ne 0 ]; then
+           sleep 2
+           if statusproc ${base} | grep "not running" 1> /dev/null 2>&1; then
+               return ${EXIT_CODE_FAILURE}
+           fi
+       fi
+    else
+       # If $pid is empty no PID's have been found that belong to the process.
+       msg_log "Not running"
+        return ${EXIT_CODE_WARNING}
+    fi
+    
+    return ${EXIT_CODE_SUCCESS}
+}
+
+
+# statusproc_path() will try to find out if a process is running or not.
+# Arg. #1: Name of process to check
+statusproc()
+{
+    # If no parameters are given, print usage information.
+    if [ $# -lt 1 ]; then
+       msg_log "Usage: statusproc {program}"
+       return ${EXIT_CODE_FAILURE}
+    fi
+
+    statusproc_path ${1} /var/run
+    
+    return ${?}
+}
+
+
+# statusproc_path() will try to find out if a process is running or not.
+# Arg. #1: Name of process to check
+# Arg. #2: Base directory containing PID file
+statusproc_path()
+{
+    # If no parameters are given, print usage information.
+    if [ $# -lt 2 ]; then
+       msg_log "Usage: status {program} {pid-directory}"
+       return ${EXIT_CODE_FAILURE}
+    fi
+    
+    # Find the basename of the first parameter (the daemon's name without the
+    # path).
+    base=$(/usr/bin/basename ${1})
+
+    piddir=${2}
+
+    # $pid will contain a list of PID's that belong to a process.
+    pid=$(pidof -o $$ -o $PPID -o %PPID -x ${base})
+    if [ -n "${pid}" ]; then
+       # If $pid contains something, the process is running, print the content
+       # of the $pid variable.
+       echo "${base} running with Process ID ${pid}"
+       return ${EXIT_CODE_SUCCESS}
+    fi
+
+    # If $pid doesn't contain it check if a PID file exists and inform the
+    # user about this stale file.
+    if [ -f ${piddir}/${base}.pid ]; then
+       pid=$(head -1 ${piddir}/${base}.pid)
+       if [ -n "${pid}" ]; then
+           echo "${base} not running but ${piddir}/${base}.pid exists"
+           return ${EXIT_CODE_FAILURE}
+       fi
+    else
+       echo "${base} is not running"
+    fi
+}
diff --git a/stage1/bootscripts/halt b/stage1/bootscripts/halt
new file mode 100755 (executable)
index 0000000..575d648
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# halt
+
+#
+# Call halt. See man halt for the meaning of the parameters
+#
+/sbin/halt -d -f -i -p
+
+exit $?
diff --git a/stage1/bootscripts/hostname b/stage1/bootscripts/hostname
new file mode 100755 (executable)
index 0000000..84b1d34
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# description: Set hostname at boot time.
+#              Even if network connection is not desired,
+#              some programs like emacs delay their startup
+#              by a few seconds if no hostname is set.
+#
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+# See how we were called.
+case "$1" in
+    start)
+       cmd_run_log_box "Setting hostname" hostname $(cat /etc/hostname)
+        ;;
+
+    stop)
+       ;;
+    
+    *)
+        echo $"Usage: $0 {start|stop}"
+       exit ${EXIT_CODE_FAILURE}
+esac
+
+exit $?
diff --git a/stage1/bootscripts/initlog b/stage1/bootscripts/initlog
new file mode 100755 (executable)
index 0000000..d9ba2b1
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# initlog
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+case "$1" in
+    start)
+       # Initialization of the log file for the INIT process
+       if [ ! -d ${INIT_LOG_PATH} ]; then
+           boot_failure "Missing ${INIT_LOG_PATH} directory."
+       fi
+       
+       mount -t tmpfs -o size=256k,nr_inodes=10,mode=0755 tmpfs ${INIT_LOG_PATH} &&
+        touch ${INIT_LOG_FILE}
+       ;;
+    
+    stop)
+        umount ${INIT_LOG_PATH}
+       ;;
+    
+    restart)
+       $0 stop
+       sleep 1
+       $0 start
+       ;;
+    
+    *)
+       echo "Usage: $0 {start|stop|restart}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/modules b/stage1/bootscripts/modules
new file mode 100755 (executable)
index 0000000..df5f195
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+# modules
+# Module auto-loading script
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+# Assure that the kernel has module support.
+if [ ! -e /proc/ksyms -a ! -e /proc/modules ]; then
+    exit 0
+fi
+
+modules_start()
+{
+    # Exit if there's no modules file
+    if [ ! -r /etc/sysconfig/modules ]; then
+        return 0
+    fi
+
+    echo "Loading modules:"
+
+    # Only try to load modules if the user has actually given us
+    # some modules to load.
+    while read module args; do
+       # Ignore comments and blank lines.
+       case "$module" in
+           ""|"#"*) continue ;;
+       esac
+       
+       # Attempt to load the module, making
+       # sure to pass any arguments provided.
+       modprobe ${module} ${args} >/dev/null
+       
+       # Print the module name if successful,
+       # otherwise take note.
+       if [ $? -eq 0 ]; then
+           echo " ${module}"
+       else
+           failedmod="${failedmod} ${module}"
+       fi
+    done < /etc/sysconfig/modules
+    
+    # Print a failure message with a list of any
+    # modules that may have failed to load.
+    if [ -n "${failedmod}" ]; then
+        ${FAILURE}
+       echo "Failed to load modules:${failedmod}"
+    fi
+}
+
+# See how we were called
+case "$1" in
+    start)
+       cmd_run_log_box_warn "Loading modules" modules_start
+       ;;
+    
+    *)
+       echo "Usage: $0 {start}"
+       exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/mountfs b/stage1/bootscripts/mountfs
new file mode 100755 (executable)
index 0000000..15cde93
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# mountfs
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+case "$1" in
+    start)
+       # Remount the root partition in read-write mode.
+       cmd_run_log_box "Remounting root file system Read/Write" \
+           mount -o remount,rw /
+
+        # Remove the possible /fastboot and /forcefsck files. they are only
+        # supposed to be used during the next reboot's checkfs which just
+        # happened. If you want to fastboot or forcefsck again you'll have to
+        # recreate the files
+        rm -f /fastboot /forcefsck
+
+        # Walk through /etc/fstab and mount all file systems that don't have
+       # the noauto option set in the fs_mntops field (the 4th field. See man
+       # fstab for more info).
+       cmd_run_log_box "Mounting other file systems" mount -a -O no_netdev
+        ;;
+
+    stop)
+        # Unmount all the file systems, mounting the root file system
+        # read-only (all are unmounted but because root can't be unmounted
+        # at this point mount will automatically mount it read-only which
+        # is what is supposed to happen. This way no data can be written
+       # anymore to disk).
+       cmd_run_nolog_box "Unmounting file systems" umount -a -d -r -v -t notmpfs,noproc
+        if [ $? -ne 0 ]; then
+            exit ${EXIT_CODE_WARNING}
+        fi
+        ;;
+    
+    *)
+        echo "Usage: $0 {start|stop}"
+        exit ${EXIT_CODE_FAILURE}
+        ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/mountkernfs b/stage1/bootscripts/mountkernfs
new file mode 100755 (executable)
index 0000000..9c3fed5
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# mountkernfs
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+case "$1" in
+    start)
+       # The "-n: option tells mount not to write to the /etc/mtab
+       # file (because /etc/mtab is a symbolic link to /proc/mounts,
+       # which we are in the process of mounting).
+       cmd_run_log_box "Mounting /proc file system" mount -n proc
+       cmd_run_log_box "Mounting /sys file system" mount sys
+       ;;
+
+    stop)
+       umount -n proc
+        ;;
+
+    *)
+        echo "Usage: $0 {start|stop}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/rc b/stage1/bootscripts/rc
new file mode 100755 (executable)
index 0000000..9e4087d
--- /dev/null
@@ -0,0 +1,150 @@
+#!/bin/sh
+
+# rc
+
+# By Jason Pearce  - jason.pearce@linux.org
+# Modified by Gerard Beekmans - gerard@linuxfromscratch.org
+# print_error_msg based on ideas by Simon Perreault -
+# nomis80@videotron.ca
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+# If you uncomment the debug variable below none of the scripts will be
+# executed, just the script name and parameters will be echo'ed to the
+# screen so you can see how the scripts are called by rc.
+#debug="echo"
+
+# If the return value of the scripts executed in each runlevel (start or stop)
+# is not 0 (success) or 1 (warning), something went wrong with error checking
+# inside the script. The print_error_msg function will be called and the
+# message plus the return value of the K script will be printed to the screen.
+
+# Prints an error message when an unforeseen error occurred that wasn't
+# trapped for some reason by error checking.
+print_error_msg()
+{
+    ${FAILURE}
+    echo "   Error in subscript \"${1}\" (${2})"
+    echo -en "${NORMAL}"
+    echo "   Press a key to continue..."
+    read
+}
+
+# Start script or program.
+startup()
+{
+    ${debug} "$@"
+}
+
+check_script_status()
+{
+    if [ ! -f $1 ]; then
+       echo "$1 is not a valid symlink"
+       return ${EXIT_CODE_FAILURE}
+    fi
+    
+    if [ ! -x $1 ]; then
+       echo "$1 is not executable, skipping"
+       return ${EXIT_CODE_FAILURE}
+    fi
+    
+    return ${EXIT_CODE_SUCCESS}
+}
+
+# Configure for displaying only relevant messages to console
+/bin/dmesg -n ${LOGLEVEL}
+
+# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
+trap ":" INT QUIT TSTP
+
+runlevel=${1}
+
+# If no runlevel was passed as an argument, we won't change runlevels.
+if [ "${runlevel}" = "" ]; then
+    echo "Usage: ${0} <runlevel>" >&2
+    exit ${EXIT_CODE_FAILURE}
+fi
+
+# PREVLEVEL is set by init
+# If PREVLEVEL is not set it means that there is no previous runlevel and
+# we'll set previous to N.
+previous=${PREVLEVEL}
+if [ "${previous}" = "" ]; then
+    previous="N"
+fi
+
+# Is there an rc directory for the new runlevel?
+if [ ! -d /etc/rc.d/rc${runlevel}.d ]; then
+    echo "/etc/rc.d/rc${runlevel}.d directory does not exist"
+    exit ${EXIT_CODE_FAILURE}
+fi
+
+# First, attempt to stop all services started by previous runlevel,
+# and killed in this runlevel (K8 scripts
+# If so, first collect all the K* scripts in the new run level.
+if [ ${previous} != N ]; then
+    for kill_script in $(ls /etc/rc.d/rc${runlevel}.d/K* 2> /dev/null); do
+       if [ -f ${kill_script} ]; then
+           # "suffix" will contain the script name without the leading Kxx.
+           suffix="${kill_script##*/K[0-9][0-9]}"
+           
+           # If there is a S script in the previous runlevel corresponding
+           # to this K script, determine what it's full path is.
+           previous_start="/etc/rc.d/rc${previous}.d/S[0-9][0-9]${suffix}"
+
+           # If no start script was found in the previous run level it could
+           # be that something was started in rcsysinit.d (sysinit level) so we'll
+           # determine the path for that possibility as well.
+           sysinit_start="/etc/rc.d/rcsysinit.d/S[0-9][0-9]${suffix}"
+
+           # Stop the service if there is a start script in the previous run
+           # level or in the sysinit level. Otherwise, don't execute this K
+           # script because the service is not active.
+           if [ -f ${previous_start} -o -f ${sysinit_start} ]; then
+               startup ${kill_script} stop
+               retval=${?}
+               if [ ${retval} -ne ${EXIT_CODE_SUCCESS} -a ${retval} -ne ${EXIT_CODE_WARNING} ]; then
+                   print_error_msg ${kill_script} ${retval}
+               fi
+           fi
+       fi
+    done
+fi
+
+# Now run the START scripts for this runlevel.
+for start_script in $(ls /etc/rc.d/rc${runlevel}.d/S* 2> /dev/null); do
+    # "suffix" will contain the script name without the leading Sxx.
+    suffix=${start_script#/etc/rc.d/rc${runlevel}.d/S[0-9][0-9]}
+
+    # If there is a K script in the current runlevel corresponding
+    # to this S script, determine what it's full path is.
+    current_stop=/etc/rc.d/rc${runlevel}.d/K[0-9][0-9]${suffix}
+
+    if [ ${previous} != "N" ]; then
+       # If there is a S script in the previous runlevel corresponding
+       # to this S script, determine what it's full path is.
+       previous_start=/etc/rc.d/rc${previous}.d/S[0-9][0-9]${suffix}
+    else
+       previous_start=""
+    fi
+
+    if [ -f "$previous_start" -a ! -f "$current_stop" ]; then
+       # If the service was started in the previous level and was not stopped
+       # in this runlevel, then we don't have to re-start it.
+       continue
+    else
+       # If the service was not started in the previous level, or if we just
+       # stopped it in this runlevel, then we need to start or restart it.
+       check_script_status ${start_script}
+       if [ ${?} = ${EXIT_CODE_SUCCESS} ]; then
+           startup ${start_script} start
+           retval=${?}
+           if [ ${retval} -ne ${EXIT_CODE_SUCCESS} -a ${retval} -ne ${EXIT_CODE_WARNING} ]; then
+               print_error_msg ${start_script} ${retval}
+           fi
+       fi
+    fi
+done
+
+exit ${EXIT_CODE_SUCCESS}
diff --git a/stage1/bootscripts/reboot b/stage1/bootscripts/reboot
new file mode 100755 (executable)
index 0000000..2f6c3e5
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# reboot
+
+# Call reboot. See man halt for the meaning of the parameters
+echo "System reboot in progress..."
+
+/sbin/reboot -d -f -i
+
+exit $?
diff --git a/stage1/bootscripts/sendsignals b/stage1/bootscripts/sendsignals
new file mode 100755 (executable)
index 0000000..6bde3e3
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# sendsignals
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+# Send all the remaining processes the TERM signal
+cmd_run_log_box "Sending all processes the TERM signal" /sbin/killall5 -15
+
+# Send all the remaining process (after sending them the TERM signal before)
+# the KILL signal.
+cmd_run_log_box "Sending all processes the KILL signal" /sbin/killall5 -9
+
+exit $?
diff --git a/stage1/bootscripts/setclock b/stage1/bootscripts/setclock
new file mode 100755 (executable)
index 0000000..2a00c66
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# setclock
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+# Load clock parameters
+source /etc/sysconfig/clock
+
+case "$UTC" in
+    yes|true|1)
+       TIME_BASE="--utc"
+       ;;
+    no|false|0)
+       TIME_BASE="--localtime"
+       ;;
+    *)
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+# See how we were called
+case "$1" in
+    start)
+       cmd_run_log_box "Setting system time from hardware clock value" \
+           /sbin/hwclock --hctosys "$TIME_BASE"
+       ;;
+    stop)
+       cmd_run_log_box "Saving system time value in hardware clock" \
+           /sbin/hwclock --systohc "$TIME_BASE"
+       ;;
+    *)
+       echo "Usage: $0 {start|stop}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/swap b/stage1/bootscripts/swap
new file mode 100755 (executable)
index 0000000..083b980
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# swap
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+case "$1" in
+    start)
+       cmd_run_log_box "Enabling swap partition" swapon -a
+       ;;
+    
+    stop)
+       cmd_run_log_box "Disabling swap partition" swapoff -a
+       ;;
+    
+    restart)
+       $0 stop
+       sleep 1
+       $0 start
+       ;;
+    
+    status)
+       swapon -s
+       ;;
+    
+    *)
+       echo "Usage: $0 {start|stop|restart|status}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
diff --git a/stage1/bootscripts/udev b/stage1/bootscripts/udev
new file mode 100644 (file)
index 0000000..c29fbd0
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# udev
+# Udev cold-plugging script
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+udev_coldplug()
+{
+    # Unlikely, but we may be faster than the first event
+    mkdir -p /dev/.udev/queue &&
+
+    # Configure all devices
+    /sbin/udevadm trigger &&
+
+    # Now wait for udevd to process the uevents we triggered
+    /sbin/udevadm settle
+}
+
+udev_start()
+{
+    echo "" > /sys/kernel/uevent_helper &&
+
+    # Start the udev daemon to continually watch for, and act on uevents
+    /sbin/udevd --daemon
+}
+
+# See how we were called
+case "$1" in
+    start)
+        if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
+           boot_failure "FAILURE: Unable to create devices without a SysFS filesystem."
+        fi
+
+        # Mount a temporary file system over /dev, so that any devices
+        # made or removed during this boot don't affect the next one.
+        # The reason we don't write to mtab is because we don't ever
+        # want /dev to be unavailable (such as by `umount -a').
+       cmd_run_log_box "Mounting /dev in tmpfs" mount -n -t tmpfs -o mode=0755 udev /dev
+
+       cmd_run_log_box "Copying static /dev entries" cp --preserve=all --recursive --remove-destination /lib/udev/devices/* /dev
+
+       cmd_run_log_box "Setting permissons on /dev/shm" chmod 1777 /dev/shm
+
+       cmd_run_log_box_warn "Starting udevd" udev_start
+
+       cmd_run_log_box "Performing Coldplugging" udev_coldplug
+       ;;
+    
+    *)
+       echo "Usage: $0 {start}"
+       exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
index 9d7a283..bf6a869 100755 (executable)
@@ -1,4 +1,6 @@
 #!/bin/sh
+set -o errexit
+
 # First argument of this script is the package name.
 # Remaining arguments are additional configure options.
 
@@ -12,14 +14,8 @@ source ../functions
 source ../packages-list
 
 # Applying patches (if any)
-apply_patches ${PACKAGE} &&
+apply_patches ${PACKAGE}
 
-cd ${LFS_TMP}/${PACKAGE}-build &&
-../${PACKAGE}/configure \
-    --prefix=/tools \
-    ${CONFIGURE_OPTS} &&
-make &&
-make install
+${SCRDIR}/cis-common ${PACKAGE} ${CONFIGURE_OPTS}
 
-# Return last error
 exit $?
index a8a4edb..4aa5816 100755 (executable)
@@ -1,4 +1,12 @@
 #!/bin/sh
+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 ../sysinfos
@@ -6,15 +14,33 @@ source ../functions
 source ../packages-list
 
 # Applying patches (if any)
-apply_patches ${1} &&
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+# When Bash is cross-compiled, it cannot test for the presence of named pipes,
+# among other things. If you used su to become an unprivileged user, this
+# combination will cause Bash to build without process substitution, which
+# will break one of the C++ test scripts in eglibc. The following prevents
+# future problems by skipping the check for named pipes, as well as other tests
+# that can not run while cross-compiling or that do not run properly:
+cat > config.cache << "EOF"
+ac_cv_func_mmap_fixed_mapped=yes
+ac_cv_func_strcoll_works=yes
+ac_cv_func_working_mktime=yes
+bash_cv_func_sigsetjmp=present
+bash_cv_getcwd_malloc=yes
+bash_cv_job_control_missing=present
+bash_cv_printf_a_format=yes
+bash_cv_sys_named_pipes=present
+bash_cv_ulimit_maxfds=yes
+bash_cv_under_sys_siglist=yes
+bash_cv_unusable_rtsigs=no
+gt_cv_int_divbyzero_sigfpe=yes
+EOF
+
+${SCRDIR}/cis-common ${PACKAGE} "${CONFIGURE_OPTS} --without-bash-malloc --cache-file=config.cache"
 
-cd ${LFS_TMP}/${1}-build &&
-../${1}/configure \
-    --prefix=/tools \
-    --without-bash-malloc &&
-make -j ${MAKEJOBS} &&
-make install &&
-ln -sf bash /tools/bin/sh
+ln -svfT bash /tools/bin/sh
 
-# Return last error
 exit $?
diff --git a/stage1/cis-binutils b/stage1/cis-binutils
new file mode 100755 (executable)
index 0000000..904dcb0
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${1}
+
+case "${HVL_TARGET}" in
+    "x86_64")
+        # This adds 64 bit support to Binutils.
+       TARGET_CONFIGURE_OPTS="--enable-64-bit-bfd"
+       ;;
+esac
+
+# --prefix=/tools
+#     This tells the configure script to prepare to install the package in the /tools directory.
+# --host=${CLFS_HOST}
+# --target=${CLFS_TARGET}
+#     Creates a cross-architecture executable that creates files for ${CLFS_TARGET} but runs on ${CLFS_HOST}.
+# --with-lib-path=/tools/lib
+#     Specify the library search path during the compilation of Binutils, resulting in /tools/lib
+#     being passed to the linker. This prevents the linker from searching through library directories on the host.
+# --disable-nls
+#     This disables internationalization as i18n is not needed for the cross-compile tools.
+# --enable-shared
+#     Enable the creation of the shared libraries.
+# --disable-multilib
+#     This option disables the building of a multilib capable Binutils.
+# --enable-64-bit-bfd
+#     This adds 64 bit support to Binutils.
+cd ${LFS_TMP}/${1}-build
+CC="${CC} ${CLFS_BUILDFLAGS}" \
+    ../${1}/configure \
+    --prefix=/tools \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    --target=${CLFS_TARGET} \
+    --with-lib-path=/tools/lib \
+    --disable-nls \
+    --enable-shared \
+    --disable-multilib \
+    ${TARGET_CONFIGURE_OPTS}
+${HVMAKE} configure-host
+${HVMAKE}
+${HVMAKE} install
+
+exit $?
diff --git a/stage1/cis-bootscripts b/stage1/cis-bootscripts
new file mode 100755 (executable)
index 0000000..ac17b28
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# Clock settings
+cat > ${LFS}/etc/sysconfig/clock << "EOF"
+UTC=1
+EOF
+
+# Copying boot scripts
+STAGE1_BOOTSCRIPTS="checkfs cleanfs functions halt hostname initlog modules mountfs \
+    mountkernfs rc reboot sendsignals setclock swap udev"
+mkdir -p ${LFS}/etc/rc.d/init.d
+for bootscript in ${STAGE1_BOOTSCRIPTS}; do
+    install -m755 bootscripts/${bootscript} ${LFS}/etc/rc.d/init.d
+done
+
+# Creating runlevels links
+for level in sysinit 0 1 2 3 4 5 6; do
+    dir=${LFS}/etc/rc.d/rc${level}.d
+    if [ -d ${dir} ]; then
+        # Removing old links
+        rm -f ${dir}/*
+    else
+        # Creating basic directory structure
+        mkdir -v -p ${dir}
+    fi
+done
+
+# rcsysinit.d
+bootscript_add_rcsysinit initlog     05 00
+bootscript_add_rcsysinit hostname    10 00
+bootscript_add_rcsysinit mountkernfs 15 00
+bootscript_add_rcsysinit modules     20 00
+bootscript_add_rcsysinit udev        25 00
+bootscript_add_rcsysinit checkfs     30 00
+bootscript_add_rcsysinit mountfs     35 95
+bootscript_add_rcsysinit swap        40 94
+bootscript_add_rcsysinit cleanfs     45 00
+bootscript_add_rcsysinit setclock    60 92
+
+# rc0.d
+bootscript_add_manual 0 sendsignals 95 00
+bootscript_add_manual 0 halt        99 00
+
+# rc6.d is almost identical to rc0.d
+bootscript_add_manual 6 sendsignals 95 00
+bootscript_add_manual 6 reboot      99 00
+
+exit $?
index a5df099..5b36c8d 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/sh
+set -o errexit
 
 # Reading system configuration informations, functions and package versions.
 source ../sysinfos
@@ -6,12 +7,17 @@ source ../functions
 source ../packages-list
 
 # Applying patches (if any)
-apply_patches ${1} &&
+apply_patches ${1}
+
+cd ${LFS_TMP}/${1}
+
+# Bzip2's default Makefile target automatically runs the testsuite as well.
+# Disable the tests since they won't work on a multi-architecture build:
+cp -v Makefile{,.orig}
+sed -e 's@^\(all:.*\) test@\1@g' Makefile.orig > Makefile
 
 # This package doesn't have a configure script...
-cd ${LFS_TMP}/${1} &&
-make -j ${MAKEJOBS} &&
-make PREFIX=/tools install
+${HVMAKE} CC="${CC} ${CLFS_BUILDFLAGS}" AR="${AR}" RANLIB="${RANLIB}"
+${HVMAKE} PREFIX=/tools install
 
-# Return last error
 exit $?
diff --git a/stage1/cis-common b/stage1/cis-common
new file mode 100755 (executable)
index 0000000..be4e6ec
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+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
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+CC="${CC} ${CLFS_BUILDFLAGS}" CXX="${CXX} ${CLFS_BUILDFLAGS}" \
+    ../${PACKAGE}/configure \
+    --prefix=/tools \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    ${CONFIGURE_OPTS}
+${HVMAKE}
+${HVMAKE} install
+
+exit $?
diff --git a/stage1/cis-common2 b/stage1/cis-common2
new file mode 100755 (executable)
index 0000000..98b876f
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+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
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+CC="${CC} ${CLFS_BUILDFLAGS}" CXX="${CXX} ${CLFS_BUILDFLAGS}" \
+    ../${PACKAGE}/configure \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    ${CONFIGURE_OPTS}
+
+exit $?
diff --git a/stage1/cis-coreutils b/stage1/cis-coreutils
new file mode 100755 (executable)
index 0000000..67fc413
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+# Fix a bug with help2man???
+cd ${LFS_TMP}/${PACKAGE}
+touch man/hostname.1
+touch man/uname.1
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+# Configure can not properly determine how to get free space when
+# cross-compiling - as a result, the df program will not be built. Add the
+# following entries to config.cache  to correct this, and fix various
+# cross-compiling issues:
+cat > config.cache << EOF
+fu_cv_sys_stat_statfs2_bsize=yes
+gl_cv_func_rename_trailing_slash_bug=no
+gl_cv_func_working_mkstemp=yes
+EOF
+
+${SCRDIR}/cis-common ${PACKAGE} "${CONFIGURE_OPTS} --enable-install-program=hostname --cache-file=config.cache"
+
+exit $?
diff --git a/stage1/cis-e2fsprogs b/stage1/cis-e2fsprogs
new file mode 100755 (executable)
index 0000000..71985fa
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+CC="${CC} ${CLFS_BUILDFLAGS}" PKG_CONFIG=true \
+    ../${PACKAGE}/configure \
+    --prefix=/tools \
+    --enable-elf-shlibs \
+    --with-cc="${CC} ${CLFS_BUILDFLAGS}" \
+    --with-linker=${LD} \
+    --host=${CLFS_TARGET} \
+    --disable-libblkid \
+    --disable-libuuid \
+    --disable-fsck \
+    --disable-uuidd
+${HVMAKE} LIBUUID="-luuid" STATIC_LIBUUID="-luuid" \
+    LIBBLKID="-lblkid" STATIC_LIBBLKID="-lblkid"
+${HVMAKE} install
+# Install the static libraries and headers:
+${HVMAKE} install-libs
+
+# Create needed symlinks for a bootable system:
+LINKS="fsck.ext2 fsck.ext3 fsck.ext4 e2fsck"
+
+for link in ${LINKS}; do
+    ln -svfT /tools/sbin/${link} ${LFS}/sbin/${link}
+done
+
+exit $?
diff --git a/stage1/cis-findutils b/stage1/cis-findutils
new file mode 100755 (executable)
index 0000000..c3f887d
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+# The following cache entries set the values for tests that do not run while
+# cross-compiling:
+cat > config.cache << EOF
+gl_cv_func_wcwidth_works=yes
+ac_cv_func_fnmatch_gnu=yes
+EOF
+
+${SCRDIR}/cis-common ${PACKAGE} "${CONFIGURE_OPTS} --cache-file=config.cache"
+
+exit $?
diff --git a/stage1/cis-flex b/stage1/cis-flex
new file mode 100755 (executable)
index 0000000..f5be27f
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}
+
+# Make sure that Flex doesn't try to include headers from /usr/include.
+cp -v Makefile.in{,.orig}
+sed "s/-I@includedir@//g" Makefile.in.orig > Makefile.in
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+# When Cross Compiling the configure script does not determine the correct
+# values for the following, Set the values manually:
+cat > config.cache << EOF
+ac_cv_func_malloc_0_nonnull=yes
+ac_cv_func_realloc_0_nonnull=yes
+EOF
+
+${SCRDIR}/cis-common ${PACKAGE} "${CONFIGURE_OPTS} --cache-file=config.cache"
+
+exit $?
diff --git a/stage1/cis-gcc b/stage1/cis-gcc
new file mode 100755 (executable)
index 0000000..49c7e4e
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# Manually applying patches
+apply_patch ${1}-branch_update-1.patch ${1}
+
+case "${HVL_TARGET}" in
+    "x86")
+        apply_patch ${1}-specs-1.patch ${1}
+        ;;
+    "x86_64")
+        apply_patch ${1}-pure64_specs-1.patch ${1}
+       ;;
+esac
+
+cd ${LFS_TMP}/${1}
+
+# Change the StartFile Spec to point to the correct library location:
+echo -en '#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR "/tools/include/"\n\n' >> gcc/config/linux.h
+echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h
+echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h
+
+# Set the directory searched by the fixincludes process for system headers, so it won't look at the host's headers:
+cp -v gcc/Makefile.in{,.orig}
+sed -e 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \
+    gcc/Makefile.in.orig > gcc/Makefile.in
+
+# --with-local-prefix=/tools
+#     The purpose of this switch is to remove /usr/local/include from gcc's include search path.
+#     This is not absolutely essential, however, it helps to minimize the influence of the host system.
+# --disable-shared
+#     Disables the creation of the shared libraries.
+# --disable-threads
+#     This will prevent GCC from looking for the multi-thread include files, since they haven't been
+#     created for this architecture yet. GCC will be able to find the multi-thread information after
+#     the Glibc headers are created.
+# --enable-languages=c
+#     This option ensures that only the C compiler is built.
+cd ${LFS_TMP}/${1}-build
+CC="${CC} ${CLFS_BUILDFLAGS}" CXX="${CXX} ${CLFS_BUILDFLAGS}" \
+    ../${1}/configure \
+    --prefix=/tools \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    --target=${CLFS_TARGET} \
+    --disable-multilib \
+    --with-local-prefix=/tools \
+    --libexecdir=/tools/lib \
+    --disable-nls \
+    --disable-libstdcxx-pch \
+    --enable-long-long \
+    --enable-c99 \
+    --enable-shared \
+    --enable-threads=posix \
+    --enable-__cxa_atexit \
+    --enable-languages=c,c++
+# Prevent GCC from looking in the wrong directories for headers and libraries:
+cp Makefile{,.orig}
+sed "/^HOST_\(GMP\|PPL\|CLOOG\)\(LIBS\|INC\)/s:-[IL]/\(lib\|include\)::" \
+    Makefile.orig > Makefile
+${HVMAKE} AS_FOR_TARGET="${AS}" LD_FOR_TARGET="${LD}"
+${HVMAKE} install
+
+exit $?
index 9f7410d..f7ddee3 100755 (executable)
@@ -1,4 +1,12 @@
 #!/bin/sh
+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 ../sysinfos
@@ -6,15 +14,24 @@ source ../functions
 source ../packages-list
 
 # Applying patches (if any)
-apply_patches ${1} &&
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}/gettext-tools
+
+# When cross-compiling the Gettext configure script assumes we don't have a
+# working wcwidth when we do. The following will fix possible compilation
+# errors because of this assumption:
+echo "gl_cv_func_wcwidth_works=yes" > config.cache
 
-cd ${LFS_TMP}/${1}/gettext-tools &&
-./configure \
+CC="${CC} ${CLFS_BUILDFLAGS}" CXX="${CXX} ${CLFS_BUILDFLAGS}" \
+    ./configure \
     --prefix=/tools \
-    --disable-shared &&
-make -j ${MAKEJOBS} -C gnulib-lib &&
-make -j ${MAKEJOBS} -C src msgfmt &&
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    --disable-shared \
+    --cache-file=config.cache
+${HVMAKE} -C gnulib-lib
+${HVMAKE} -C src msgfmt
 cp -v src/msgfmt /tools/bin
 
-# Return last error
 exit $?
diff --git a/stage1/cis-m4 b/stage1/cis-m4
new file mode 100755 (executable)
index 0000000..6e364e7
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+#  Configure can not properly determine the results of the following tests:
+cat > config.cache << EOF
+gl_cv_func_btowc_eof=yes
+gl_cv_func_mbrtowc_incomplete_state=yes
+gl_cv_func_mbrtowc_sanitycheck=yes
+gl_cv_func_mbrtowc_null_arg=yes
+gl_cv_func_mbrtowc_retval=yes
+gl_cv_func_mbrtowc_nul_retval=yes
+gl_cv_func_wcrtomb_retval=yes
+gl_cv_func_wctob_works=yes
+EOF
+
+${SCRDIR}/cis-common ${PACKAGE} "${CONFIGURE_OPTS} --cache-file=config.cache"
+
+exit $?
diff --git a/stage1/cis-module-init-tools b/stage1/cis-module-init-tools
new file mode 100755 (executable)
index 0000000..b84c5fd
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+CC="${CC} ${CLFS_BUILDFLAGS}" ../${PACKAGE}/configure \
+    --prefix=/ \
+    --bindir=/bin \
+    --sbindir=/sbin \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET}
+make DOCBOOKTOMAN=""
+make DESTDIR=${LFS} install
+
+exit $?
diff --git a/stage1/cis-perl b/stage1/cis-perl
deleted file mode 100755 (executable)
index dc50712..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-PERL_VERSION=$(get_pkg_ver ${1})
-
-# Applying patches (if any)
-apply_patches ${1} &&
-
-cd ${LFS_TMP}/${1} &&
-./configure.gnu \
-  --prefix=/tools \
-    -Dstatic_ext='Data/Dumper Fcntl IO POSIX' &&
-make -j ${MAKEJOBS} perl utilities &&
-cp -v perl pod/pod2man /tools/bin &&
-mkdir -v -p /tools/lib/perl5/${PERL_VERSION} &&
-cp -v -R lib/* /tools/lib/perl5/${PERL_VERSION}
-
-# Return last error
-exit $?
diff --git a/stage1/cis-post-install b/stage1/cis-post-install
new file mode 100755 (executable)
index 0000000..b5bb52d
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# We need /dev/null and /dev/console before udev is started.
+mkdir -pv ${LFS}/dev
+
+if [ ! -c ${LFS}/dev/console ]; then
+    mknod -m 0600 ${LFS}/dev/console c 5 1
+fi
+
+if [ ! -c ${LFS}/dev/null ]; then
+    mknod -m 0666 ${LFS}/dev/null c 1 3
+fi
+
+# Static UDEV devices
+if [ ! -c ${LFS}/lib/udev/devices/null ]; then
+    mknod -m0666 ${LFS}/lib/udev/devices/null c 1 3
+fi
+
+if [ ! -c ${LFS}/lib/udev/devices/kmsg ]; then
+    mknod -m0666 ${LFS}/lib/udev/devices/kmsg c 1 11
+fi
+
+if [ ! -h ${LFS}/lib/udev/devices/fd ]; then
+    ln -sfv /proc/self/fd ${LFS}/lib/udev/devices/fd
+fi
+
+if [ ! -h ${LFS}/lib/udev/devices/stdin ]; then
+    ln -sfv /proc/self/fd/0 ${LFS}/lib/udev/devices/stdin
+fi
+
+if [ ! -h ${LFS}/lib/udev/devices/stdout ]; then
+    ln -sfv /proc/self/fd/1 ${LFS}/lib/udev/devices/stdout
+fi
+
+if [ ! -h ${LFS}/lib/udev/devices/stderr ]; then
+    ln -sfv /proc/self/fd/2 ${LFS}/lib/udev/devices/stderr
+fi
+
+if [ ! -h ${LFS}/lib/udev/devices/core ]; then
+    ln -sfv /proc/kcore ${LFS}/lib/udev/devices/core
+fi
+
+# Change the ownership for ${LFS} and its subdirectories
+chown -Rv root:root ${LFS}
+
+exit $?
diff --git a/stage1/cis-pre-install b/stage1/cis-pre-install
new file mode 100755 (executable)
index 0000000..21d7ebd
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# Making sure that this script was executed by the root user
+if [ "x${USER}" != "xroot" ]; then
+    echo "You must be the superuser to install hvlinux."
+    exit 1
+fi
+
+# Making sure that the LFS directory is accessible
+if [ ! -d ${LFS} ]; then
+    echo "LFS destination directory not found."
+    exit 1
+fi
+
+# Make lfs the owner in case the installation is restarted
+chown -Rv lfs:lfs ${LFS}
+
+exit $?
diff --git a/stage1/cis-stripping b/stage1/cis-stripping
deleted file mode 100755 (executable)
index 725ff33..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-strip --strip-debug    /tools/lib/*
-strip --strip-unneeded /tools/{bin,sbin}/*
-# Removing documentation
-rm -rf /tools/{doc,info,man}
-
-# Return success
-exit 0
diff --git a/stage1/cis-sysvinit b/stage1/cis-sysvinit
new file mode 100755 (executable)
index 0000000..6ca42b9
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}
+cp -v src/Makefile src/Makefile.orig
+sed -e 's@root@0@g' \
+    -e "s@/dev/initctl@${CLFS}&@g" \
+    -e 's@\(mknod \)-m \([0-9]* \)\(.* \)p@\1\3p; chmod \2\3@g' \
+    -e "s@/usr/lib@/tools/lib@" \
+    src/Makefile.orig > src/Makefile
+make -C src clobber
+make -C src CC="${CC} ${CLFS_BUILDFLAGS}"
+make -C src install INSTALL=install ROOT=${LFS}
+
+install -m644 ${SCRDIR}/misc/inittab ${LFS}/etc
+
+exit $?
diff --git a/stage1/cis-tar b/stage1/cis-tar
new file mode 100755 (executable)
index 0000000..7cf1879
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+# Configure can not properly determine the results of a few tests. Set them manually:
+cat > config.cache << EOF
+gl_cv_func_wcwidth_works=yes
+gl_cv_func_btowc_eof=yes
+ac_cv_func_malloc_0_nonnull=yes
+ac_cv_func_realloc_0_nonnull=yes
+gl_cv_func_mbrtowc_incomplete_state=yes
+gl_cv_func_mbrtowc_nul_retval=yes
+gl_cv_func_mbrtowc_null_arg=yes
+gl_cv_func_mbrtowc_retval=yes
+gl_cv_func_wcrtomb_retval=yes
+EOF
+
+${SCRDIR}/cis-common ${PACKAGE} "${CONFIGURE_OPTS} --cache-file=config.cache"
+
+exit $?
diff --git a/stage1/cis-texinfo b/stage1/cis-texinfo
new file mode 100755 (executable)
index 0000000..1e6fa90
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+
+CC="${CC} ${CLFS_BUILDFLAGS}" CXX="${CXX} ${CLFS_BUILDFLAGS}" \
+    ../${PACKAGE}/configure \
+    --prefix=/tools \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    ${CONFIGURE_OPTS}
+${HVMAKE} -C tools/gnulib/lib
+${HVMAKE} -C tools
+${HVMAKE}
+${HVMAKE} install
+
+exit $?
diff --git a/stage1/cis-toolchain-adjust b/stage1/cis-toolchain-adjust
deleted file mode 100755 (executable)
index 9e17879..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-cd ${LFS_TMP}
-
-# The linker, adjusted at the end of the first pass of Binutils, needs
-# to be renamed so that it can be properly found and used.
-if [ ! -f /tools/bin/ld-old -a -f /tools/bin/ld ]; then
-    mv -v /tools/bin/{ld,ld-old} || exit 1
-fi
-if [ ! -f /tools/$(gcc -dumpmachine)/bin/ld-old -a -f /tools/$(gcc -dumpmachine)/bin/ld ]; then
-    mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old} || exit 1
-fi
-rm -f /tools/$(gcc -dumpmachine)/bin/ld &&
-cp -v -a /tools/bin/{ld-new,ld} &&
-ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld &&
-
-# From this point onwards, everything will link only against the libraries
-# in /tools/lib.
-
-# Point GCC to the new dynamic linker.
-gcc -dumpspecs | sed 's@/lib/ld-linux.so.2@/tools&@g' \
-    > `dirname $(gcc -print-libgcc-file-name)`/specs &&
-
-# Removing the header files in GCC's private include directory:
-GCC_INCLUDEDIR=`dirname $(gcc -print-libgcc-file-name)`/include &&
-find ${GCC_INCLUDEDIR}/* -maxdepth 0 -xtype d -exec rm -rvf '{}' \; &&
-rm -vf `grep -l "DO NOT EDIT THIS FILE" ${GCC_INCLUDEDIR}/*` &&
-unset GCC_INCLUDEDIR &&
-
-gcc_toolchain_test_stage1
-
-# Return last error
-exit $?
diff --git a/stage1/cis-udev b/stage1/cis-udev
new file mode 100755 (executable)
index 0000000..d05e1b1
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+cd ${LFS_TMP}/${PACKAGE}
+
+install -dv ${LFS}/lib/{firmware,udev/devices/{pts,shm}}
+
+cd ${LFS_TMP}/${PACKAGE}-build
+CC="${CC} ${CLFS_BUILDFLAGS}" ../${PACKAGE}/configure \
+    --prefix=/usr \
+    --build=${CLFS_HOST} \
+    --host=${CLFS_TARGET} \
+    --exec-prefix="" \
+    --sysconfdir=/etc \
+    --libexecdir=/lib/udev \
+    --libdir=/usr/lib \
+    --disable-extras \
+    --disable-introspection
+make
+make DESTDIR=${LFS} install
+
+exit $?
diff --git a/stage1/cis-util-linux b/stage1/cis-util-linux
deleted file mode 100755 (executable)
index d3861dc..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-# Reading system configuration informations, functions and package versions.
-source ../sysinfos
-source ../functions
-source ../packages-list
-
-# Applying patches (if any)
-apply_patches ${1} &&
-
-cd ${LFS_TMP}/${1} &&
-sed -i 's@/usr/include@/tools/include@g' configure &&
-./configure &&
-make -j ${MAKEJOBS} -C lib &&
-make -j ${MAKEJOBS} -C mount mount umount &&
-make -j ${MAKEJOBS} -C text-utils more &&
-cp mount/{mount,umount} text-utils/more /tools/bin
-
-# Return last error
-exit $?
diff --git a/stage1/cis-util-linux-ng b/stage1/cis-util-linux-ng
new file mode 100755 (executable)
index 0000000..8d16906
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+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 ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${PACKAGE}
+
+${SCRDIR}/cis-common2 ${PACKAGE} "${CONFIGURE_OPTS} --enable-login-utils --disable-makeinstall-chown"
+cd ${LFS_TMP}/${PACKAGE}-build
+${HVMAKE}
+${HVMAKE} DESTDIR=${LFS} install
+
+# Copy Libraries and includes to /tools:
+rm -fv ${LFS}/usr/lib/lib{blkid,uuid}.la
+cp -v ${LFS}/usr/lib/lib{blkid,uuid}* /tools/lib
+cp -v ${LFS}/lib/lib{blkid,uuid}* /tools/lib
+ln -sfvT libblkid.so.1.1.0 /tools/lib/libblkid.so
+ln -sfvT libuuid.so.1.3.0 /tools/lib/libuuid.so
+install -dv /tools/include/{blkid,uuid}
+cp -av ${LFS}/usr/include/blkid/* /tools/include/blkid/
+cp -av ${LFS}/usr/include/uuid/* /tools/include/uuid/
+
+exit $?
diff --git a/stage1/cis-zlib b/stage1/cis-zlib
new file mode 100755 (executable)
index 0000000..f01fc25
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+set -o errexit
+
+# First argument of this script is the package name
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# Applying patches (if any)
+apply_patches ${1}
+
+cd ${LFS_TMP}/${1}
+CC="${CC} ${CLFS_BUILDFLAGS}" ./configure \
+    --prefix=/tools \
+    --shared
+${HVMAKE}
+
+# Installing the shared library
+${HVMAKE} install
+
+exit $?
diff --git a/stage1/create-config-files b/stage1/create-config-files
new file mode 100755 (executable)
index 0000000..ef723b5
--- /dev/null
@@ -0,0 +1,228 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+echo "Creating /etc/fstab"
+cat > ${LFS}/etc/fstab << "EOF"
+# Device       Mount point     FS-type   Options             Dump  Fsck-order
+# ----------------------------------------------------------------------------
+EOF
+
+if [ -n "${BOOT_PARTITION}" ]; then
+    echo "${BOOT_PARTITION} /boot ext2 defaults 1 1" >> ${LFS}/etc/fstab
+fi
+if [ -n "${SWAP_PARTITION}" ]; then
+    echo "${SWAP_PARTITION} none swap sw 0 0" >> ${LFS}/etc/fstab
+fi
+echo "${LFS_PARTITION}  /                 reiserfs defaults,noatime 0 0" >> ${LFS}/etc/fstab
+
+cat >> ${LFS}/etc/fstab << "EOF"
+/dev/cdrom        /media/cdrom      auto     ro,noauto,users  0 0
+/dev/dvd          /media/dvd        auto     ro,noauto,users  0 0
+proc              /proc             proc     defaults         0 0
+sysfs             /sys              sysfs    defaults         0 0
+devpts            /dev/pts          devpts   gid=4,mode=620   0 0
+shm               /dev/shm          tmpfs    defaults         0 0
+EOF
+
+echo "Creating basic /etc/profile"
+cat > ${LFS}/etc/profile << "EOF"
+#!/bin/sh
+# /etc/profile
+
+# System-wide environment and startup programs.
+# Functions and aliases go in /etc/bashrc.
+# This is the first file read by bash during the logon process.
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/tools/bin:/tools/sbin
+
+USER=`id -un`
+LOGNAME=$USER
+MAIL="/var/mail/$USER"
+HISTFILESIZE=1000
+HISTSIZE=1000
+HOSTNAME=`hostname`
+EDITOR=_DEFAULT_EDITOR_
+CFLAGS="-pipe -O2"
+CXXFLAGS=${CFLAGS}
+
+# Set default permissions when creating new files.
+if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
+    # Normal user
+    umask 002
+else
+    # Root
+    umask 022
+fi
+
+if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
+    export INPUTRC=/etc/inputrc
+fi
+
+# This disables generation of 'core' files when an application exit abnormally
+ulimit -c 0
+
+MANPATH=/usr/share/man:/usr/local/share/man
+
+LANG="en_US.UTF-8"
+
+# The sort order of ls output is affected by  the  locale  and
+# can  be  overridden  by the LC_COLLATE environment variable.
+# For example, if LC_COLLATE equals C, dot files appear first,
+# followed  by  names  beginning with upper-case letters, then
+# followed by names beginning with lower-case letters. But  if
+# LC_COLLATE equals en_US.ISO8859-1, then leading dots as well
+# as case are ignored in determining the sort order.
+LC_COLLATE=C
+################# LC_ALL=POSIX
+
+export PATH MANPATH LANG LC_COLLATE PS1 PS2 USER LOGNAME MAIL HISTFILESIZE HISTSIZE HOSTNAME EDITOR CFLAGS CXXFLAGS
+EOF
+
+sed -i -e "s!_DEFAULT_EDITOR_!${DEFAULT_EDITOR}!g" ${LFS}/etc/profile
+
+echo "Creating /etc/bashrc"
+cat > ${LFS}/etc/bashrc << "EOF"
+#!/bin/sh
+
+# /etc/bashrc
+
+# System wide functions and aliases
+# Environment stuff goes in /etc/profile
+
+alias rm='rm -i'
+alias mv='mv -i'
+alias cp='cp -i'
+alias df='df -h'
+alias du='du -h -s'
+# --show-control-chars is for seeing international characters in filenames
+alias ls='ls -h --color=auto --show-control-chars'
+eval $(dircolors --sh /etc/DIR_COLORS)
+
+# For some unknown reason bash refuses to inherit PS1 in some circumstances
+# that I can't figure out. Putting PS1 here ensures that it gets loaded every
+# time.
+# \h = Display hostname
+# \s = Display shell name (bash)
+# \v = Display shell version
+# \w = Display complete path
+# \W = Dispaly only current directory
+# \$ = Display '#'
+#PS1="\h(\W)\$"
+
+if [ "$TERM" = "linux" ]; then
+    #we're on the system console or maybe telnetting in
+    export PS1="\u(\W)\$"
+    #export PS1="\[\e[32;1m\]\u@\H > \[\e[0m\]"
+else
+    #we're not on the console, assume an xterm
+    #export PS1="\[\e]2;\u@\H   \w\a\e[32;1m\]>\[\e[0m\] "
+    export PS1="\[\e]2;[\u]   \w\a\e[32;1m\]>\[\e[0m\] "
+fi
+EOF
+
+echo "Installing /etc/DIR_COLORS"
+install -m644 ${SCRDIR}/misc/DIR_COLORS ${LFS}/etc/DIR_COLORS
+
+echo "Creating /etc/inputrc"
+cat > ${LFS}/etc/inputrc << "EOF"
+# Begin /etc/inputrc
+
+# Enable 8bit input
+set meta-flag On
+set input-meta On
+# Turns off 8th bit stripping
+set convert-meta Off
+# Keep the 8th bit for display
+set output-meta On
+
+# none, visible or audible
+set bell-style none
+
+# All of the following map the escape sequence of the value contained inside
+# the 1st argument to the readline specific functions
+"\eOd": backward-word
+"\eOc": forward-word
+# for linux console
+"\e[1~": beginning-of-line
+"\e[4~": end-of-line
+"\e[5~": beginning-of-history
+"\e[6~": end-of-history
+"\e[3~": delete-char
+"\e[2~": quoted-insert
+# for xterm
+"\eOH": beginning-of-line
+"\eOF": end-of-line
+EOF
+
+cat >> ${LFS}/etc/modules << "EOF"
+# /etc/modules: kernel modules to load at boot time.
+#
+# This file contains the names of kernel modules that should be loaded
+# at boot time, one per line. Lines beginning with "#" are ignored.
+EOF
+
+echo "Creating /etc/skel and it's files"
+cat > ${LFS}/etc/skel/.bash_logout << "EOF"
+# ~/.bash_logout
+
+clear
+EOF
+
+cat > ${LFS}/etc/skel/.bash_profile << "EOF"
+# ~/.bash_profile
+
+# User specific environment and startup programs
+# This file is the second read by bash during the logon process.
+
+# Get the aliases and functions
+if [ -f ~/.bashrc ]; then
+       . ~/.bashrc
+fi
+
+BASH_ENV=$HOME/.bashrc
+
+export BASH_ENV
+
+unset USERNAME
+EOF
+
+cat > ${LFS}/etc/skel/.bashrc << "EOF"
+# ~/.bashrc
+
+# User specific aliases and functions
+# This file is executed each time an xterm window
+# is started.
+
+# Source global definitions
+if [ -f /etc/bashrc ]; then
+       . /etc/bashrc
+fi
+
+EOF
+
+# Copy skeleton files to root user directory
+cp ${LFS}/etc/skel/.bash* ${LFS}/root
+
+echo "Creating /etc/shells"
+cat > ${LFS}/etc/shells << "EOF"
+/bin/sh
+/bin/bash
+EOF
+chmod 644 ${LFS}/etc/shells
+
+echo "Creating /etc/shutdown.allow"
+echo "${REGUSER}" > ${LFS}/etc/shutdown.allow
+
+# Hostname
+echo "${MACHINE_NAME}.${DOMAIN}" > ${LFS}/etc/hostname
+chmod 644 ${LFS}/etc/hostname
+
+echo "127.0.0.1 localhost ${MACHINE_NAME}" > ${LFS}/etc/hosts
+chmod 644 ${LFS}/etc/hosts
+
+exit $?
diff --git a/stage1/create-directories b/stage1/create-directories
new file mode 100755 (executable)
index 0000000..43dcb78
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+mkdir -pv ${LFS}/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
+mkdir -pv ${LFS}/{proc,media/{cdrom,dvd},sbin,srv,sys}
+mkdir -pv ${LFS}/var/{lock,log,mail,run,spool}
+
+mkdir -pv ${LFS}/var/{opt,cache,lib/{misc,locate},local}
+install -dv -m 0750 ${LFS}/root
+install -dv -m 1777 ${LFS}{/var,}/tmp
+
+mkdir -pv ${LFS}/usr/{,local/}{bin,include,lib,sbin,src}
+mkdir -pv ${LFS}/usr/{,local/}share/{doc,info,locale,man}
+mkdir -pv ${LFS}/usr/{,local/}share/{misc,terminfo,zoneinfo}
+mkdir -pv ${LFS}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
+for dir in ${LFS}/usr{,/local}; do
+  ln -sfv share/{man,doc,info} $dir
+done
+
+mkdir -pv ${LFS}/etc/{skel,sysconfig/network}
+mkdir -pv ${LFS}/usr/share/pixmaps
+mkdir -pv ${LFS}/usr/local/share/pixmaps
+
+# For alsa, nfs, milter-greylist and fcron?
+mkdir -pv ${LFS}/var/lock/subsys
+
+# Required only for hvlinux.
+mkdir -pv ${LFS}/var/log/hvinit
+install -dv -m 1777 ${LFS}/tmp/trash
+
+exit $?
diff --git a/stage1/create-groups b/stage1/create-groups
new file mode 100755 (executable)
index 0000000..e610968
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# In order for root to be able to login and for the name "root" to be
+# recognized, there need to be relevant entries in the /etc/group file.
+cat > ${LFS}/etc/group << "EOF"
+root:x:0:
+bin:x:1:
+sys:x:2:
+kmem:x:3:
+tty:x:4:
+tape:x:5:
+daemon:x:6:
+floppy:x:7:
+disk:x:8:
+lp:x:9:
+dialout:x:10:
+audio:x:11:
+video:x:12:
+utmp:x:13:
+usb:x:14:
+cdrom:x:15:
+# Used by MTAs (Mail Transport Agents)
+mail:x:30:mail
+# Default group used by some programs that do not require a group.
+nogroup:x:65533:
+# The default GID used by shadow for new users
+users:x:1000:
+EOF
+
+exit $?
diff --git a/stage1/create-logfiles b/stage1/create-logfiles
new file mode 100755 (executable)
index 0000000..4ab97e0
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+touch ${LFS}/var/run/utmp ${LFS}/var/log/{btmp,lastlog,wtmp}
+chmod -v 664  ${LFS}/var/run/utmp ${LFS}/var/log/lastlog
+chmod -v 600  ${LFS}/var/log/btmp
+
+exit $?
diff --git a/stage1/create-symlinks b/stage1/create-symlinks
new file mode 100755 (executable)
index 0000000..cc91b57
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# Some programs hard-wire paths to programs which don't exist yet. In order to
+# satisfy these programs, we create a number of symbolic links which will be
+# replaced by real files when we're installing all the software.
+
+# We must not use "-sf" to force the creation of a symlink, because we don't want
+# to write over a valid program if the install script needs to be re-started.
+
+source=/tools/bin
+target=${LFS}/bin
+for link in ${source}/{bash,cat,echo,grep,pwd,sleep,stty}; do
+    if [ ! -L ${target}/$(basename ${link}) ]; then
+        ln -sv ${link} ${target}
+    fi
+done
+
+source=/tools/bin
+target=${LFS}/usr/bin
+link=${source}/file
+if [ ! -L ${target}/$(basename ${link}) ]; then
+    ln -sv ${link} ${target}
+fi
+
+source=/tools/lib
+target=${LFS}/usr/lib
+for link in ${source}/libgcc_s.so{,.1} ${source}/libstd*so* ; do
+    if [ ! -L ${target}/$(basename ${link}) ]; then
+        ln -sv ${link} ${target}
+    fi
+done
+
+if [ ! -L ${LFS}/bin/sh ]; then
+    ln -sv bash ${LFS}/bin/sh
+fi
+
+# /etc/mtab can be either a regular file updated by mount/umount, or a symlink
+# to /proc/mounts.
+#
+# With linux < 2.6.26, /proc/mounts lacks information present in /etc/mtab such
+# as additional mount options.  Thus a symlink breaks things like discquotas
+# which rely on parsing the additional mount options.  As a result, we are
+# mostly all still using it as a plain file.
+#
+# With linux >= 2.6.26, /proc/mounts contains all of the information in
+# /etc/mtab, plus more.  The mount system call can now pass all of the mount
+# options to the kernel, so no information is missing in /proc/mounts.  This
+# has obviously useful benefits such as read-only root, and the state in
+# /etc/mtab never gets out of sync with reality (there are a number of open
+# bugs against mount where this occurs).
+ln -svfT /proc/mounts ${LFS}/etc/mtab
+
+exit $?
diff --git a/stage1/create-users b/stage1/create-users
new file mode 100755 (executable)
index 0000000..c02da2d
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+# In order for root to be able to login and for the name "root" to be
+# recognized, there need to be relevant entries in the /etc/passwd file.
+cat > ${LFS}/etc/passwd << "EOF"
+root::0:0:root:/root:/bin/bash
+bin:x:1:1:bin:/dev/null:/bin/false
+nobody:x:99:99:Unprivileged user:/dev/null:/bin/false
+EOF
+
+exit $?
index d2a720d..169d678 100755 (executable)
@@ -7,45 +7,79 @@ source ../sysinfos
 source ../functions
 source ../packages-list
 
-export LFS_PKG_DIR="$(dirname $(dirname $(pwd)))/packages/stage1"
+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
 
-export CFLAGS="-pipe -march=${MACHINE_ARCHITECTURE} -O2"
-export CXXFLAGS=${CFLAGS}
-
-ipkg_ac        ${GMP} "--enable-cxx --enable-mpbsd ABI=32"
-ipkg_ac        ${MPFR} "--enable-shared"
-
-ipkg_mult      ${BINUTILS} cis-binutils-pass1 "${BINUTILS}-pass1"
-ipkg_mult      ${GCC_CORE} cis-gcc-pass1 "${GCC_CORE}-pass1"
-ipkg           ${KERNEL} cis-linux-api-headers
-ipkg           ${GLIBC} cis-glibc
-run_script_log "Toolchain-adjust-stage1" cis-toolchain-adjust
-ipkg_mult      ${GCC_CORE} cis-gcc-pass2 "${GCC_CORE}-pass2"
-ipkg_mult      ${BINUTILS} cis-binutils-pass2 "${BINUTILS}-pass2"
-ipkg_ac        ${NCURSES} "--with-shared --without-debug --without-ada --enable-overwrite"
-ipkg           ${BASH} cis-bash
-ipkg           ${BZIP2} cis-bzip2
-ipkg_ac        ${COREUTILS}
-ipkg_ac        ${DIFFUTILS}
-ipkg_ac        ${FINDUTILS}
-ipkg_ac        ${GAWK}
-ipkg           ${GETTEXT} cis-gettext
-ipkg_ac        ${GREP} "--disable-perl-regexp"
-ipkg_ac        ${GZIP}
-ipkg_ac        ${MAKE_PACKAGE}
-ipkg_ac        ${PATCH_PACKAGE}
-ipkg           ${PERL} cis-perl
-ipkg_ac        ${SED}
-ipkg_ac        ${TAR_PACKAGE}
-ipkg_ac        ${TEXINFO}
-ipkg           ${UTIL_LINUX} cis-util-linux
-run_script_log "Stripping" cis-stripping
-
-echo "Total build time: $(get_total_build_time ${LFS_LOG_FILE})h"
+# Building temporary system
+export CC="${CLFS_TARGET}-gcc"
+export CXX="${CLFS_TARGET}-g++"
+export AR="${CLFS_TARGET}-ar"
+export AS="${CLFS_TARGET}-as"
+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_ac   ${GMP} "--enable-cxx"
+ipkg_ac   ${MPFR} "--enable-shared"
+ipkg_ac   ${PPL} "\
+    --enable-shared \
+    --enable-interfaces=c,cxx \
+    --disable-optimization \
+    --with-libgmp-prefix=/tools \
+    --with-libgmpxx-prefix=/tools"
+ipkg_ac   ${CLOOG_PPL} "\
+    --enable-shared \
+    --with-bits=gmp \
+    --with-gmp=/tools \
+    --with-ppl=/tools"
+ipkg_cust ${ZLIB} cis-zlib
+ipkg_cust ${BINUTILS} cis-binutils
+ipkg_cust ${GCC_CORE} cis-gcc
+ipkg_ac   ${NCURSES} "--with-shared --without-debug --without-ada --enable-overwrite --with-build-cc=gcc"
+ipkg_cust ${BASH} cis-bash
+ipkg_ac   ${BISON}
+ipkg_cust ${BZIP2} cis-bzip2
+ipkg_cust ${COREUTILS} cis-coreutils
+ipkg_ac   ${DIFFUTILS}
+ipkg_cust ${FINDUTILS} cis-findutils
+ipkg_ac   ${FILE_PKG}
+ipkg_cust ${FLEX} cis-flex
+ipkg_ac   ${GAWK} "--disable-libsigsegv"
+ipkg_cust ${GETTEXT} cis-gettext
+ipkg_ac   ${GREP} "--disable-perl-regexp --without-included-regex"
+ipkg_ac   ${GZIP}
+ipkg_cust ${MFOUR} cis-m4
+ipkg_ac   ${MAKE_PACKAGE}
+ipkg_ac   ${PATCH_PACKAGE}
+ipkg_ac   ${SED}
+ipkg_cust ${TAR_PACKAGE} cis-tar
+ipkg_cust ${TEXINFO} cis-texinfo
+ipkg_ac   ${XZ_UTILS}
+
+# Chapter 7
+rscr once "Creating directory structure" create-directories
+rscr once "Creating symbolic links" create-symlinks
+
+ipkg_ac   ${NANO} --enable-color --enable-multibuffer
+ipkg_cust ${UTIL_LINUX_NG} cis-util-linux-ng
+ipkg_cust ${E2FSPROGS} cis-e2fsprogs
+ipkg_cust ${SYSVINIT} cis-sysvinit
+ipkg_cust ${MODULE_INIT_TOOLS} cis-module-init-tools
+ipkg_cust ${UDEV} cis-udev
+
+rscr once "Creating default users" create-users
+rscr once "Creating default groups" create-groups
+rscr once "Creating default log files" create-logfiles
+rscr once "Installing kernel sources" install-linux-minimal
+rscr once "Creating default config files" create-config-files
+rscr once "Installing bootscripts" cis-bootscripts
 
 exit $?
diff --git a/stage1/install-linux-minimal b/stage1/install-linux-minimal
new file mode 100755 (executable)
index 0000000..f79d126
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+set -o errexit
+
+# Reading system configuration informations, functions and package versions.
+source ../sysinfos
+source ../functions
+source ../packages-list
+
+PACKAGE=${KERNEL}
+
+# Move kernel source files to their final destination
+mkdir -pv ${LFS}/usr/src
+decompress_package ${PACKAGE} ${LFS}/usr/src
+
+cd ${LFS}/usr/src/${PACKAGE}
+${HVMAKE} mrproper
+
+# Install HV kernel compilation script:
+VERSION=$(get_pkg_ver ${PACKAGE})
+SCRIPT=${LFS}/usr/src/compile-kernel-minimal
+
+echo "#!/bin/sh" > ${SCRIPT}
+echo "KERNEL_VERSION=${VERSION}" >> ${SCRIPT}
+echo "KERNEL_NAME=clfs-\${KERNEL_VERSION}" >> ${SCRIPT}
+echo "DEST=${LFS}/boot" >> ${SCRIPT}
+echo "PATH=\${PATH}:${LFS}/cross-tools/bin" >> ${SCRIPT}
+echo "" >> ${SCRIPT}
+
+echo "make ARCH=${HVL_TARGET} CROSS_COMPILE=${CLFS_TARGET}- menuconfig &&" >> ${SCRIPT}
+
+# Compile the kernel image:
+echo "make ARCH=${HVL_TARGET} CROSS_COMPILE=${CLFS_TARGET}- &&" >> ${SCRIPT}
+
+# Install the kernel:
+echo "cp -v arch/${HVL_TARGET}/boot/bzImage \${DEST}/vmlinuz-\${KERNEL_NAME} &&" >> ${SCRIPT}
+
+# Install map file:
+echo "cp -v System.map \${DEST}/System.map-\${KERNEL_NAME} &&" >> ${SCRIPT}
+
+# Install config file:
+echo "cp -v .config \${DEST}/config-\${KERNEL_NAME}" >> ${SCRIPT}
+
+cat >> ${SCRIPT} << "EOF"
+
+if [ $? -ne 0 ]; then
+    echo "*** Kernel compilation error ***."
+    exit 1
+fi
+
+exit 0
+EOF
+
+chmod -v u+x ${SCRIPT}
+
+exit $?
diff --git a/stage1/misc/DIR_COLORS b/stage1/misc/DIR_COLORS
new file mode 100644 (file)
index 0000000..fc21bf9
--- /dev/null
@@ -0,0 +1,75 @@
+# Configuration file for the color ls utility
+# This file goes in the /etc directory, and must be world readable.
+# You can copy this file to .dir_colors in your $HOME directory to override
+# the system defaults.
+
+# COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
+# pipes. 'all' adds color characters to all output. 'none' shuts colorization
+# off.
+COLOR tty
+
+# Below, there should be one TERM entry for each termtype that is colorizable
+TERM linux
+TERM console
+TERM con132x25
+TERM con132x30
+TERM con132x43
+TERM con132x60
+TERM con80x25
+TERM con80x28
+TERM con80x30
+TERM con80x43
+TERM con80x50
+TERM con80x60
+TERM xterm
+TERM vt100
+
+# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
+EIGHTBIT 1
+
+# Below are the color init strings for the basic file types. A color init
+# string consists of one or more of the following numeric codes:
+# Attribute codes: 
+# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
+# Text color codes:
+# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
+# Background color codes:
+# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
+NORMAL 00      # global default, although everything should be something.
+FILE 01        # normal file
+DIR 01;34      # directory
+LINK 01;36     # symbolic link
+FIFO 40;33     # pipe
+SOCK 01;35     # socket
+BLK 00;37;01   # block device driver
+CHR 00;31;01   # character device driver
+ORPHAN 01;05;37;41  # orphaned syminks
+MISSING 01;05;37;41 # ... and the files they point to
+
+# This is for files with execute permission:
+EXEC 01;32;01 
+
+# List any file extensions like '.gz' or '.tar' that you would like ls
+# to colorize below. Put the extension, a space, and the color init string.
+# (and any comments you want to add after a '#')
+.cmd 01;32 # executables (bright green)
+.exe 01;32
+.com 01;32
+.btm 01;32
+.bat 01;32
+.tar 01;31 # archives or compressed (bright red)
+.tgz 01;31
+.bz2 01;31
+.arj 01;31
+.taz 01;31
+.lzh 01;31
+.zip 01;31
+.z   01;31
+.Z   01;31
+.gz  01;31
+.jpg 01;35 # image formats
+.gif 01;35;47
+.bmp 01;35
+.xbm 01;35
+.xpm 01;35
+.patch 04;31
diff --git a/stage1/misc/inittab b/stage1/misc/inittab
new file mode 100644 (file)
index 0000000..09fe5ae
--- /dev/null
@@ -0,0 +1,59 @@
+# /etc/inittab
+#
+# SysVinit
+
+# Each non-comment line is a data record entry with the following format:
+# <id>:<runlevels>:<action>:<process>
+#
+# id:        Unique sequence of 1-4 characters identifying an entry in inittab
+# runlevels: lists the runlevels for which the specified action should be taken
+# action:    describes which action should be taken
+# process:   specifies the process to be executed
+
+# Default runlevel
+id:3:initdefault: 
+
+# System initialization before anything else (runs when system boots).
+si::sysinit:/etc/rc.d/init.d/rc sysinit
+
+# System halting
+l0:0:wait:/etc/rc.d/init.d/rc 0
+
+# Single-user mode
+l1:1:wait:/etc/rc.d/init.d/rc 1
+
+# Not used  
+l2:2:wait:/etc/rc.d/init.d/rc 2
+
+# Full multi-user mode
+l3:3:wait:/etc/rc.d/init.d/rc 3
+
+# Not used
+l4:4:wait:/etc/rc.d/init.d/rc 4
+
+# Full multi-user mode (X-windows)
+l5:5:wait:/etc/rc.d/init.d/rc 5
+
+# System reboot
+l6:6:wait:/etc/rc.d/init.d/rc 6
+
+# Trap CTRL-ALT-DELETE
+ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
+
+su:S016:once:/sbin/sulogin
+
+# getty-programs for the normal runlevels
+# 'getty' opens a tty port, prompts for a login name and invokes the
+# /bin/login command.
+# The <id> field MUST be the same as the last
+# characters of the device (after "tty").
+1:12345:respawn:/sbin/agetty 38400 tty1
+2:2345:respawn:/sbin/agetty 38400 tty2
+3:2345:respawn:/sbin/agetty 38400 tty3
+4:2345:respawn:/sbin/agetty 38400 tty4
+5:2345:respawn:/sbin/agetty 38400 tty5
+6:2345:respawn:/sbin/agetty 38400 tty6
+
+# Run xdm or kdm in runlevel 5
+# kdm or xdm is now a separate service
+x:5:respawn:/usr/X11R6/bin/xdm -nodaemon
index e85c558..7ca40cd 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 
 LFS_STAGE="stage1"
-USE_LFS_PATCHES=1
-USE_BLFS_PATCHES=1
+USE_CLFS_PATCHES=1
 USE_HV_PATCHES=1
 
 # Reading system configuration informations, functions and package versions.
@@ -13,28 +12,44 @@ source ../packages-list
 
 update_packages_init
 
-# Begin
+# These packages are already downloaded for stage0:
+lpkg     0 ${GMP}
+lpkg     0 ${MPFR}
+lpkg     0 ${PPL}
+lpkg     0 ${CLOOG_PPL}
+lpkg     0 ${BINUTILS}
+lpkg     0 ${GCC_CORE}
+lpkg     0 ${NCURSES}
+lpkg     0 ${FILE_PKG}
+lpkg     0 ${KERNEL}
 
-fpkg_gnu   ${BINUTILS}
-fpkg       ${GCC_CORE} ${GNU_URL}/gcc/${GCC_CORE}
-fpkg       ${KERNEL} http://www.kernel.org/pub/linux/kernel/v2.6
-fpkg_gnu   ${GLIBC}
-fpkg_gnu   ${NCURSES}
+# New packages for stage 1:
+fpkg       ${ZLIB} "http://www.zlib.net"
 fpkg_gnu   ${BASH}
-fpkg       ${BZIP2} http://www.bzip.org/$(get_pkg_ver ${BZIP2})
+fpkg_gnu   ${BISON}
+fpkg       ${BZIP2} "http://www.bzip.org/$(get_pkg_ver ${BZIP2})"
 fpkg_gnu   ${COREUTILS}
-fpkg_gnu   ${DIFFUTILS}
+fpkg       ${DIFFUTILS} "ftp://alpha.gnu.org/gnu/diffutils"
 fpkg_gnu   ${FINDUTILS}
+fpkg_sf    ${FLEX}
 fpkg_gnu   ${GAWK}
 fpkg_gnu   ${GETTEXT}
 fpkg_gnu   ${GREP}
 fpkg_gnu   ${GZIP}
+fpkg_gnu   ${MFOUR}
 fpkg_gnu   ${MAKE_PACKAGE}
 fpkg_gnu   ${PATCH_PACKAGE}
 fpkg_gnu   ${SED}
 fpkg_gnu   ${TAR_PACKAGE}
 fpkg_gnu   ${TEXINFO}
-fpkg       ${UTIL_LINUX} http://www.kernel.org/pub/linux/utils/util-linux
+fpkg_gnu   ${NANO}
+fpkg       ${XZ_UTILS} "http://tukaani.org/xz"
+
+# Chapter 7
+fpkg       ${UTIL_LINUX_NG} "http://www.kernel.org/pub/linux/utils/util-linux-ng/v$(get_pkg_ver_base ${UTIL_LINUX_NG})"
+fpkg_sf    ${E2FSPROGS}
+fpkg       ${SYSVINIT} "ftp://ftp.cistron.nl/pub/people/miquels/sysvinit"
+fpkg       ${MODULE_INIT_TOOLS} "http://www.kernel.org/pub/linux/utils/kernel/module-init-tools"
+fpkg       ${UDEV} "http://www.kernel.org/pub/linux/utils/kernel/hotplug"
 
-# Return last error
 exit $?
index 9a700ca..6efcf2e 100755 (executable)
@@ -1,70 +1,33 @@
 #!/bin/sh
 
+LFS_STAGE=stage1
+
 # Reading system configuration informations, functions and package versions.
 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_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"
 
-# Making sure that this script was executed by the root user
-if [ "x${USER}" != "xroot" ]; then
-    echo "You must be the superuser to install hvlinux."
-    exit 1
-fi
-
-# Making sure that the LFS partition is mounted
-if ! mount | awk '{ print "x" $3 "x" }' | grep "x${LFS}x" 1> /dev/null 2>&1; then
-    echo "LFS partition is not mounted. Please mount it."
-    exit 1
-fi
-
-# Creating basic directories
-for subdir in tmp var boot tools; do
-    dir=${LFS}/${subdir}
-    if [ ! -d ${dir} ]; then
-        install -dv ${dir} || exit 1
-    fi
-    chown lfs:lfs ${dir} || exit 1
-done
-
-# Creating a link from the host root directory to LFS tools directory
-ln -sf ${LFS}/tools / &&
-
-# Testing for the presence of the lfs user
-# We cannot 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
-    # 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 || exit 1
-fi &&
+init_log_file
 
-cat > /home/lfs/.bashrc << "EOF" &&
-# Setting up the environment
-set +h
-umask 022
-CC="gcc -s"
-LC_ALL=POSIX
-PATH=/tools/bin:/bin:/usr/bin
-export CC LC_ALL PATH
-EOF
-
-chown lfs:lfs /home/lfs/.bashrc &&
+rscr mult "Performing pre-install" cis-pre-install
 
 # Logging-in as 'lfs' user, and executing the install-1 script. The
 # 'su -' command starts with a clean environment and enters the home
 # directory of the user.
-su - lfs -c "cd ${PWD}; ./install-1"
+su - lfs -c "cd ${PWD}; ./install-1" &&
+
+rscr mult "Performing post-install" cis-post-install
 
 if [ $? -ne 0 ]; then
-    echo "*** An error occured during stage1"
+    echo "*** An error occured during ${LFS_STAGE}"
     exit 1
 fi
 
+echo "Total build time: $(get_total_build_time ${LFS_LOG_FILE})h"
+
 exit 0