From 9b734560ce02e626f7ea58ea9153b5e8daa00831 Mon Sep 17 00:00:00 2001 From: gobo72 Date: Sat, 12 Mar 2011 21:29:26 +0000 Subject: [PATCH] -Added code to write and detect if we are running under the HOST (stages 0 and 1) or in NATIVE mode (stages 2 and up) --- Makefile | 29 ++++++++++++++++++++--------- functions/main | 12 +++++++++--- functions/version | 39 +++++++++++++++++++++++++++++++++++++++ stage0/create-version | 33 +++++++++++++++++++++++++++++++++ stage0/hv-install-1 | 1 + stage1/pkg/patch | 10 ++++++++++ 6 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 functions/version create mode 100644 stage0/create-version create mode 100644 stage1/pkg/patch diff --git a/Makefile b/Makefile index e80efe6..2b3202b 100644 --- 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 diff --git a/functions/main b/functions/main index c0ab98e..76aa3a0 100644 --- a/functions/main +++ b/functions/main @@ -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 index 0000000..4a96731 --- /dev/null +++ b/functions/version @@ -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 index 0000000..527e7ba --- /dev/null +++ b/stage0/create-version @@ -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} <> ${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 diff --git a/stage0/hv-install-1 b/stage0/hv-install-1 index cdd7040..8b69a4a 100755 --- a/stage0/hv-install-1 +++ b/stage0/hv-install-1 @@ -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 index 0000000..2742671 --- /dev/null +++ b/stage1/pkg/patch @@ -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 +} -- 2.20.1