basic version checking

master
Chris Punches 2024-02-10 09:14:54 -05:00
parent 5ddeaeeacb
commit c0ef3d4bf6
28 changed files with 727 additions and 17 deletions

View File

@ -4,7 +4,10 @@ set -u
export LC_ALL=C export LC_ALL=C
expected_version="$1" expected_version="$1"
real_name="bash"
app="bash" app="bash"
ver_check $app $expected_version || echofail "$app $expected_version check failed." ver_check $real_name $app $expected_version || \
echofail "$real_name $expected_version check failed."
exit $? exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="binutils"
app="ld"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="bison"
app="bison"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -4,7 +4,8 @@ set -u
export LC_ALL=C export LC_ALL=C
expected_version="$1" expected_version="$1"
real_name="coreutils"
app="sort" app="sort"
ver_check $app $expected_version || echofail "$app $expected_version check failed." ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $? exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="diffutils"
app="diff"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="findutils"
app="find"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="GCC (G++)"
app="g++"
ver_check "$real_name" "$app" "$expected_version" || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="gawk"
app="gawk"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="coreutils"
app="sort"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="grep"
app="grep"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="gzip"
app="gzip"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="coreutils"
app="sort"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="m4"
app="m4"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="make"
app="make"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="patch"
app="patch"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="perl"
app="perl"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="python3"
app="python3"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -u
export LC_ALL=C
real_name="bison"
app="bison"
dialog \
--title "Install ${real_name}?" \
--backtitle "Requirements Remediations" \
--yesno "Do you want to install ${real_name} on the build host?" 7 60
response=$?
# this is distro-specific and distro-specific function routing should
# account for things like this
case $response in
0) dnf -y install $app; install_result=$?;;
1) echo "Canceled. You need $real_name to run this.";;
255) echo "Canceled. You need $real_name to run this.";;
esac
exit $install_result

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -u
export LC_ALL=C
real_name="patch"
app="patch"
dialog \
--title "Install ${real_name}?" \
--backtitle "Requirements Remediations" \
--yesno "Do you want to install ${real_name} on the build host?" 7 60
response=$?
# this is distro-specific and distro-specific function routing should
# account for things like this
case $response in
0) dnf -y install $app; install_result=$?;;
1) echo "Canceled. You need $real_name to run this.";;
255) echo "Canceled. You need $real_name to run this.";;
esac
exit $install_result

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -u
export LC_ALL=C
real_name="texinfo"
app="texinfo"
dialog \
--title "Install ${real_name}?" \
--backtitle "Requirements Remediations" \
--yesno "Do you want to install ${real_name} on the build host?" 7 60
response=$?
# this is distro-specific and distro-specific function routing should
# account for things like this
case $response in
0) dnf -y install $app; install_result=$?;;
1) echo "Canceled. You need $real_name to run this.";;
255) echo "Canceled. You need $real_name to run this.";;
esac
exit $install_result

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="sed"
app="sed"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="tar"
app="tar"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="texinfo"
app="texi2any"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -0,0 +1,11 @@
#!/bin/bash
set -u
export LC_ALL=C
expected_version="$1"
real_name="xz"
app="xz"
ver_check $real_name $app $expected_version || echofail "$real_name $expected_version check failed."
exit $?

View File

@ -14,15 +14,19 @@ function echofail() {
ver_check() ver_check()
{ {
if ! type -p $1 &>/dev/null; then if ! type -p $2 &>/dev/null; then
echo "ERROR: Cannot find $1"; return 1; echo "ERROR: Cannot find $2 ($1)"
return 1
fi 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 v=$($2 --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1)
printf "OK: %-9s %-6s >= $2\n" "$1" "$v"; return 0;
if printf '%s\n' $3 $v | sort --version-sort --check &>/dev/null; then
printf "OK: %-9s %-6s >= $3\n" "$1" "$v"
return 0
else else
printf "ERROR: %-9s is TOO OLD ($2 or later required)\n" "$1"; printf "ERROR: %-9s is TOO OLD ($3 or later required)\n" "$1"
return 1; return 1
fi fi
} }

View File

@ -2,14 +2,84 @@
"plan": "plan":
[ [
{ {
"name": "coreutils version check", "name": "bash version check",
"dependencies": [ null ], "dependencies": [ null ]
"comment": "check bash version"
}, },
{ {
"name": "bash version check", "name": "coreutils version check",
"dependencies": [ null ], "dependencies": [ null ]
"comment": "check bash version" },
{
"name": "binutils version check",
"dependencies": [ null ]
},
{
"name": "bison version check",
"dependencies": [ null ]
},
{
"name": "diffutils version check",
"dependencies": [ null ]
},
{
"name": "findutils version check",
"dependencies": [ null ]
},
{
"name": "gawk version check",
"dependencies": [ null ]
},
{
"name": "GCC version check",
"dependencies": [ null ]
},
{
"name": "g++ version check",
"dependencies": [ null ]
},
{
"name": "grep version check",
"dependencies": [ null ]
},
{
"name": "gzip version check",
"dependencies": [ null ]
},
{
"name": "m4 version check",
"dependencies": [ null ]
},
{
"name": "make version check",
"dependencies": [ null ]
},
{
"name": "patch version check",
"dependencies": [ null ]
},
{
"name": "perl version check",
"dependencies": [ null ]
},
{
"name": "python3 version check",
"dependencies": [ null ]
},
{
"name": "sed version check",
"dependencies": [ null ]
},
{
"name": "tar version check",
"dependencies": [ null ]
},
{
"name": "texinfo version check",
"dependencies": [ null ]
},
{
"name": "xz version check",
"dependencies": [ null ]
} }
] ]
} }

