Skip to content

Commit

Permalink
Update linux script to check for libc version, don't support python3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
julianneswinoga committed Sep 19, 2022
1 parent 20ed69f commit 099bb9c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion OATFWGUI/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.4'
__version__ = '0.0.5'
40 changes: 38 additions & 2 deletions scripts/OATFWGUI_Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ function list_include_item {
fi
}

function check_ldd_version {
local LIBC_VER_RAW=$(ldd --version | head -1)
echo "LIBC version: $LIBC_VER_RAW"
if ! [[ $LIBC_VER_RAW =~ ([[:digit:]]+)\.([[:digit:]]+) ]]; then
echo "Could not match LIBC version! Not sure what's going on."
return 1
fi
local LIBC_VER_ALL=${BASH_REMATCH[0]}
local LIBC_VER_MAJ=${BASH_REMATCH[1]}
local LIBC_VER_MIN=${BASH_REMATCH[2]}

# Only support libc 2
if ! list_include_item '2' $LIBC_VER_MAJ; then
echo "LIBC major version $LIBC_VER_MAJ ($LIBC_VER_ALL) is not supported"
return 1
fi
# Only support >= 28
if [ "$LIBC_VER_MIN" -lt 28 ]; then
echo "LIBC minor version $LIBC_VER_MIN ($LIBC_VER_ALL) is not supported"
return 1
fi
return 0
}

function check_py_version {
local PY_VER_RAW=$($PYTHON --version)
echo "Python version: $PY_VER_RAW"
Expand All @@ -31,15 +55,23 @@ function check_py_version {
echo "Python major version $PY_VER_MAJ ($PY_VER_ALL) is not supported"
return 1
fi
# Only support 3.6+
if ! list_include_item '6 7 8 9 10 11' $PY_VER_MIN; then
# Only support 3.7+
if ! list_include_item '7 8 9 10 11' $PY_VER_MIN; then
echo "Python minor version $PY_VER_MIN ($PY_VER_ALL) is not supported"
return 1
fi
return 0
}

function set_supported_python_path {
if [ -n "${PYTHON+x}" ]; then
# PYTHON is being set from the CLI
echo "PYTHON overridden: $PYTHON"
if check_py_version; then
return 0
fi
echo "Overridden PYTHON not supported. Checking system python versions."
fi
# Check the that one of (python, python3) is supported
if ! command -v python3 > /dev/null; then
# ok, python3 not available. Try python
Expand Down Expand Up @@ -70,6 +102,10 @@ function set_supported_python_path {
}

# Main script logic
if ! check_ldd_version; then
echo "Unsupported LIBC version, sorry :/"
exit 1
fi
set_supported_python_path # This sets $PYTHON
echo "Python command is $PYTHON"
# check venv is available
Expand Down

0 comments on commit 099bb9c

Please sign in to comment.