diff --git a/rex.project/x86_64/components/dependencies/awk-gawk.bash b/rex.project/x86_64/components/dependencies/awk-gawk.bash new file mode 100755 index 0000000..ab9a8d5 --- /dev/null +++ b/rex.project/x86_64/components/dependencies/awk-gawk.bash @@ -0,0 +1,11 @@ +#!/bin/bash +set -u + +export LC_ALL=C + +app="awk" +expected_target="gawk" + +sym_check $app $expected_target + +exit $? diff --git a/rex.project/x86_64/components/dependencies/rectify_yacc-bison.bash b/rex.project/x86_64/components/dependencies/rectify_yacc-bison.bash new file mode 100755 index 0000000..e08c4a2 --- /dev/null +++ b/rex.project/x86_64/components/dependencies/rectify_yacc-bison.bash @@ -0,0 +1,34 @@ +#!/bin/bash +set -u + +export LC_ALL=C + +app="yacc" +symlink_target="bison" + + +dialog \ + --title "Symlink '${app}' to '${symlink_target}'?" \ + --backtitle "Requirements Remediations" \ + --yesno "Do you want to Symlink ${app} to ${symlink_target}?" 7 60 + +response=$? + +# this is distro-specific and distro-specific function routing should +# account for things like this + +function symlink() { + ln -vs "$(which $2)" "$(dirname $(which $2))/$1" + return $? +} + +install_result=0 +case $response in + 0) symlink "$app" "$symlink_target"; install_result=$?;; + 1) echo "Canceled. You need $app pointing to $symlink_target to run this.";; + 255) echo "Canceled. You need $app pointing to $symlink_target to run this.";; +esac + + + +exit $install_result diff --git a/rex.project/x86_64/components/dependencies/sh-bash.bash b/rex.project/x86_64/components/dependencies/sh-bash.bash new file mode 100755 index 0000000..a40879c --- /dev/null +++ b/rex.project/x86_64/components/dependencies/sh-bash.bash @@ -0,0 +1,11 @@ +#!/bin/bash +set -u + +export LC_ALL=C + +app="sh" +expected_target="bash" + +sym_check $app $expected_target + +exit $? diff --git a/rex.project/x86_64/components/dependencies/yacc-bison.bash b/rex.project/x86_64/components/dependencies/yacc-bison.bash new file mode 100755 index 0000000..38e7f7d --- /dev/null +++ b/rex.project/x86_64/components/dependencies/yacc-bison.bash @@ -0,0 +1,11 @@ +#!/bin/bash +set -u + +export LC_ALL=C + +app="yacc" +expected_target="bison" + +sym_check $app $expected_target + +exit $? diff --git a/rex.project/x86_64/components/stage1/check_dependencies.bash b/rex.project/x86_64/components/stage1/check_dependencies.bash index 95f5b6b..c2138bd 100755 --- a/rex.project/x86_64/components/stage1/check_dependencies.bash +++ b/rex.project/x86_64/components/stage1/check_dependencies.bash @@ -4,9 +4,6 @@ set -u export LC_ALL=C -echo -echo "Checking bash..." -bash --version | head -n1 | cut -d" " -f2-4 echo echo "Checking /bin/sh path" diff --git a/rex.project/x86_64/environments/dependencies.env.bash b/rex.project/x86_64/environments/dependencies.env.bash index ffeccc5..250e1b7 100755 --- a/rex.project/x86_64/environments/dependencies.env.bash +++ b/rex.project/x86_64/environments/dependencies.env.bash @@ -4,6 +4,8 @@ source ./project_config.sh TERM=xterm-256color COLORTERM=truecolor LC_ALL=C +PATH=${CROSSTOOLS_DIR}/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin + function echofail() { echo @@ -42,10 +44,35 @@ ver_kernel() fi } +sym_check() { + # the name of the binary/symlink we're checking as it appears in PATH + app="$1" + + # the name of the binary we expect it to point to + expected_target="$2" + + # the basename of the target of the symlink (if it is one) + target="$(basename $(readlink -f $(which $app)))" + if [[ "$target" == "$expected_target" ]]; then + printf "OK:\t$app -> $expected_target\n"; + return 0; + else + if [[ "$target" == '' ]]; then + printf "ERROR: '$app' is not present on this system.\n"; + return 1; + else + printf "ERROR: '$app' points to '$target' instead of '$expected_target'.\n" + return 1; + fi + fi +} + alias_check() { if $1 --version 2>&1 | grep -qi $2; then printf "OK: %-4s is $2\n" "$1"; + return 0; else printf "ERROR: %-4s is NOT $2\n" "$1"; + return 1; fi } diff --git a/rex.project/x86_64/plans/dependencies.plan b/rex.project/x86_64/plans/dependencies.plan index c115050..f11cb24 100644 --- a/rex.project/x86_64/plans/dependencies.plan +++ b/rex.project/x86_64/plans/dependencies.plan @@ -80,6 +80,18 @@ { "name": "xz version check", "dependencies": [ null ] + }, + { + "name": "awk-gawk check", + "dependencies": [ null ] + }, + { + "name": "yacc-bison check", + "dependencies": [ null ] + }, + { + "name": "sh-bash check", + "dependencies": [ null ] } ] } diff --git a/rex.project/x86_64/units/dependencies.units b/rex.project/x86_64/units/dependencies.units index a6b8e75..efcdf79 100644 --- a/rex.project/x86_64/units/dependencies.units +++ b/rex.project/x86_64/units/dependencies.units @@ -377,6 +377,60 @@ "group": "bagira", "supply_environment": true, "environment": "environments/dependencies.env.bash" + }, + { + "name": "awk-gawk check", + "target": "components/dependencies/awk-gawk.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": "bagira", + "group": "bagira", + "supply_environment": true, + "environment": "environments/dependencies.env.bash" + }, + { + "name": "yacc-bison check", + "target": "components/dependencies/yacc-bison.bash", + "is_shell_command": true, + "shell_definition": "bash", + "force_pty": true, + "set_working_directory": false, + "working_directory": "", + "rectify": true, + "rectifier": "components/dependencies/rectify_yacc-bison.bash", + "active": true, + "required": true, + "set_user_context": true, + "user": "root", + "group": "root", + "supply_environment": true, + "environment": "environments/dependencies.env.bash" + }, + { + "name": "sh-bash check", + "target": "components/dependencies/sh-bash.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": "bagira", + "group": "bagira", + "supply_environment": true, + "environment": "environments/dependencies.env.bash" } ] }