From 223712d36cb4d421a7532f59fbad7b9aa1f6aa3b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 16 Dec 2024 18:25:24 +0100 Subject: [PATCH] common: implement an explicit preference order in sambacc installation this explicitly implements a preference order for sambacc custom installation sources like so: local repo -> rpm -> wheeel -> copr. It makes the output a bit more verbose while at it. Signed-off-by: Michael Adam --- images/common/install-sambacc-common.sh | 56 +++++++++++++++++-------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/images/common/install-sambacc-common.sh b/images/common/install-sambacc-common.sh index bccdb26b..42f9ff55 100644 --- a/images/common/install-sambacc-common.sh +++ b/images/common/install-sambacc-common.sh @@ -31,26 +31,48 @@ install_sambacc() { local action=install-from-copr-repo - if [ "${#wheels[@]}" -gt 1 ]; then - echo "more than one wheel file found" - exit 1 - elif [ "${#wheels[@]}" -eq 1 ]; then - action=install-wheel + local source_found=0 + if [ "${#wheels[@]}" -gt 0 ]; then + echo "INFO: wheel found" + if [ "${#wheels[@]}" -gt 1 ]; then + echo "ERROR: more than one wheel file found" + exit 1 + elif [ "${#wheels[@]}" -eq 1 ]; then + echo "sambacc wheel found. Installing wheel." + action=install-wheel + source_found=1 + fi fi - - if [ "${#rpmfiles[@]}" -gt 1 ]; then - echo "more than one sambacc rpm file found" - exit 1 - elif [ "${#rpmfiles[@]}" -eq 1 ]; then - action=install-rpm + if [ "${#rpmfiles[@]}" -gt 0 ]; then + echo "INFO: rpm file found" + if [ "${#rpmfiles[@]}" -gt 1 ]; then + echo "ERROR: more than one sambacc rpm file found" + exit 1 + elif [ "${#rpmfiles[@]}" -eq 1 ]; then + echo "sambacc rpm found. preferring rpm install." + action=install-rpm + source_found=1 + fi fi - - if [ "${#repofiles[@]}" -gt 1 ]; then - echo "more than one repo file found" - exit 1 - elif [ "${#repofiles[@]}" -eq 1 ]; then - action=install-from-repo + if [ "${#repofiles[@]}" -gt 0 ]; then + echo "INFO: repo file found" + if [ "${#repofiles[@]}" -gt 1 ]; then + echo "ERROR: more than one repo file found" + exit 1 + elif [ "${#repofiles[@]}" -eq 1 ]; then + echo "sambacc repo file found. preferring install from local yum repo." + action=install-from-repo + source_found=1 + fi fi + if [ "${source_found}" = "0" ]; then + echo "INFO: no local sambacc installation source found. falling back to copr install." + action=install-from-copr-repo + fi + + echo "INFO: selected installation method: '${action}'" + + if [ -z "${DEFAULT_JSON_FILE}" ]; then echo "DEFAULT_JSON_FILE value unset"