Bläddra i källkod

feat(details): show missing dependencies in details and post-details (#5041)

* feat(details): show missing dependencies in details and post-details

details and post-details now list any missing dependencies in the Distro
Details section, so they end up in the termbin output shared for support.

check_deps.sh gains a check-only mode for DETAILS and POST-DETAILS. In
that mode it builds array_deps_missing but never calls
fn_install_missing_deps, so neither command will try to install packages
or add Mono or .NET repositories via sudo. The unsupported distro warnings
and exits are also skipped so a game blocked on the current distro can
still produce details for support, and the "dependency checking
unavailable" warning and its no-check tmp file are left to the commands
that install. When no dependency CSV exists for the distro, details shows
that dependency checking is unavailable instead.

post-details is added to the commands that run check_deps.sh.

Closes #1281

* refactor(details): label missing dependencies line Dependencies

* refactor(details): label line Missing dependencies
Daniel Gibbs 2 dagar sedan
förälder
incheckning
8c5441022c
3 ändrade filer med 38 tillägg och 21 borttagningar
  1. 1 1
      lgsm/modules/check.sh
  2. 31 20
      lgsm/modules/check_deps.sh
  3. 6 0
      lgsm/modules/info_messages.sh

+ 1 - 1
lgsm/modules/check.sh

@@ -54,7 +54,7 @@ for allowed_command in "${allowed_commands_array[@]}"; do
 	fi
 	fi
 done
 done
 
 
-allowed_commands_array=(BACKUP DEBUG DETAILS RESTART START UPDATE WORKSHOP-UPDATE)
+allowed_commands_array=(BACKUP DEBUG DETAILS POST-DETAILS RESTART START UPDATE WORKSHOP-UPDATE)
 for allowed_command in "${allowed_commands_array[@]}"; do
 for allowed_command in "${allowed_commands_array[@]}"; do
 	if [ "${allowed_command}" == "${commandname}" ]; then
 	if [ "${allowed_command}" == "${commandname}" ]; then
 		check_deps.sh
 		check_deps.sh

+ 31 - 20
lgsm/modules/check_deps.sh

@@ -264,7 +264,9 @@ fn_check_loop() {
 	done
 	done
 
 
 	# user will be informed of any missing dependencies.
 	# user will be informed of any missing dependencies.
-	fn_install_missing_deps
+	if [ "${depcheckonly}" != "1" ]; then
+		fn_install_missing_deps
+	fi
 }
 }
 
 
 # Checks if dependency is installed or not.
 # Checks if dependency is installed or not.
@@ -375,6 +377,10 @@ fn_deps_detector() {
 	fi
 	fi
 }
 }
 
 
+if [ "${commandname}" == "DETAILS" ] || [ "${commandname}" == "POST-DETAILS" ]; then
+	depcheckonly="1"
+fi
+
 if [ "${commandname}" == "INSTALL" ]; then
 if [ "${commandname}" == "INSTALL" ]; then
 	if [ "$(whoami)" == "root" ]; then
 	if [ "$(whoami)" == "root" ]; then
 		echo -e ""
 		echo -e ""
@@ -391,29 +397,31 @@ fi
 
 
 info_distro.sh
 info_distro.sh
 
 
-# Will warn user if their distro is no longer supported by the vendor.
-if [ -n "${distrosupport}" ]; then
-	if [ "${distrosupport}" == "unsupported" ]; then
-		fn_print_warning_nl "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
-		fn_script_log_warn "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
+if [ "${depcheckonly}" != "1" ]; then
+	# Will warn user if their distro is no longer supported by the vendor.
+	if [ -n "${distrosupport}" ]; then
+		if [ "${distrosupport}" == "unsupported" ]; then
+			fn_print_warning_nl "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
+			fn_script_log_warn "${distroname} is no longer supported by the vendor or LinuxGSM. Upgrading is recommended."
+		fi
 	fi
 	fi
-fi
 
 
-# These titles are only supported up to Ubuntu 20.04 and Debian 11.
-if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "gt" "20.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "gt" "11"; }; then
-	if [ "${shortname}" == "onset" ] || [ "${shortname}" == "btl" ]; then
-		fn_print_failure_nl "${gamename} is not supported on ${distroname} (requires Ubuntu <= 20.04 or Debian <= 11)."
-		fn_script_log_fail "${gamename} is not supported on ${distroname}."
-		core_exit.sh
+	# These titles are only supported up to Ubuntu 20.04 and Debian 11.
+	if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "gt" "20.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "gt" "11"; }; then
+		if [ "${shortname}" == "onset" ] || [ "${shortname}" == "btl" ]; then
+			fn_print_failure_nl "${gamename} is not supported on ${distroname} (requires Ubuntu <= 20.04 or Debian <= 11)."
+			fn_script_log_fail "${gamename} is not supported on ${distroname}."
+			core_exit.sh
+		fi
 	fi
 	fi
