Skip to content
Permalink
Browse files

feat(install): refactor check dependencies (#2708)

* feat: replace lib32tinfo5 with libtinfo5:i386

* dependency refactor and check

refactored check_deps and corrected some incorrect dependencies

* dependency refactor and check

* apt-get back to apt

* further code refactor

* improve messages for check_deps
  • Loading branch information
dgibbs64 committed Mar 10, 2020
1 parent 0af1f5e commit 4b063636043feb0350da52d65f16b11ab5b2404f
Showing with 92 additions and 45 deletions.
  1. +61 −45 lgsm/functions/check_deps.sh
  2. +29 −0 lgsm/functions/command_dev_detect_deps.sh
  3. +2 −0 lgsm/functions/command_dev_detect_ldd.sh
@@ -26,30 +26,30 @@ fn_install_mono_repo(){
echo -en " \r"
if [ "${distroid}" == "ubuntu" ]; then
if [ "${distroversion}" == "18.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "16.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-get install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-xenial main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-xenial main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "14.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-get install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-trusty main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-trusty main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
else
fn_print_warn_nl "Installing Mono repository"
fn_print_warn_nl "Installing Mono repository."
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
echo -e " https://www.mono-project.com/download/stable/#download-lin"
monoautoinstall="1"
fi
elif [ "${distroid}" == "debian" ]; then
if [ "${distroversion}" == "10" ]; then
cmd="sudo apt-get install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-buster main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
cmd="sudo apt install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-buster main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "9" ]; then
cmd="sudo apt-get install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-stretch main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
cmd="sudo apt install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-stretch main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
elif [ "${distroversion}" == "8" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt-get install apt-transport-https;echo 'deb https://download.mono-project.com/repo/debian stable-jessie main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt-get update"
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https;echo 'deb https://download.mono-project.com/repo/debian stable-jessie main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval "${cmd}"
else
echo -e "Mono auto install not available for ${distroname}"
@@ -91,11 +91,11 @@ fn_install_mono_repo(){
fi
fi
else
fn_print_information_nl "Installing Mono repository"
fn_print_information_nl "Installing Mono repository."
echo -e ""
fn_print_warning_nl "$(whoami) does not have sudo access. Manually install Mono repository."
fn_script_log_warn "$(whoami) does not have sudo access. Manually install Mono repository."
echo -e " Follow instructions on mono site to install the latest version of Mono."
echo -e "* Follow instructions on mono site to install the latest version of Mono."
echo -e " https://www.mono-project.com/download/stable/#download-lin"
fi
fi
@@ -105,7 +105,7 @@ fn_install_universe_repo(){
# Defensive coding - As this is an ubuntu only issue then check to make sure this fix is needed, and we are using ubuntu.
if [ "${jquniversemissing}" != "0" ]&&[ "${distroid}" == "ubuntu" ]; then
fn_print_warning_nl "Ubuntu 18.04.1 contains a bug which means the sources.list file does not populate with the Ubuntu universe repository."
fn_print_information_nl "Attempting to add Universe Repo"
fn_print_information_nl "Attempting to add universe repository."
if [ "${autoinstall}" == "1" ]; then
sudo -n true > /dev/null 2>&1
else
@@ -131,7 +131,8 @@ fn_install_universe_repo(){
else
fn_print_warning_nl "$(whoami) does not have sudo access. Manually add Universe repository."
fn_script_log_warn "$(whoami) does not have sudo access. Manually add Universe repository."
echo -e " Please run the following command as a user with sudo access, and re-run the installation"
echo -e "* Please run the following command as a user with sudo access, and re-run the installation"
echo -e ""
echo -e " sudo apt-add-repository universe"
fi
fi
@@ -228,7 +229,7 @@ fn_found_missing_deps(){
fn_install_mono_repo
fi
if [ -n "${jqstatus}" ]; then
fn_print_warning_nl "jq is not available in the ${distroname} repository"
fn_print_warning_nl "jq is not available in the ${distroname} repository."
echo -e " * https://docs.linuxgsm.com/requirements/jq"
fi
if [ "${autoinstall}" == "1" ]; then
@@ -247,7 +248,7 @@ fn_found_missing_deps(){
sleep 1
echo -en " \r"
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
cmd="echo steamcmd steam/question select \"I AGREE\" | sudo debconf-set-selections; echo steamcmd steam/license note '' | sudo debconf-set-selections; sudo dpkg --add-architecture i386; sudo apt-get update; sudo apt-get -y install ${array_deps_missing[@]}"
cmd="echo steamcmd steam/question select \"I AGREE\" | sudo debconf-set-selections; echo steamcmd steam/license note '' | sudo debconf-set-selections; sudo dpkg --add-architecture i386; sudo apt update; sudo apt -y install ${array_deps_missing[@]}"
eval "${cmd}"
elif [ "$(command -v dnf 2>/dev/null)" ]; then
cmd="sudo dnf -y install ${array_deps_missing[@]}"
@@ -257,13 +258,13 @@ fn_found_missing_deps(){
eval "${cmd}"
fi
if [ $? != 0 ]; then
fn_print_failure_nl "Unable to install dependencies"
fn_script_log_fatal "Unable to install dependencies"
fn_print_failure_nl "Unable to install dependencies."
fn_script_log_fatal "Unable to install dependencies."
echo -e ""
fn_print_warning_nl "Manually install dependencies."
fn_script_log_warn "Manually install dependencies."
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
echo -e " sudo dpkg --add-architecture i386; sudo apt-get update; sudo apt-get install ${array_deps_missing[@]}"
echo -e " sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[@]}"
elif [ "$(command -v dnf 2>/dev/null)" ]; then
echo -e " sudo dnf install ${array_deps_missing[@]}"
elif [ "$(command -v yum 2>/dev/null)" ]; then
@@ -276,19 +277,19 @@ fn_found_missing_deps(){
core_exit.sh
fi
else
fn_print_complete_nl "Install dependencies completed"
fn_script_log_pass "Install dependencies completed"
fn_print_complete_nl "Install dependencies completed."
fn_script_log_pass "Install dependencies completed."
fi
else
echo -e ""
fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies."
fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies."
echo -e ""
if [ "$(command -v dpkg-query 2>/dev/null)" ]; then
echo -e " sudo dpkg --add-architecture i386; sudo apt-get update; sudo apt-get install ${array_deps_missing[@]}"
echo -e "sudo dpkg --add-architecture i386; sudo apt update; sudo apt install ${array_deps_missing[@]}"
elif [ "$(command -v dnf 2>/dev/null)" ]; then
echo -e " sudo dnf install ${array_deps_missing[@]}"
echo -e "sudo dnf install ${array_deps_missing[@]}"
elif [ "$(command -v yum 2>/dev/null)" ]; then
echo -e " sudo yum install ${array_deps_missing[@]}"
echo -e "sudo yum install ${array_deps_missing[@]}"
fi
if [ "${steamcmdfail}" ]; then
echo -e ""
@@ -303,8 +304,8 @@ fn_found_missing_deps(){
fi
else
if [ "${function_selfname}" == "command_install.sh" ]; then
fn_print_information_nl "Required dependencies already installed"
fn_script_log_info "Required dependencies already installed"
fn_print_information_nl "Required dependencies already installed."
fn_script_log_info "Required dependencies already installed."
fi
fi
}
@@ -339,7 +340,7 @@ fn_deps_build_debian(){

# Game Specific requirements.

# Natural Selection 2 - x64 only.
# Natural Selection 2 (x64 only)
if [ "${shortname}" == "ns2" ]; then
array_deps_required+=( speex libtbb2 )
# NS2: Combat
@@ -348,14 +349,14 @@ fn_deps_build_debian(){
# 7 Days to Die
elif [ "${shortname}" == "sdtd" ]; then
array_deps_required+=( telnet expect )
# No More Room in Hell, Counter-Strike: Source and Garry's Mod
# No More Room in Hell, Counter-Strike: Source, Garry's Mod and Zombie Panic: Source
elif [ "${shortname}" == "nmrih" ]||[ "${shortname}" == "css" ]||[ "${shortname}" == "gmod" ]||[ "${shortname}" == "zps" ]; then
if [ "${arch}" == "x86_64" ]; then
array_deps_required+=( lib32tinfo5 )
else
array_deps_required+=( libtinfo5 )
fi
# Brainbread 2 ,Don't Starve Together & Team Fortress 2
# Brainbread 2, Don't Starve Together & Team Fortress 2
elif [ "${shortname}" == "bb2" ]||[ "${shortname}" == "dst" ]||[ "${shortname}" == "tf2" ]; then
array_deps_required+=( libcurl4-gnutls-dev:i386 )
if [ "${shortname}" == "tf2" ]; then
@@ -364,27 +365,24 @@ fn_deps_build_debian(){
# Battlefield: 1942
elif [ "${shortname}" == "bf1942" ]; then
array_deps_required+=( libncurses5:i386 )
# Call of Duty
elif [ "${shortname}" == "cod" ]||[ "${shortname}" == "coduo" ]||[ "${shortname}" == "cod2" ]; then
# Call of Duty & Medal of Honor: Allied Assault
elif [ "${shortname}" == "cod" ]||[ "${shortname}" == "coduo" ]||[ "${shortname}" == "cod2" ]||[ "${shortname}" == "mohaa" ]; then
array_deps_required+=( libstdc++5:i386 )
# Factorio
elif [ "${shortname}" == "fctr" ]; then
array_deps_required+=( xz-utils )
# Hurtword/Rust
elif [ "${shortname}" == "hw" ]||[ "${shortname}" == "rust" ]; then
array_deps_required+=( lib32z1 )
# Minecraft
elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "rw" ]||[ "${shortname}" == "pz" ]; then
# Minecraft, Rising World, Wurm
elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "rw" ]||[ "${shortname}" == "wurm" ]; then
javaversion=$(java -version 2>&1 | grep "version")
if [ "${javaversion}" ]; then
# Added for users using Oracle JRE to bypass the check.
javacheck=1
else
array_deps_required+=( openjdk-8-jre-headless )
array_deps_required+=( default-jre )
fi
# Medal of Honor: Allied Assault
elif [ "${shortname}" == "mohaa" ]; then
array_deps_required+=( libstdc++5:i386 )
# Onset
elif [ "${shortname}" == "onset" ]; then
array_deps_required+=( libmariadbclient-dev )
@@ -418,6 +416,9 @@ fn_deps_build_debian(){
# Unreal Tournament
elif [ "${shortname}" == "ut" ]; then
array_deps_required+=( unzip )
# Unturned
elif [ "${shortname}" == "unt" ]; then
array_deps_required+=( mono-complete )
# Wurm: Unlimited
elif [ "${shortname}" == "wurm" ]; then
array_deps_required+=( xvfb )
@@ -478,36 +479,50 @@ fn_deps_build_redhat(){
# Battlefield: 1942
elif [ "${shortname}" == "bf1942" ]; then
array_deps_required+=( ncurses-libs.i686 )
# Call of Duty
elif [ "${shortname}" == "cod" ]||[ "${shortname}" == "coduo" ]||[ "${shortname}" == "cod2" ]; then
# Call of Duty & Medal of Honor: Allied Assault
elif [ "${shortname}" == "cod" ]||[ "${shortname}" == "coduo" ]||[ "${shortname}" == "cod2" ]||[ "${shortname}" == "mohaa" ]; then
array_deps_required+=( compat-libstdc++-33.i686 )
# Factorio
elif [ "${shortname}" == "fctr" ]; then
array_deps_required+=( xz )
# Hurtword/Rust
elif [ "${shortname}" == "hw" ]||[ "${shortname}" == "rust" ]; then
array_deps_required+=( zlib-devel )
# Minecraft, Project Zomboid, Rising World
elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "rw" ]||[ "${shortname}" == "pz" ]; then
# Minecraft, Rising World, Wurm
elif [ "${shortname}" == "mc" ]||[ "${shortname}" == "rw" ]||[ "${shortname}" == "wurm" ]; then
javaversion=$(java -version 2>&1 | grep "version")
if [ "${javaversion}" ]; then
# Added for users using Oracle JRE to bypass the check.
javacheck=1
array_deps_required+=( rng-tools )
else
array_deps_required+=( java-1.8.0-openjdk rng-tools )
array_deps_required+=( java-11-openjdk )
fi
# Onset
# Onset
elif [ "${shortname}" == "onset" ]; then
array_deps_required+=( mariadb-connector-c )
# Project Zomboid
elif [ "${shortname}" == "pz" ]; then
if java -version 2>&1 | grep "version"; then
# Added for users using Oracle JRE to bypass the check.
javacheck=1
array_deps_required+=( rng-tools )
else
array_deps_required+=( java-11-openjdk rng-tools )
fi
# GoldenEye: Source
elif [ "${shortname}" == "ges" ]; then
array_deps_required+=( zlib.i686 openldap.i686 )
# Serious Sam 3: BFE
elif [ "${shortname}" == "ss3" ]; then
: # not compatible
elif [ "${shortname}" == "sven" ]; then
: # not compatible
# Unreal Engine
elif [ "${executable}" == "./ucc-bin" ]; then
#UT2K4
# UT2K4
if [ -f "${executabledir}/ut2004-bin" ]; then
array_deps_required+=( compat-libstdc++-33.i686 SDL.i686 bzip2 )
#UT99
# UT99
else
array_deps_required+=( SDL.i686 bzip2 )
fi
@@ -517,6 +532,7 @@ fn_deps_build_redhat(){
# Unturned
elif [ "${shortname}" == "unt" ]; then
array_deps_required+=( mono-complete )
# Wurm: Unlimited
elif [ "${shortname}" == "wurm" ]; then
array_deps_required+=( xorg-x11-server-Xvfb )
elif [ "${shortname}" == "pstbs" ]; then
@@ -548,5 +564,5 @@ if [ -f "/etc/debian_version" ]; then
elif [ -f "/etc/redhat-release" ]; then
fn_deps_build_redhat
else
fn_print_warning_nl "${distroname} dependency checking unavailable"
fn_print_warning_nl "${distroname} dependency checking unavailable."
fi
@@ -34,6 +34,10 @@ done

sort "${tmpdir}/.depdetect_readelf" |uniq >"${tmpdir}/.depdetect_readelf_uniq"

touch "${tmpdir}/.depdetect_centos_list"
touch "${tmpdir}/.depdetect_ubuntu_list"
touch "${tmpdir}/.depdetect_debian_list"

while read -r lib; do
echo -e "${lib}"
local libs_array=( libm.so.6 libc.so.6 libtcmalloc_minimal.so.4 libpthread.so.0 libdl.so.2 libnsl.so.1 libgcc_s.so.1 librt.so.1 ld-linux.so.2 libdbus-glib-1.so.2 libgio-2.0.so.0 libglib-2.0.so.0 libGL.so.1 libgobject-2.0.so.0 libnm-glib.so.4 libnm-util.so.2 )
@@ -128,6 +132,31 @@ while read -r lib; do
echo -e "libgconf2-4" >> "${tmpdir}/.depdetect_ubuntu_list"
echo -e "libgconf2-4" >> "${tmpdir}/.depdetect_debian_list"
libdetected=1
elif [ "${lib}" == "libz.so.1" ]; then
echo -e "zlib" >> "${tmpdir}/.depdetect_centos_list"
echo -e "zlib1g" >> "${tmpdir}/.depdetect_ubuntu_list"
echo -e "zlib1g" >> "${tmpdir}/.depdetect_debian_list"
libdetected=1
elif [ "${lib}" == "libatk-1.0.so.0" ]; then
echo -e "atk" >> "${tmpdir}/.depdetect_centos_list"
echo -e "libatk1.0-0" >> "${tmpdir}/.depdetect_ubuntu_list"
echo -e "libatk1.0-0" >> "${tmpdir}/.depdetect_debian_list"
libdetected=1
elif [ "${lib}" == "libcairo.so.2" ]; then
echo -e "cairo" >> "${tmpdir}/.depdetect_centos_list"
echo -e "libcairo2" >> "${tmpdir}/.depdetect_ubuntu_list"
echo -e "libcairo2" >> "${tmpdir}/.depdetect_debian_list"
libdetected=1
elif [ "${lib}" == "libfontconfig.so.1" ]; then
echo -e "fontconfig" >> "${tmpdir}/.depdetect_centos_list"
echo -e "libfontconfig1" >> "${tmpdir}/.depdetect_ubuntu_list"
echo -e "libfontconfig1" >> "${tmpdir}/.depdetect_debian_list"
libdetected=1
elif [ "${lib}" == "libfreetype.so.6" ]; then
echo -e "freetype" >> "${tmpdir}/.depdetect_centos_list"
echo -e "libfreetype6" >> "${tmpdir}/.depdetect_ubuntu_list"
echo -e "libfreetype6" >> "${tmpdir}/.depdetect_debian_list"
libdetected=1
fi

if [ "${libdetected}" != "1" ]; then
@@ -25,6 +25,8 @@ elif [ -f "${serverfiles}" ]; then
echo -e "${serverfiles}"
fi
echo -e ""
touch "${tmpdir}/detect_ldd.tmp"
touch "${tmpdir}/detect_ldd_not_found.tmp"

files=$(find "${serverfiles}" | wc -l)
find "${serverfiles}" -type f -print0 |

0 comments on commit 4b06363

Please sign in to comment.
You can’t perform that action at this time.