rectifiers for some deps

Chris Punches 2024-02-10 12:37:46 -05:00
parent c0ef3d4bf6
commit 8e19ee2c68
8 changed files with 160 additions and 3 deletions

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
app="awk"
expected_target="gawk"
sym_check $app $expected_target
exit $?

View File

@ -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

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
app="sh"
expected_target="bash"
sym_check $app $expected_target
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
app="yacc"
expected_target="bison"
sym_check $app $expected_target
exit $?

View File

@ -4,9 +4,6 @@ set -u
export LC_ALL=C export LC_ALL=C
echo
echo "Checking bash..."
bash --version | head -n1 | cut -d" " -f2-4
echo echo
echo "Checking /bin/sh path" echo "Checking /bin/sh path"

View File

@ -4,6 +4,8 @@ source ./project_config.sh
TERM=xterm-256color TERM=xterm-256color
COLORTERM=truecolor COLORTERM=truecolor
LC_ALL=C LC_ALL=C
PATH=${CROSSTOOLS_DIR}/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
function echofail() { function echofail() {
echo echo
@ -42,10 +44,35 @@ ver_kernel()
fi 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() { alias_check() {
if $1 --version 2>&1 | grep -qi $2; then if $1 --version 2>&1 | grep -qi $2; then
printf "OK: %-4s is $2\n" "$1"; printf "OK: %-4s is $2\n" "$1";
return 0;
else else
printf "ERROR: %-4s is NOT $2\n" "$1"; printf "ERROR: %-4s is NOT $2\n" "$1";
return 1;
fi fi
} }

View File

@ -80,6 +80,18 @@
{ {
"name": "xz version check", "name": "xz version check",
"dependencies": [ null ] "dependencies": [ null ]
},
{
"name": "awk-gawk check",
"dependencies": [ null ]
},
{
"name": "yacc-bison check",
"dependencies": [ null ]
},
{
"name": "sh-bash check",
"dependencies": [ null ]
} }
] ]
} }

View File

@ -377,6 +377,60 @@
"group": "bagira", "group": "bagira",
"supply_environment": true, "supply_environment": true,
"environment": "environments/dependencies.env.bash" "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"
} }
] ]
} }