From 69268ee6737da909a53f0e865dba62bb352917b0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 4 Sep 2021 22:47:34 +0100 Subject: [PATCH] impove dep checking logic for unsupported distros --- lgsm/functions/check_deps.sh | 22 ++++++++++++++-------- lgsm/functions/core_dl.sh | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 0d4784e1a..4dcd25238 100755 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -306,24 +306,30 @@ fn_deps_detector(){ info_distro.sh -if [ ! -f "${datadir}/${distroid}-${distroversion}.csv" ]; then +if [ ! -f "${tmpdir}/dependency-no-check.tmp" ]&&[ ! -f "${datadir}/${distroid}-${distroversion}.csv" ]; then + # Check that the disto dependency csv file exists and if it does download it. fn_check_file_github "lgsm/data" "${distroid}-${distroversion}.csv" fi -# Select Distro -if [ "${checkflag}" == "0" ]; then +# If the file successfully downloaded run the dependency check. +if [ -n "${checkflag}" ]||[ "${checkflag}" == "0" ]; then dependencyinstall=$(awk -F, '$1=="install" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") dependencyall=$(awk -F, '$1=="all" {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") dependencyshortname=$(awk -v shortname="$shortname" -F, '$1==shortname {$1=""; print $0}' "${datadir}/${distroid}-${distroversion}.csv") - # dev code - echo "${dependencyinstall}${dependencyall}${dependencyshortname}" - # Generate array of missing deps. array_deps_missing=() - array_deps_required=(${dependencyall} ${dependencyshortname}) fn_check_loop -else +# Warn the user that dependency checking is unavailable for their distro. +elif [ -n "${checkflag}" ]||[ "${checkflag}" != "0" ]; then fn_print_warning_nl "LinuxGSM dependency checking currently unavailable for ${distroname}." + # Prevent future dependency checking if unavailable for the distro. + echo "${version}" > "${tmpdir}/dependency-no-check.tmp" +elif [ -f "${tmpdir}/dependency-no-check.tmp" ]; then + # Allow LinuxGSM to try a dependency check if LinuxGSM has been recently updated. + nocheckversion=$(cat "${tmpdir}/dependency-no-check.tmp" ) + if [ "${version}" != "${nocheckversion}" ]; then + rm -f "${tmpdir:?}/dependency-no-check.tmp" + fi fi diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 7aa2a65ab..33b2b7120 100755 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -252,6 +252,7 @@ fn_fetch_trap(){ core_exit.sh } +# Will check a file exists and download it. Will not exit if fails to download. fn_check_file(){ remote_fileurl="${1}" remote_fileurl_backup="${2}"