View File

@ -35,6 +35,348 @@
"group": "bagira", "group": "bagira",
"supply_environment": true, "supply_environment": true,
"environment": "environments/dependencies.env.bash" "environment": "environments/dependencies.env.bash"
},
{
"name": "binutils version check",
"target": "components/dependencies/binutils.bash 2.13.1",
"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": "bison version check",
"target": "components/dependencies/bison.bash 2.7",
"is_shell_command": true,
"shell_definition": "bash",
"force_pty": true,
"set_working_directory": false,
"working_directory": "",
"rectify": true,
"rectifier": "components/dependencies/rectify_bison.bash",
"active": true,
"required": true,
"set_user_context": true,
"user": "root",
"group": "root",
"supply_environment": true,
"environment": "environments/dependencies.env.bash"
},
{
"name": "diffutils version check",
"target": "components/dependencies/diffutils.bash 2.8.1",
"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": "findutils version check",
"target": "components/dependencies/findutils.bash 2.8.1",
"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": "gawk version check",
"target": "components/dependencies/gawk.bash 4.0.1",
"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": "GCC version check",
"target": "components/dependencies/gcc.bash 5.1",
"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": "g++ version check",
"target": "components/dependencies/g++.bash 5.1",
"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": "grep version check",
"target": "components/dependencies/grep.bash 2.5.1a",
"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": "gzip version check",
"target": "components/dependencies/gzip.bash 1.3.12",
"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": "m4 version check",
"target": "components/dependencies/m4.bash 1.4.10",
"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": "make version check",
"target": "components/dependencies/make.bash 4.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"
},
{
"name": "patch version check",
"target": "components/dependencies/patch.bash 2.5.4",
"is_shell_command": true,
"shell_definition": "bash",
"force_pty": true,
"set_working_directory": false,
"working_directory": "",
"rectify": true,
"rectifier": "components/dependencies/rectify_patch.bash",
"active": true,
"required": true,
"set_user_context": true,
"user": "root",
"group": "root",
"supply_environment": true,
"environment": "environments/dependencies.env.bash"
},
{
"name": "perl version check",
"target": "components/dependencies/perl.bash 5.8.8",
"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": "python3 version check",
"target": "components/dependencies/python3.bash 3.4",
"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": "sed version check",
"target": "components/dependencies/sed.bash 4.1.5",
"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": "tar version check",
"target": "components/dependencies/tar.bash 1.22",
"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": "texinfo version check",
"target": "components/dependencies/texinfo.bash 5.0",
"is_shell_command": true,
"shell_definition": "bash",
"force_pty": true,
"set_working_directory": false,
"working_directory": "",
"rectify": true,
"rectifier": "components/dependencies/rectify_texinfo.bash",
"active": true,
"required": true,
"set_user_context": true,
"user": "root",
"group": "root",
"supply_environment": true,
"environment": "environments/dependencies.env.bash"
},
{
"name": "xz version check",
"target": "components/dependencies/xz.bash 5.0.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"
},
{
"name": "kernel version check",
"target": "components/dependencies/kernel.bash 4.14",
"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"
} }
] ]
} }

View File

@ -5,7 +5,7 @@
"target": "components/stage1/welcome.bash", "target": "components/stage1/welcome.bash",
"is_shell_command": true, "is_shell_command": true,
"shell_definition": "bash", "shell_definition": "bash",
"force_pty": true, "force_pty": false,
"set_working_directory": false, "set_working_directory": false,
"working_directory": "", "working_directory": "",
"rectify": false, "rectify": false,