From 5ddeaeeacb3a72ada04915f288371249a94f3636 Mon Sep 17 00:00:00 2001 From: Chris Punches Date: Fri, 9 Feb 2024 02:04:57 -0500 Subject: [PATCH] adding rest of files from last push --- make.project/dependencies.sh | 21 +++++++++ .../x86_64/components/dependencies/bash.bash | 10 ++++ .../components/dependencies/coreutils.bash | 10 ++++ .../x86_64/environments/dependencies.env.bash | 47 +++++++++++++++++++ rex.project/x86_64/plans/dependencies.plan | 15 ++++++ rex.project/x86_64/units/dependencies.units | 40 ++++++++++++++++ 6 files changed, 143 insertions(+) create mode 100755 make.project/dependencies.sh create mode 100755 rex.project/x86_64/components/dependencies/bash.bash create mode 100755 rex.project/x86_64/components/dependencies/coreutils.bash create mode 100755 rex.project/x86_64/environments/dependencies.env.bash create mode 100644 rex.project/x86_64/plans/dependencies.plan create mode 100644 rex.project/x86_64/units/dependencies.units diff --git a/make.project/dependencies.sh b/make.project/dependencies.sh new file mode 100755 index 0000000..ce48d40 --- /dev/null +++ b/make.project/dependencies.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -u + +# closely aligns with LFS Ch 5, 6 + +# 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/dependencies.plan + +retVal=$? +exit $retVal diff --git a/rex.project/x86_64/components/dependencies/bash.bash b/rex.project/x86_64/components/dependencies/bash.bash new file mode 100755 index 0000000..575ab52 --- /dev/null +++ b/rex.project/x86_64/components/dependencies/bash.bash @@ -0,0 +1,10 @@ +#!/bin/bash +set -u + +export LC_ALL=C + +expected_version="$1" +app="bash" + +ver_check $app $expected_version || echofail "$app $expected_version check failed." +exit $? diff --git a/rex.project/x86_64/components/dependencies/coreutils.bash b/rex.project/x86_64/components/dependencies/coreutils.bash new file mode 100755 index 0000000..2c3b8a4 --- /dev/null +++ b/rex.project/x86_64/components/dependencies/coreutils.bash @@ -0,0 +1,10 @@ +#!/bin/bash +set -u + +export LC_ALL=C + +expected_version="$1" +app="sort" + +ver_check $app $expected_version || echofail "$app $expected_version check failed." +exit $? diff --git a/rex.project/x86_64/environments/dependencies.env.bash b/rex.project/x86_64/environments/dependencies.env.bash new file mode 100755 index 0000000..49cb81c --- /dev/null +++ b/rex.project/x86_64/environments/dependencies.env.bash @@ -0,0 +1,47 @@ +#!/bin/bash +source ./project_config.sh + +TERM=xterm-256color +COLORTERM=truecolor +LC_ALL=C + +function echofail() { + echo + echo "FAILED: $1" + echo + exit 1 +} + +ver_check() +{ + if ! type -p $1 &>/dev/null; then + echo "ERROR: Cannot find $1"; return 1; + fi + v=$($1 --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1 ) + if printf '%s\n' $2 $v | sort --version-sort --check &>/dev/null; then + printf "OK: %-9s %-6s >= $2\n" "$1" "$v"; return 0; + else + printf "ERROR: %-9s is TOO OLD ($2 or later required)\n" "$1"; + return 1; + fi +} + +ver_kernel() +{ + kver=$(uname -r | grep -E -o '^[0-9\.]+') + if printf '%s\n' $1 $kver | sort --version-sort --check &>/dev/null; then + printf "OK: Linux Kernel $kver >= $1\n"; + return 0; + else + printf "ERROR: Linux Kernel ($kver) is TOO OLD ($1 or later required)\n" "$kver"; + return 1; + fi +} + +alias_check() { + if $1 --version 2>&1 | grep -qi $2; then + printf "OK: %-4s is $2\n" "$1"; + else + printf "ERROR: %-4s is NOT $2\n" "$1"; + fi +} diff --git a/rex.project/x86_64/plans/dependencies.plan b/rex.project/x86_64/plans/dependencies.plan new file mode 100644 index 0000000..1daaf16 --- /dev/null +++ b/rex.project/x86_64/plans/dependencies.plan @@ -0,0 +1,15 @@ +{ + "plan": + [ + { + "name": "coreutils version check", + "dependencies": [ null ], + "comment": "check bash version" + }, + { + "name": "bash version check", + "dependencies": [ null ], + "comment": "check bash version" + } + ] +} diff --git a/rex.project/x86_64/units/dependencies.units b/rex.project/x86_64/units/dependencies.units new file mode 100644 index 0000000..72d6e4b --- /dev/null +++ b/rex.project/x86_64/units/dependencies.units @@ -0,0 +1,40 @@ +{ + "units": [ + { + "name": "bash version check", + "target": "components/dependencies/bash.bash 3.2", + "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": "bagira", + "group": "bagira", + "supply_environment": true, + "environment": "environments/dependencies.env.bash" + }, + { + "name": "coreutils version check", + "target": "components/dependencies/coreutils.bash 7.0", + "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": "bagira", + "group": "bagira", + "supply_environment": true, + "environment": "environments/dependencies.env.bash" + } + ] +}