-fi
 
 
-# Vintage Story tracks newer .NET runtimes; older distro releases may not ship required packages.
-if [ "${shortname}" == "vints" ]; then
-	if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "lt" "24.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "lt" "12"; } || [ "${distroid}" == "centos" ] || [ "${distroid}" == "rhel" ] || [ "${distroid}" == "rocky" ] || [ "${distroid}" == "almalinux" ]; then
-		fn_print_warning_nl "${gamename} may require newer .NET runtimes than ${distroname} provides."
-		echo -e "If startup fails due to missing .NET runtime, upgrading to Ubuntu 24.04+ or Debian 12+ is recommended."
-		fn_script_log_warn "${gamename} may require newer .NET runtimes than ${distroname} provides."
+	# Vintage Story tracks newer .NET runtimes; older distro releases may not ship required packages.
+	if [ "${shortname}" == "vints" ]; then
+		if { [ "${distroid}" == "ubuntu" ] && dpkg --compare-versions "${distroversion}" "lt" "24.04"; } || { [ "${distroid}" == "debian" ] && dpkg --compare-versions "${distroversion}" "lt" "12"; } || [ "${distroid}" == "centos" ] || [ "${distroid}" == "rhel" ] || [ "${distroid}" == "rocky" ] || [ "${distroid}" == "almalinux" ]; then
+			fn_print_warning_nl "${gamename} may require newer .NET runtimes than ${distroname} provides."
+			echo -e "If startup fails due to missing .NET runtime, upgrading to Ubuntu 24.04+ or Debian 12+ is recommended."
+			fn_script_log_warn "${gamename} may require newer .NET runtimes than ${distroname} provides."
+		fi
 	fi
 	fi
 fi
 fi
 
 
@@ -441,6 +449,9 @@ if [ -f "${datadir}/${distroid}-${distroversioncsv}.csv" ]; then
 	IFS=" " read -r -a array_deps_required <<< "$(echo "${array_deps_required[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
 	IFS=" " read -r -a array_deps_required <<< "$(echo "${array_deps_required[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
 
 
 	fn_check_loop
 	fn_check_loop
+elif [ "${depcheckonly}" == "1" ]; then
+	# shellcheck disable=SC2034 # Used by info_messages.sh.
+	depcheckunavailable="1"
 # Warn the user that dependency checking is unavailable for their distro.
 # Warn the user that dependency checking is unavailable for their distro.
 elif [ "${commandname}" == "INSTALL" ] || [ -n "${checkflag}" ] && [ "${checkflag}" != "0" ]; then
 elif [ "${commandname}" == "INSTALL" ] || [ -n "${checkflag}" ] && [ "${checkflag}" != "0" ]; then
 	fn_print_warning_nl "LinuxGSM dependency checking currently unavailable for ${distroname}."
 	fn_print_warning_nl "LinuxGSM dependency checking currently unavailable for ${distroname}."

+ 6 - 0
lgsm/modules/info_messages.sh

@@ -111,6 +111,7 @@ fn_info_messages_distro() {
 	# Uptime:    16d, 5h, 18m
 	# Uptime:    16d, 5h, 18m
 	# tmux:      tmux 3.0a
 	# tmux:      tmux 3.0a
 	# glibc:     2.31
 	# glibc:     2.31
+	# Missing dependencies: lib32gcc-s1 steamcmd
 
 
 	echo -e ""
 	echo -e ""
 	echo -e "${bold}${lightyellow}Distro Details${default}"
 	echo -e "${bold}${lightyellow}Distro Details${default}"
@@ -128,6 +129,11 @@ fn_info_messages_distro() {
 		if [ -n "${javaram}" ]; then
 		if [ -n "${javaram}" ]; then
 			echo -e "${lightblue}Java:\t${default}${javaversion}"
 			echo -e "${lightblue}Java:\t${default}${javaversion}"
 		fi
 		fi
+		if [ "${#array_deps_missing[@]}" != "0" ]; then
+			echo -e "${lightblue}Missing dependencies:\t${red}${array_deps_missing[*]}${default}"
+		elif [ "${depcheckunavailable}" == "1" ]; then
+			echo -e "${lightblue}Missing dependencies:\t${default}dependency checking unavailable for ${distroname}"
+		fi
 	} | column -s $'\t' -t
 	} | column -s $'\t' -t
 }
 }