-Added code to write and detect if we are running under the HOST (stages 0 and 1...
authorgobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Sat, 12 Mar 2011 21:29:26 +0000 (21:29 +0000)
committergobo72 <gobo72@364a67c3-989e-7be9-548d-dae8560ea662>
Sat, 12 Mar 2011 21:29:26 +0000 (21:29 +0000)
Makefile
functions/main
functions/version [new file with mode: 0644]
stage0/create-version [new file with mode: 0644]
stage0/hv-install-1
stage1/pkg/patch [new file with mode: 0644]

index e80efe6..2b3202b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,16 +9,27 @@
 
 .PHONY: get test
 
-all: get
+RUN_MODE := $(shell . functions/version && check_hvlinux_version)
 
-# Fetch packages from network
-get:
-       @for k in $$(seq 0 5); do \
-         make -C stage$${k} $(MAKECMDGOALS); \
-        done
+ifeq ($(RUN_MODE),HOST)
+  STAGES := "0 1"
+else ifeq ($(RUN_MODE),NATIVE)
+  STAGES := "2 3 4 5"
+else
+  $(error Unable to determine run mode.)
+endif
 
-# Test integrity of packages
-test:
-       @for k in $$(seq 0 6); do \
+ifeq ($(MAKECMDGOALS),get)
+  STAGES := $(shell seq 0 5)
+endif
+ifeq ($(MAKECMDGOALS),test)
+  STAGES := $(shell seq 0 5)
+endif
+
+all:
+       @echo "Stages: $(STAGES)"
+       @for k in $(STAGES); do \
          make -C stage$${k} $(MAKECMDGOALS); \
         done
+
+$(MAKECMDGOALS): all
index c0ab98e..76aa3a0 100644 (file)
@@ -50,6 +50,7 @@ source ./stage.def
 # Load functions
 source ../functions/fpkg
 source ../functions/lpkg
+source ../functions/version
 
 # Constants for return codes
 EXIT_SUCCESS=0
@@ -119,7 +120,7 @@ if [ -z "${LFS_STAGE}" ]; then
     return ${EXIT_FAILURE}
 fi
 
-if [ "x${LFS_STAGE}" != "xstage0" -a "x${LFS_STAGE}" != "xstage1" ] ;then
+if [ "x${LFS_STAGE}" != "xstage0" -a "x${LFS_STAGE}" != "xstage1" ]then
     LFS=""
 fi
 
@@ -941,11 +942,16 @@ rscr()
        exit ${EXIT_FAILURE}
     fi
 
-    # Checking if script is valid and executable
-    if [ ! -x ${SCRDIR}/${SCRIPT} ]; then
+    # Checking if script file is found
+    if [ ! -f ${SCRDIR}/${SCRIPT} ]; then
        echo "${FUNCNAME}(): script not found: ${SCRIPT}"
        exit ${EXIT_FAILURE}
     fi
+    # ... and make sure it is executable
+    if [ ! -x ${SCRDIR}/${SCRIPT} ]; then
+       echo "${FUNCNAME}(): execute bit not set: ${SCRIPT}"
+       exit ${EXIT_FAILURE}
+    fi
 
     PACKAGE_LOG=${LFS_LOG_DIR}/${HVLABEL}.log
 
diff --git a/functions/version b/functions/version
new file mode 100644 (file)
index 0000000..4a96731
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Running this script as 'sh' for Make
+
+CFG_DIR="config"
+HV_VER_FILE="hvlinux-version"
+
+check_hvlinux_version()
+{
+    # Default value, assume we run on the host.
+    export HVLINUX_RUN_MODE="host"
+
+    if [ -f ${CFG_DIR}/${HV_VER_FILE} ]; then
+        . ${CFG_DIR}/${HV_VER_FILE}
+
+        # Compare local UUID to the one in /etc to determine if we run on the
+        # host or on the newly-built HVLinux system.
+        if [ -f /etc/${HV_VER_FILE} ]; then
+            # Save value
+            HVUUID_LOCAL=${HVUUID}
+
+            . /etc/${HV_VER_FILE}
+
+            if [ "x${HVUUID_LOCAL}" = "x${HVUUID}" ]; then
+                HVLINUX_RUN_MODE="native"
+            else
+                # Restore value in case of mismatch
+                HVUUID=${HVUUID_LOCAL}
+            fi
+        fi
+    fi
+
+    if [ "x${HVLINUX_RUN_MODE}" = "xnative" ]; then
+        #echo "Running in NATIVE mode (stage >= 2)"
+        echo "NATIVE"
+    else
+        #echo "Running in HOST mode (stage 0 or 1)"
+        echo "HOST"
+    fi
+}
diff --git a/stage0/create-version b/stage0/create-version
new file mode 100644 (file)
index 0000000..527e7ba
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+source ../functions/main
+
+create_hvlinux_version()
+{
+    local CFG_DIR="../config"
+
+    if [ -f ${CFG_DIR}/${HV_VER_FILE} ]; then
+        echo "Version file already created"
+        return 0
+    fi
+
+    echo "Create new hvlinux-version file"
+
+    if [ ! -x /usr/bin/uuidgen ]; then
+        echo "Error, missing /usr/bin/uuidgen program"
+        exit 1
+    fi
+
+    cat > ${CFG_DIR}/${HV_VER_FILE} <<EOF
+# Do not edit this file.
+# This file is autogenerated by the HVLinux build system
+EOF
+
+    echo "HVUUID=$(uuidgen)" >> ${CFG_DIR}/${HV_VER_FILE}
+
+    # Copy local file to destination LFS partition
+    mkdir -pv ${LFS}/etc
+    cp ${CFG_DIR}/${HV_VER_FILE} ${LFS}/etc
+}
+
+create_hvlinux_version
index cdd7040..8b69a4a 100755 (executable)
@@ -5,6 +5,7 @@ source ../functions/main
 init_log_file
 
 rscr mult "Performing pre-install" pre-install
+rscr mult "Creating HVLinux version file" create-version
 
 # Logging-in as 'lfs' user, and executing the hv-install-2 script. The
 # 'su -' command starts with a clean environment and enters the home
diff --git a/stage1/pkg/patch b/stage1/pkg/patch
new file mode 100644 (file)
index 0000000..2742671
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# When cross-compiling configure cannot properly detect the existence of
+# certain features:
+hvconfig_cache()
+{
+cat > ${LFS_TMP}/${PACKAGE}-build/config.cache << EOF
+ac_cv_func_strnlen_working=yes
+EOF
+}