From 7868997024999e80c12fbb76ca2449bd97a339b4 Mon Sep 17 00:00:00 2001 From: phanes Date: Sat, 25 Feb 2023 15:50:02 -0500 Subject: [PATCH] up thorugh 17.13.2, backup facility needs additional testing --- Makefile | 32 ++- configs/etc_hosts | 2 + make.project/build_stage4.sh | 32 +++ make.project/build_stage4backup.sh | 18 ++ project_config.sh | 1 + .../x86_64/components/stage3/bison.bash | 206 ++++++++++++++++ .../x86_64/components/stage3/clean-temp.bash | 37 +++ .../stage3/create_essential_files_links.bash | 56 +++++ .../stage3/create_system_dir_structure.bash | 72 ++++++ .../x86_64/components/stage3/gettext.bash | 206 ++++++++++++++++ .../x86_64/components/stage3/perl.bash | 215 +++++++++++++++++ .../x86_64/components/stage3/python.bash | 208 ++++++++++++++++ .../x86_64/components/stage3/texinfo.bash | 206 ++++++++++++++++ .../x86_64/components/stage3/util-linux.bash | 226 ++++++++++++++++++ .../components/stage4backup/offer_backup.bash | 109 +++++++++ rex.project/x86_64/plans/stage3.plan | 45 ++++ rex.project/x86_64/plans/stage4backup.plan | 10 + rex.project/x86_64/units/stage3.units | 162 +++++++++++++ rex.project/x86_64/units/stage4backup.units | 22 ++ 19 files changed, 1854 insertions(+), 11 deletions(-) create mode 100644 configs/etc_hosts create mode 100755 make.project/build_stage4.sh create mode 100755 make.project/build_stage4backup.sh create mode 100755 rex.project/x86_64/components/stage3/bison.bash create mode 100755 rex.project/x86_64/components/stage3/clean-temp.bash create mode 100755 rex.project/x86_64/components/stage3/create_essential_files_links.bash create mode 100755 rex.project/x86_64/components/stage3/create_system_dir_structure.bash create mode 100755 rex.project/x86_64/components/stage3/gettext.bash create mode 100755 rex.project/x86_64/components/stage3/perl.bash create mode 100755 rex.project/x86_64/components/stage3/python.bash create mode 100755 rex.project/x86_64/components/stage3/texinfo.bash create mode 100755 rex.project/x86_64/components/stage3/util-linux.bash create mode 100755 rex.project/x86_64/components/stage4backup/offer_backup.bash create mode 100644 rex.project/x86_64/plans/stage4backup.plan create mode 100644 rex.project/x86_64/units/stage4backup.units diff --git a/Makefile b/Makefile index 9a59ee7..4152a6b 100644 --- a/Makefile +++ b/Makefile @@ -55,21 +55,31 @@ disarm_chroot: enter_chroot: sudo /usr/bin/env -i bash -c ". ./project_config.sh && ${dir_make}/enter_chroot.sh" -#embeds and kicks off rex +#embeds and kicks off rex from inside chroot build_stage3: sudo /usr/bin/env -i bash -c ". ./project_config.sh && ${dir_make}/build_stage3.sh" -# example: -# make dirs -# make install_rex -# make download_sources -# make download_patches -# make build_stage1 -# make build_stage2 -# optional: make enter_chroot -# make build_stage3 +# offers to back up +build_stage4backup: + sudo /usr/bin/env -i bash -c ". ./project_config.sh && ${dir_make}/build_stage4backup.sh" -all: disarm_chroot clean dirs install_rex download_patches download_sources build_stage1 build_stage2 build_stage3 +build_stage4: + sudo /usr/bin/env -i bash -c ". ./project_config.sh && ${dir_make}/build_stage4.sh" + + +# example: +# make dirs +# make install_rex +# make download_sources +# make download_patches +# make build_stage1 +# make build_stage2 +# optional: make enter_chroot +# make build_stage3 +# optional: make build_stage4backup +# make build_stage4 + +all: disarm_chroot clean dirs install_rex download_patches download_sources build_stage1 build_stage2 build_stage3 build_stage4backup build_stage4 # Remember, before you make clean or make purge_artifacts you MUST run # make disarm_chroot beforehand or you could cause irreversible damage diff --git a/configs/etc_hosts b/configs/etc_hosts new file mode 100644 index 0000000..430ec72 --- /dev/null +++ b/configs/etc_hosts @@ -0,0 +1,2 @@ +127.0.0.1 localhost localhost.localdomain +::1 localhost diff --git a/make.project/build_stage4.sh b/make.project/build_stage4.sh new file mode 100755 index 0000000..4b0fdde --- /dev/null +++ b/make.project/build_stage4.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# fix an issue with open files limit on some hosts +ulimit -l unlimited + +#ulimit -n 10240 +ulimit -c unlimited + + +# closely aligns with LFS Ch 5, 6 +T_SYSROOT=${dir_sysroot} + +project_root=/rex_embedded + +echo "Bootstrapping from MAKE to REX..." +dir_rex=/rex_embedded/rex.project + +# Executes rex from within the chroot. +/usr/sbin/chroot "${T_SYSROOT}" /usr/bin/env -i \ + HOME="/" \ + TERM="$TERM" \ + COLORTERM=$COLORTERM \ + PS1='\n(Dark Horse Linux) [ \u @ \H ] << \w >>\n\n[- ' \ + PATH=/usr/bin:/usr/sbin \ + project_root="${project_root}" \ + dir_rex="${dir_rex}" \ + dir_logs="/${project_root}/logs" \ + /rex_embedded/stage/rex/rex -v -c ${dir_rex}/x86_64/rex.config -p ${dir_rex}/x86_64/plans/stage4.plan + + +retVal=$? +echo "Rex exited with error code '$retVal'." diff --git a/make.project/build_stage4backup.sh b/make.project/build_stage4backup.sh new file mode 100755 index 0000000..bd11bf1 --- /dev/null +++ b/make.project/build_stage4backup.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + + +# fix an issue with open files limit on some hosts +ulimit -l unlimited + +#ulimit -n 10240 +ulimit -c unlimited + +echo "Bootstrapping from MAKE to REX..." + +# Executes rex from within the shell. + +${dir_localtools}/rex -v \ + -c ${dir_rex}/x86_64/rex.config \ + -p ${dir_rex}/x86_64/plans/stage4backup.plan + +retVal=$? diff --git a/project_config.sh b/project_config.sh index 91bd74b..94e5cb1 100755 --- a/project_config.sh +++ b/project_config.sh @@ -17,6 +17,7 @@ echo "Loading project_config.sh...." # this is where the directory for foster is located. serves as the # parent directory for most other directories project_root="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" + # the project files for the make system that is used to orchestrate the # build steps dir_make=${project_root}/make.project diff --git a/rex.project/x86_64/components/stage3/bison.bash b/rex.project/x86_64/components/stage3/bison.bash new file mode 100755 index 0000000..5f9ddde --- /dev/null +++ b/rex.project/x86_64/components/stage3/bison.bash @@ -0,0 +1,206 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +# ---------------------------------------------------------------------- +# Configuration: +# ---------------------------------------------------------------------- +# the name of this application +APPNAME="bison" + +# the version of this application +VERSION="3.8.2" + +# ---------------------------------------------------------------------- +# Variables and functions sourced from Environment: +# ---------------------------------------------------------------------- +# assert_zero() +# Checks if $1 is 0. If non-0 value, halts the execution of the script. +# +# LOGS_ROOT +# The parent directory where logs from this project will go. +# +# TEMP_STAGE_DIR +# The parent directory of where source archives are extracted to. + +# register mode selections +ARGUMENT_LIST=( + "stage" + "build" + "install" + "all" + "help" +) + +# modes to associate with switches +# assumes you want nothing done unless you ask for it. +MODE_STAGE=false +MODE_BUILD=false +MODE_INSTALL=false +MODE_ALL=false +MODE_HELP=false + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the path where the source will be located when complete +# note: TEMP_STAGE_DIR is sourced from environment +T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}" + +# read defined arguments +opts=$(getopt \ + --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ + --name "$APPNAME" \ + --options "" \ + -- "$@" +) + +# process supplied arguments into flags that enable execution modes +eval set --$opts +while [[ $# -gt 0 ]]; do + case "$1" in + --stage) + MODE_STAGE=true + shift 1 + ;; + --build) + MODE_BUILD=true + shift 1 + ;; + --install) + MODE_INSTALL=true + shift 1 + ;; + --all) + MODE_ALL=true + shift 1 + ;; + --help) + MODE_HELP=true + shift 1 + ;; + *) + break + ;; + esac +done + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +# when the stage mode is enabled, this will execute +mode_stage() { + logprint "Starting stage of ${APPNAME}..." + + logprint "Removing any pre-existing staging for ${APPNAME}." + rm -Rf "${T_SOURCE_DIR}"* + + logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}" + tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}" + assert_zero $? + + # conditionally rename if it needs it + stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}" + + logprint "Staging operation complete." +} + +# when the build_pass1 mode is enabled, this will execute +mode_build() { + + # patch, configure and build + logprint "Starting build of ${APPNAME}..." + + logprint "Entering stage dir." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Configuring ${APPNAME}..." + ./configure --prefix=/usr --docdir=/usr/share/doc/bison-${VERSION} + assert_zero $? + + logprint "Compiling..." + make + assert_zero $? + + logprint "Build operation complete." +} + +mode_install() { + logprint "Starting install of ${APPNAME}..." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Installing..." + make install + assert_zero $? + + logprint "Partial install operation complete." +} + + +mode_help() { + echo "${APPNAME} [ --stage ] [ --build ] [ --install ] [ --all ] [ --help ]" + exit 1 +} + +if [ "$MODE_ALL" = "true" ]; then + MODE_STAGE=true + MODE_BUILD=true + MODE_INSTALL=true +fi + +# if no options were selected, then show help and exit +if \ + [ "$MODE_HELP" != "true" ] && \ + [ "$MODE_STAGE" != "true" ] && \ + [ "$MODE_BUILD" != "true" ] && \ + [ "$MODE_INSTALL" != "true" ] +then + logprint "No option selected during execution." + mode_help +fi + +# if help was supplied at all, show help and exit +if [ "$MODE_HELP" = "true" ]; then + logprint "Help option selected. Printing options and exiting." + mode_help +fi + +if [ "$MODE_STAGE" = "true" ]; then + logprint "Staging option selected." + mode_stage + assert_zero $? +fi + +if [ "$MODE_BUILD" = "true" ]; then + logprint "Build of ${APPNAME} selected." + mode_build + assert_zero $? +fi + +if [ "$MODE_INSTALL" = "true" ]; then + logprint "Install of ${APPNAME} selected." + mode_install + assert_zero $? +fi + +logprint "Execution of ${APPNAME} completed." + diff --git a/rex.project/x86_64/components/stage3/clean-temp.bash b/rex.project/x86_64/components/stage3/clean-temp.bash new file mode 100755 index 0000000..3de9c9d --- /dev/null +++ b/rex.project/x86_64/components/stage3/clean-temp.bash @@ -0,0 +1,37 @@ +#!/bin/bash +# Prepares sysroot ownership and perms for chrooting +# print to stdout, print to log +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment + +APPNAME="Cleaning up the Temporary System" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the file to log to +LOGFILE="${APPNAME}.log" + +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +logprint "Cleaning up the Temporary System" + + +# this may need an alternative approach when we shift deliverables towards an install iso +logprint "Removing temp documentation files..." +rm -rvf /usr/share/{info,man,doc}/* +assert_zero $? + +logprint "Removing temp libtool artifacts..." +find /usr/{lib,exec} -name \*.la -delete +assert_zero $? + +logprint "Cleaning out Temporary Cross-Compilation Toolchain" +rm -Rf ${CROSSTOOLS_DIR} +assert_zero $? diff --git a/rex.project/x86_64/components/stage3/create_essential_files_links.bash b/rex.project/x86_64/components/stage3/create_essential_files_links.bash new file mode 100755 index 0000000..48e6ff1 --- /dev/null +++ b/rex.project/x86_64/components/stage3/create_essential_files_links.bash @@ -0,0 +1,56 @@ +#!/bin/bash +# Prepares sysroot ownership and perms for chrooting +# print to stdout, print to log +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment + +APPNAME="Creating Essential Files and Symlinks" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the file to log to +LOGFILE="${APPNAME}.log" + +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +logprint "Creating Essential Files and Symlinks" + + +# this may need an alternative approach when we shift deliverables towards an install iso +logprint "Generating /etc/mtab from /proc/self/mounts" +ln -sv /proc/self/mounts /etc/mtab +assert_zero $? + +logprint "Staging /etc/hosts file" +cp -f ${dir_configs}/etc_hosts /etc/hosts +assert_zero $? + +logprint "creating a temporary user and group for some tests later" +echo "tester:x:101:101::/home/tester:/bin/bash" >> /etc/passwd +assert_zero $? +echo "tester:x:101:" >> /etc/group +assert_zero $? + +logprint "creating the tester user home dir" +install -o tester -d /home/tester +assert_zero $? + +logprint "creating log placeholders for login/agetty/init/btmp/lastlog" +touch /var/log/{btmp,lastlog,faillog,wtmp} +assert_zero $? + +chgrp -v utmp /var/log/lastlog +assert_zero $? + +chmod -v 664 /var/log/lastlog +assert_zero $? + +chmod -v 600 /var/log/btmp +assert_zero $? diff --git a/rex.project/x86_64/components/stage3/create_system_dir_structure.bash b/rex.project/x86_64/components/stage3/create_system_dir_structure.bash new file mode 100755 index 0000000..08bb92b --- /dev/null +++ b/rex.project/x86_64/components/stage3/create_system_dir_structure.bash @@ -0,0 +1,72 @@ +#!/bin/bash +# Prepares sysroot ownership and perms for chrooting +# print to stdout, print to log +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment + +APPNAME="Creating system directories" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the file to log to +LOGFILE="${APPNAME}.log" + +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +logprint "Creating system directories..." + +mkdir -pv /{boot,home,mnt,opt,srv} +assert_zero $? + +mkdir -pv /etc/{opt,sysconfig} +assert_zero $? + +mkdir -pv /lib/firmware +assert_zero $? + +mkdir -pv /media/{floppy,cdrom} +assert_zero $? + +mkdir -pv /usr/{,local/}{include,src} +assert_zero $? + +mkdir -pv /usr/local/{bin,lib,sbin} +assert_zero $? + +mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man} +assert_zero $? + +mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo} +assert_zero $? + +mkdir -pv /usr/{,local/}share/man/man{1..8} +assert_zero $? + +mkdir -pv /var/{cache,local,log,mail,opt,spool} +assert_zero $? + +mkdir -pv /var/lib/{color,misc,locate} +assert_zero $? + +ln -sfv /run /var/run +assert_zero $? + +ln -sfv /run/lock /var/lock +assert_zero $? + +install -dv -m 0750 /root +assert_zero $? + +install -dv -m 1777 /tmp /var/tmp +assert_zero $? + +# additional FHS compliance directories go here +# these are only a subset + diff --git a/rex.project/x86_64/components/stage3/gettext.bash b/rex.project/x86_64/components/stage3/gettext.bash new file mode 100755 index 0000000..3adf63a --- /dev/null +++ b/rex.project/x86_64/components/stage3/gettext.bash @@ -0,0 +1,206 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +# ---------------------------------------------------------------------- +# Configuration: +# ---------------------------------------------------------------------- +# the name of this application +APPNAME="gettext" + +# the version of this application +VERSION="0.21.1" + +# ---------------------------------------------------------------------- +# Variables and functions sourced from Environment: +# ---------------------------------------------------------------------- +# assert_zero() +# Checks if $1 is 0. If non-0 value, halts the execution of the script. +# +# LOGS_ROOT +# The parent directory where logs from this project will go. +# +# TEMP_STAGE_DIR +# The parent directory of where source archives are extracted to. + +# register mode selections +ARGUMENT_LIST=( + "stage" + "build_temp" + "install_temp" + "all_temp" + "help" +) + +# modes to associate with switches +# assumes you want nothing done unless you ask for it. +MODE_STAGE=false +MODE_BUILD_TEMP=false +MODE_INSTALL_TEMP=false +MODE_ALL_TEMP=false +MODE_HELP=false + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the path where the source will be located when complete +# note: TEMP_STAGE_DIR is sourced from environment +T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}" + +# read defined arguments +opts=$(getopt \ + --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ + --name "$APPNAME" \ + --options "" \ + -- "$@" +) + +# process supplied arguments into flags that enable execution modes +eval set --$opts +while [[ $# -gt 0 ]]; do + case "$1" in + --stage) + MODE_STAGE=true + shift 1 + ;; + --build_temp) + MODE_BUILD_TEMP=true + shift 1 + ;; + --install_temp) + MODE_INSTALL_TEMP=true + shift 1 + ;; + --all_temp) + MODE_ALL_TEMP=true + shift 1 + ;; + --help) + MODE_HELP=true + shift 1 + ;; + *) + break + ;; + esac +done + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +# when the stage mode is enabled, this will execute +mode_stage() { + logprint "Starting stage of ${APPNAME}..." + + logprint "Removing any pre-existing staging for ${APPNAME}." + rm -Rf "${T_SOURCE_DIR}"* + + logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}" + tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}" + assert_zero $? + + # conditionally rename if it needs it + stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}" + + logprint "Staging operation complete." +} + +# when the build_pass1 mode is enabled, this will execute +mode_build_temp() { + + # patch, configure and build + logprint "Starting build of ${APPNAME}..." + + logprint "Entering stage dir." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Configuring ${APPNAME}..." + ./configure --disable-shared + assert_zero $? + + logprint "Compiling..." + make + assert_zero $? + + logprint "Build operation complete." +} + +mode_install_temp() { + logprint "Starting install of ${APPNAME}..." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Installing..." + cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin/ + assert_zero $? + + logprint "Partial install operation complete." +} + + +mode_help() { + echo "${APPNAME} [ --stage ] [ --build_temp ] [ --install_temp ] [ --all_temp ] [ --help ]" + exit 1 +} + +if [ "$MODE_ALL_TEMP" = "true" ]; then + MODE_STAGE=true + MODE_BUILD_TEMP=true + MODE_INSTALL_TEMP=true +fi + +# if no options were selected, then show help and exit +if \ + [ "$MODE_HELP" != "true" ] && \ + [ "$MODE_STAGE" != "true" ] && \ + [ "$MODE_BUILD_TEMP" != "true" ] && \ + [ "$MODE_INSTALL_TEMP" != "true" ] +then + logprint "No option selected during execution." + mode_help +fi + +# if help was supplied at all, show help and exit +if [ "$MODE_HELP" = "true" ]; then + logprint "Help option selected. Printing options and exiting." + mode_help +fi + +if [ "$MODE_STAGE" = "true" ]; then + logprint "Staging option selected." + mode_stage + assert_zero $? +fi + +if [ "$MODE_BUILD_TEMP" = "true" ]; then + logprint "Build of ${APPNAME} selected." + mode_build_temp + assert_zero $? +fi + +if [ "$MODE_INSTALL_TEMP" = "true" ]; then + logprint "Install of ${APPNAME} selected." + mode_install_temp + assert_zero $? +fi + +logprint "Execution of ${APPNAME} completed." + diff --git a/rex.project/x86_64/components/stage3/perl.bash b/rex.project/x86_64/components/stage3/perl.bash new file mode 100755 index 0000000..dd9b9d7 --- /dev/null +++ b/rex.project/x86_64/components/stage3/perl.bash @@ -0,0 +1,215 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +# ---------------------------------------------------------------------- +# Configuration: +# ---------------------------------------------------------------------- +# the name of this application +APPNAME="perl" + +# the version of this application +VERSION="5.36.0" + +# ---------------------------------------------------------------------- +# Variables and functions sourced from Environment: +# ---------------------------------------------------------------------- +# assert_zero() +# Checks if $1 is 0. If non-0 value, halts the execution of the script. +# +# LOGS_ROOT +# The parent directory where logs from this project will go. +# +# TEMP_STAGE_DIR +# The parent directory of where source archives are extracted to. + +# register mode selections +ARGUMENT_LIST=( + "stage" + "build" + "install" + "all" + "help" +) + +# modes to associate with switches +# assumes you want nothing done unless you ask for it. +MODE_STAGE=false +MODE_BUILD=false +MODE_INSTALL=false +MODE_ALL=false +MODE_HELP=false + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the path where the source will be located when complete +# note: TEMP_STAGE_DIR is sourced from environment +T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}" + +# read defined arguments +opts=$(getopt \ + --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ + --name "$APPNAME" \ + --options "" \ + -- "$@" +) + +# process supplied arguments into flags that enable execution modes +eval set --$opts +while [[ $# -gt 0 ]]; do + case "$1" in + --stage) + MODE_STAGE=true + shift 1 + ;; + --build) + MODE_BUILD=true + shift 1 + ;; + --install) + MODE_INSTALL=true + shift 1 + ;; + --all) + MODE_ALL=true + shift 1 + ;; + --help) + MODE_HELP=true + shift 1 + ;; + *) + break + ;; + esac +done + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +# when the stage mode is enabled, this will execute +mode_stage() { + logprint "Starting stage of ${APPNAME}..." + + logprint "Removing any pre-existing staging for ${APPNAME}." + rm -Rf "${T_SOURCE_DIR}"* + + logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}" + tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}" + assert_zero $? + + # conditionally rename if it needs it + stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}" + + logprint "Staging operation complete." +} + +# when the build_pass1 mode is enabled, this will execute +mode_build() { + + # patch, configure and build + logprint "Starting build of ${APPNAME}..." + + logprint "Entering stage dir." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Configuring ${APPNAME}..." + sh Configure \ + -des \ + -Dprefix=/usr \ + -Dvendorprefix=/usr \ + -Dprivlib=/usr/lib/perl5/${VERSION}/core_perl \ + -Darchlib=/usr/lib/perl5/${VERSION}/core_perl \ + -Dsitelib=/usr/lib/perl5/${VERSION}/site_perl \ + -Dsitearch=/usr/lib/perl5/${VERSION}/site_perl \ + -Dvendorlib=/usr/lib/perl5/${VERSION}/vendor_perl \ + -Dvendorarch=/usr/lib/perl5/${VERSION}/vendor_perl + assert_zero $? + + logprint "Compiling..." + make + assert_zero $? + + logprint "Build operation complete." +} + +mode_install() { + logprint "Starting install of ${APPNAME}..." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Installing..." + make install + assert_zero $? + + logprint "Partial install operation complete." +} + + +mode_help() { + echo "${APPNAME} [ --stage ] [ --build ] [ --install ] [ --all ] [ --help ]" + exit 1 +} + +if [ "$MODE_ALL" = "true" ]; then + MODE_STAGE=true + MODE_BUILD=true + MODE_INSTALL=true +fi + +# if no options were selected, then show help and exit +if \ + [ "$MODE_HELP" != "true" ] && \ + [ "$MODE_STAGE" != "true" ] && \ + [ "$MODE_BUILD" != "true" ] && \ + [ "$MODE_INSTALL" != "true" ] +then + logprint "No option selected during execution." + mode_help +fi + +# if help was supplied at all, show help and exit +if [ "$MODE_HELP" = "true" ]; then + logprint "Help option selected. Printing options and exiting." + mode_help +fi + +if [ "$MODE_STAGE" = "true" ]; then + logprint "Staging option selected." + mode_stage + assert_zero $? +fi + +if [ "$MODE_BUILD" = "true" ]; then + logprint "Build of ${APPNAME} selected." + mode_build + assert_zero $? +fi + +if [ "$MODE_INSTALL" = "true" ]; then + logprint "Install of ${APPNAME} selected." + mode_install + assert_zero $? +fi + +logprint "Execution of ${APPNAME} completed." + diff --git a/rex.project/x86_64/components/stage3/python.bash b/rex.project/x86_64/components/stage3/python.bash new file mode 100755 index 0000000..660213d --- /dev/null +++ b/rex.project/x86_64/components/stage3/python.bash @@ -0,0 +1,208 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +# ---------------------------------------------------------------------- +# Configuration: +# ---------------------------------------------------------------------- +# the name of this application +APPNAME="Python" + +# the version of this application +VERSION="3.11.2" + +# ---------------------------------------------------------------------- +# Variables and functions sourced from Environment: +# ---------------------------------------------------------------------- +# assert_zero() +# Checks if $1 is 0. If non-0 value, halts the execution of the script. +# +# LOGS_ROOT +# The parent directory where logs from this project will go. +# +# TEMP_STAGE_DIR +# The parent directory of where source archives are extracted to. + +# register mode selections +ARGUMENT_LIST=( + "stage" + "build" + "install" + "all" + "help" +) + +# modes to associate with switches +# assumes you want nothing done unless you ask for it. +MODE_STAGE=false +MODE_BUILD=false +MODE_INSTALL=false +MODE_ALL=false +MODE_HELP=false + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the path where the source will be located when complete +# note: TEMP_STAGE_DIR is sourced from environment +T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}" + +# read defined arguments +opts=$(getopt \ + --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ + --name "$APPNAME" \ + --options "" \ + -- "$@" +) + +# process supplied arguments into flags that enable execution modes +eval set --$opts +while [[ $# -gt 0 ]]; do + case "$1" in + --stage) + MODE_STAGE=true + shift 1 + ;; + --build) + MODE_BUILD=true + shift 1 + ;; + --install) + MODE_INSTALL=true + shift 1 + ;; + --all) + MODE_ALL=true + shift 1 + ;; + --help) + MODE_HELP=true + shift 1 + ;; + *) + break + ;; + esac +done + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +# when the stage mode is enabled, this will execute +mode_stage() { + logprint "Starting stage of ${APPNAME}..." + + logprint "Removing any pre-existing staging for ${APPNAME}." + rm -Rf "${T_SOURCE_DIR}"* + + logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}" + tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}" + assert_zero $? + + # conditionally rename if it needs it + stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}" + + logprint "Staging operation complete." +} + +# when the build_pass1 mode is enabled, this will execute +mode_build() { + + # patch, configure and build + logprint "Starting build of ${APPNAME}..." + + logprint "Entering stage dir." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Configuring ${APPNAME}..." + ./configure --prefix=/usr --enable-shared --without-ensurepip + assert_zero $? + + logprint "Compiling..." + make + assert_zero $? + + logprint "Build operation complete." +} + +mode_install() { + logprint "Starting install of ${APPNAME}..." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Installing..." + make install + + # this assert may result in false positives? + assert_zero $? + + logprint "Partial install operation complete." +} + + +mode_help() { + echo "${APPNAME} [ --stage ] [ --build ] [ --install ] [ --all ] [ --help ]" + exit 1 +} + +if [ "$MODE_ALL" = "true" ]; then + MODE_STAGE=true + MODE_BUILD=true + MODE_INSTALL=true +fi + +# if no options were selected, then show help and exit +if \ + [ "$MODE_HELP" != "true" ] && \ + [ "$MODE_STAGE" != "true" ] && \ + [ "$MODE_BUILD" != "true" ] && \ + [ "$MODE_INSTALL" != "true" ] +then + logprint "No option selected during execution." + mode_help +fi + +# if help was supplied at all, show help and exit +if [ "$MODE_HELP" = "true" ]; then + logprint "Help option selected. Printing options and exiting." + mode_help +fi + +if [ "$MODE_STAGE" = "true" ]; then + logprint "Staging option selected." + mode_stage + assert_zero $? +fi + +if [ "$MODE_BUILD" = "true" ]; then + logprint "Build of ${APPNAME} selected." + mode_build + assert_zero $? +fi + +if [ "$MODE_INSTALL" = "true" ]; then + logprint "Install of ${APPNAME} selected." + mode_install + assert_zero $? +fi + +logprint "Execution of ${APPNAME} completed." + diff --git a/rex.project/x86_64/components/stage3/texinfo.bash b/rex.project/x86_64/components/stage3/texinfo.bash new file mode 100755 index 0000000..e387588 --- /dev/null +++ b/rex.project/x86_64/components/stage3/texinfo.bash @@ -0,0 +1,206 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +# ---------------------------------------------------------------------- +# Configuration: +# ---------------------------------------------------------------------- +# the name of this application +APPNAME="texinfo" + +# the version of this application +VERSION="7.0.2" + +# ---------------------------------------------------------------------- +# Variables and functions sourced from Environment: +# ---------------------------------------------------------------------- +# assert_zero() +# Checks if $1 is 0. If non-0 value, halts the execution of the script. +# +# LOGS_ROOT +# The parent directory where logs from this project will go. +# +# TEMP_STAGE_DIR +# The parent directory of where source archives are extracted to. + +# register mode selections +ARGUMENT_LIST=( + "stage" + "build" + "install" + "all" + "help" +) + +# modes to associate with switches +# assumes you want nothing done unless you ask for it. +MODE_STAGE=false +MODE_BUILD=false +MODE_INSTALL=false +MODE_ALL=false +MODE_HELP=false + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the path where the source will be located when complete +# note: TEMP_STAGE_DIR is sourced from environment +T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}" + +# read defined arguments +opts=$(getopt \ + --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ + --name "$APPNAME" \ + --options "" \ + -- "$@" +) + +# process supplied arguments into flags that enable execution modes +eval set --$opts +while [[ $# -gt 0 ]]; do + case "$1" in + --stage) + MODE_STAGE=true + shift 1 + ;; + --build) + MODE_BUILD=true + shift 1 + ;; + --install) + MODE_INSTALL=true + shift 1 + ;; + --all) + MODE_ALL=true + shift 1 + ;; + --help) + MODE_HELP=true + shift 1 + ;; + *) + break + ;; + esac +done + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +# when the stage mode is enabled, this will execute +mode_stage() { + logprint "Starting stage of ${APPNAME}..." + + logprint "Removing any pre-existing staging for ${APPNAME}." + rm -Rf "${T_SOURCE_DIR}"* + + logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}" + tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}" + assert_zero $? + + # conditionally rename if it needs it + stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}" + + logprint "Staging operation complete." +} + +# when the build_pass1 mode is enabled, this will execute +mode_build() { + + # patch, configure and build + logprint "Starting build of ${APPNAME}..." + + logprint "Entering stage dir." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Configuring ${APPNAME}..." + ./configure --prefix=/usr + assert_zero $? + + logprint "Compiling..." + make + assert_zero $? + + logprint "Build operation complete." +} + +mode_install() { + logprint "Starting install of ${APPNAME}..." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Installing..." + make install + assert_zero $? + + logprint "Partial install operation complete." +} + + +mode_help() { + echo "${APPNAME} [ --stage ] [ --build ] [ --install ] [ --all ] [ --help ]" + exit 1 +} + +if [ "$MODE_ALL" = "true" ]; then + MODE_STAGE=true + MODE_BUILD=true + MODE_INSTALL=true +fi + +# if no options were selected, then show help and exit +if \ + [ "$MODE_HELP" != "true" ] && \ + [ "$MODE_STAGE" != "true" ] && \ + [ "$MODE_BUILD" != "true" ] && \ + [ "$MODE_INSTALL" != "true" ] +then + logprint "No option selected during execution." + mode_help +fi + +# if help was supplied at all, show help and exit +if [ "$MODE_HELP" = "true" ]; then + logprint "Help option selected. Printing options and exiting." + mode_help +fi + +if [ "$MODE_STAGE" = "true" ]; then + logprint "Staging option selected." + mode_stage + assert_zero $? +fi + +if [ "$MODE_BUILD" = "true" ]; then + logprint "Build of ${APPNAME} selected." + mode_build + assert_zero $? +fi + +if [ "$MODE_INSTALL" = "true" ]; then + logprint "Install of ${APPNAME} selected." + mode_install + assert_zero $? +fi + +logprint "Execution of ${APPNAME} completed." + diff --git a/rex.project/x86_64/components/stage3/util-linux.bash b/rex.project/x86_64/components/stage3/util-linux.bash new file mode 100755 index 0000000..ef74466 --- /dev/null +++ b/rex.project/x86_64/components/stage3/util-linux.bash @@ -0,0 +1,226 @@ +#!/bin/bash +# desc: +# stages, builds, installs + +# make variables persist in subprocesses for logging function +set -a + +# ---------------------------------------------------------------------- +# Configuration: +# ---------------------------------------------------------------------- +# the name of this application +APPNAME="util-linux" + +# the version of this application +VERSION="2.38.1" + +# ---------------------------------------------------------------------- +# Variables and functions sourced from Environment: +# ---------------------------------------------------------------------- +# assert_zero() +# Checks if $1 is 0. If non-0 value, halts the execution of the script. +# +# LOGS_ROOT +# The parent directory where logs from this project will go. +# +# TEMP_STAGE_DIR +# The parent directory of where source archives are extracted to. + +# register mode selections +ARGUMENT_LIST=( + "stage" + "build" + "install" + "all" + "help" +) + +# modes to associate with switches +# assumes you want nothing done unless you ask for it. +MODE_STAGE=false +MODE_BUILD=false +MODE_INSTALL=false +MODE_ALL=false +MODE_HELP=false + +# the file to log to +LOGFILE="${APPNAME}.log" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +# the path where logs are written to +# note: LOGS_ROOT is sourced from environment +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the path where the source will be located when complete +# note: TEMP_STAGE_DIR is sourced from environment +T_SOURCE_DIR="${TEMP_STAGE_DIR}/${APPNAME}" + +# read defined arguments +opts=$(getopt \ + --longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \ + --name "$APPNAME" \ + --options "" \ + -- "$@" +) + +# process supplied arguments into flags that enable execution modes +eval set --$opts +while [[ $# -gt 0 ]]; do + case "$1" in + --stage) + MODE_STAGE=true + shift 1 + ;; + --build) + MODE_BUILD=true + shift 1 + ;; + --install) + MODE_INSTALL=true + shift 1 + ;; + --all) + MODE_ALL=true + shift 1 + ;; + --help) + MODE_HELP=true + shift 1 + ;; + *) + break + ;; + esac +done + +# print to stdout, print to log +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +# Tell the user we're alive... +logprint "Initializing the ${APPNAME} utility..." + +# when the stage mode is enabled, this will execute +mode_stage() { + logprint "Starting stage of ${APPNAME}..." + + logprint "Removing any pre-existing staging for ${APPNAME}." + rm -Rf "${T_SOURCE_DIR}"* + + logprint "Extracting ${APPNAME}-${VERSION} source archive to ${TEMP_STAGE_DIR}" + tar xf "${SOURCES_DIR}/${APPNAME}-${VERSION}.tar."* -C "${TEMP_STAGE_DIR}" + assert_zero $? + + # conditionally rename if it needs it + stat "${T_SOURCE_DIR}-"* && mv "${T_SOURCE_DIR}-"* "${T_SOURCE_DIR}" + + logprint "Staging operation complete." +} + +# when the build_pass1 mode is enabled, this will execute +mode_build() { + + # patch, configure and build + logprint "Starting build of ${APPNAME}..." + + logprint "Removing pre-staged getopt utility..." + rm -f /usr/local/bin/getopt + assert_zero $? + + # silently fail, since it's already there from earlier + mkdir -p /var/lib/hwclock + assert_zero $? + + logprint "Entering stage dir." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Configuring ${APPNAME}..." + ./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --libdir==/usr/lib \ + --docdir=/usr/share/doc/util-linux-${VERSION} \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --without-python \ + runstatedir=/run + assert_zero $? + + logprint "Compiling..." + make + assert_zero $? + + logprint "Build operation complete." +} + +mode_install() { + logprint "Starting install of ${APPNAME}..." + pushd "${T_SOURCE_DIR}" + assert_zero $? + + logprint "Installing..." + make install + assert_zero $? + + logprint "Partial install operation complete." +} + + +mode_help() { + echo "${APPNAME} [ --stage ] [ --build ] [ --install ] [ --all ] [ --help ]" + exit 1 +} + +if [ "$MODE_ALL" = "true" ]; then + MODE_STAGE=true + MODE_BUILD=true + MODE_INSTALL=true +fi + +# if no options were selected, then show help and exit +if \ + [ "$MODE_HELP" != "true" ] && \ + [ "$MODE_STAGE" != "true" ] && \ + [ "$MODE_BUILD" != "true" ] && \ + [ "$MODE_INSTALL" != "true" ] +then + logprint "No option selected during execution." + mode_help +fi + +# if help was supplied at all, show help and exit +if [ "$MODE_HELP" = "true" ]; then + logprint "Help option selected. Printing options and exiting." + mode_help +fi + +if [ "$MODE_STAGE" = "true" ]; then + logprint "Staging option selected." + mode_stage + assert_zero $? +fi + +if [ "$MODE_BUILD" = "true" ]; then + logprint "Build of ${APPNAME} selected." + mode_build + assert_zero $? +fi + +if [ "$MODE_INSTALL" = "true" ]; then + logprint "Install of ${APPNAME} selected." + mode_install + assert_zero $? +fi + +logprint "Execution of ${APPNAME} completed." + diff --git a/rex.project/x86_64/components/stage4backup/offer_backup.bash b/rex.project/x86_64/components/stage4backup/offer_backup.bash new file mode 100755 index 0000000..c00447c --- /dev/null +++ b/rex.project/x86_64/components/stage4backup/offer_backup.bash @@ -0,0 +1,109 @@ +#!/bin/bash +# move this to the makefile as a dedicated target + +APPNAME="Offer Backup" + +# ISO 8601 variation +TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)" + +LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}" + +# the file to log to +LOGFILE="${APPNAME}.log" + +logprint() { + mkdir -p "${LOG_DIR}" + echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \ + | tee -a "${LOG_DIR}/${LOGFILE}" +} + +logprint "Giving the user the option of backing up before proceeding." + +is_mounted() { + findmnt $1 &> /dev/null + if [ $? != 0 ]; then + logprint "Not mounted...skipping." + /usr/bin/false + else + logprint "Mounted..." + /usr/bin/true + fi +} + +function disarm_chroot() { + logprint "Unmounting CHROOT VFKS mounts" + + logprint "Unmounting ${T_SYSROOT}/dev" + is_mounted ${T_SYSROOT}/dev && umount -l ${T_SYSROOT}/dev + + logprint "Unmounting ${T_SYSROOT}/dev/pts" + is_mounted ${T_SYSROOT}/dev/pts && umount -l ${T_SYSROOT}/dev/pts + + logprint "Unmounting ${T_SYSROOT}/proc" + is_mounted ${T_SYSROOT}/proc && umount -l ${T_SYSROOT}/proc + + # not a symlink on ubuntu + logprint "Unmounting ${T_SYSROOT}/dev/shm" + is_mounted ${T_SYSROOT}/dev/shm && umount -l ${T_SYSROOT}/dev/shm + + logprint "Unmounting pyrois inside of chroot" + is_mounted ${T_SYSROOT}/rex_embedded && umount -l ${T_SYSROOT}/rex_embedded +} + +function perform_backup() { + logprint "Entering backup routine." + disarm_chroot + disarm_chroot + logprint "Performing backup...This will take a long time..." + tar czfp ${project_root}/${TIMESTAMP}.backup.tgz ${dir_stage} + assert_zero $? + logprint "Backup completed successfully. Moving on." + logprint "Entering project root." + pushd ${project_root} + assert_zero $? + logprint "Re-arming chroot..." + make arm_chroot + echo + logprint "You may now proceed to run 'make build_stage4'." + echo +} + + +read -r -d '' msg <<-'EOF' +This is a great stopping point for backing up the stage if you're +debugging. The following prompt will ask if you'd like to back up the +existing sysroot, in case you need to start from stage 4 again for +whatever reason, such as a build failure. + +If you select yes, you will see a gzipped tarball containing the +sysroot generated in your project root. If you select no, your backup +will not be created, and you'll move on to stage 4. + +If you skip the backup and something fails from here, you'll need to +run "make clean" and start from the beginning. + +If you do decide to back up, which you should, should you need to +restore from your backup, simply running "make restore" will perform +the operations necessary. +EOF + +read -r -d '' yn_msg <<-'EOF' +Do you want to back up the stage? + +If you select yes, the VKFS mounts for the chroot will be unmounted temporarily to perform this operation. +EOF + +# Use the dialog utility to display information to the user +dialog --backtitle "Dark Horse Linux: Pyrois" --title "IMPORTANT NOTICE" --msgbox "$msg" 20 78 + +# Use the dialog utility to prompt the user with a yes/no question +dialog --backtitle "Dark Horse Linux: Pyrois" --title "Back up the stage?" --yesno "$yn_msg" 10 60 +response=$? + +if [ $response -eq 0 ]; then + logprint "User selected to perform backups." + perform_backup +else + logprint "User selected to skip backups. Moving on." + exit 0 +fi diff --git a/rex.project/x86_64/plans/stage3.plan b/rex.project/x86_64/plans/stage3.plan index d6a342d..590f935 100644 --- a/rex.project/x86_64/plans/stage3.plan +++ b/rex.project/x86_64/plans/stage3.plan @@ -5,6 +5,51 @@ "name": "welcome 3", "dependencies": [ null ], "comment": "greet the user" + }, + { + "name": "creating system directory structure", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.5" + }, + { + "name": "creating essential files and symlinks", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.6" + }, + { + "name": "gettext", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.7" + }, + { + "name": "bison", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.8" + }, + { + "name": "perl", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.9" + }, + { + "name": "python", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.10" + }, + { + "name": "texinfo", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.11" + }, + { + "name": "util-linux", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.12" + }, + { + "name": "cleaning up the temp system", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.13" } ] } diff --git a/rex.project/x86_64/plans/stage4backup.plan b/rex.project/x86_64/plans/stage4backup.plan new file mode 100644 index 0000000..065d8f0 --- /dev/null +++ b/rex.project/x86_64/plans/stage4backup.plan @@ -0,0 +1,10 @@ +{ + "plan": + [ + { + "name": "offer backup", + "dependencies": [ null ], + "comment": "LFS 11.3-systemd-rc1 Ch. 7.13.2" + } + ] +} diff --git a/rex.project/x86_64/units/stage3.units b/rex.project/x86_64/units/stage3.units index 2b9424b..9130a58 100644 --- a/rex.project/x86_64/units/stage3.units +++ b/rex.project/x86_64/units/stage3.units @@ -17,6 +17,168 @@ "group": "root", "supply_environment": true, "environment": "environments/stage3.env.bash" + }, + { + "name": "creating system directory structure", + "target": "components/stage3/create_system_dir_structure.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "creating essential files and symlinks", + "target": "components/stage3/create_essential_files_links.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "gettext", + "target": "components/stage3/gettext.bash --all_temp", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "bison", + "target": "components/stage3/bison.bash --all", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "perl", + "target": "components/stage3/perl.bash --all", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "python", + "target": "components/stage3/python.bash --all", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "texinfo", + "target": "components/stage3/texinfo.bash --all", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "util-linux", + "target": "components/stage3/util-linux.bash --all", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" + }, + { + "name": "cleaning up the temp system", + "target": "components/stage3/clean-temp.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage3.env.bash" } ] } diff --git a/rex.project/x86_64/units/stage4backup.units b/rex.project/x86_64/units/stage4backup.units new file mode 100644 index 0000000..c58f237 --- /dev/null +++ b/rex.project/x86_64/units/stage4backup.units @@ -0,0 +1,22 @@ +{ + "units": [ + { + "name": "offer backup", + "target": "components/stage4backup/offer_backup.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": false, + "rectifier": "", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/stage2.env.bash" + } + ] +}