summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Gabaldon <igabaldon@inetol.net>2025-05-12 10:36:04 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-05-12 17:11:35 +0200
commit64a5b6920f1fd386d5ec8bce575b2ea0c82b2572 (patch)
tree9604bed5a7accda71f2becf41116cc3f5afa135e
parent346d7fe0192ea180552adbd2877dc13b3dd4050e (diff)
[mod] lib_sxng_container.sh use required_commands() helper
Suggested-by: @return42 https://github.com/searxng/searxng/pull/4764#discussion_r2083564489
-rw-r--r--utils/lib_sxng_container.sh32
1 files changed, 8 insertions, 24 deletions
diff --git a/utils/lib_sxng_container.sh b/utils/lib_sxng_container.sh
index b3f84594f..1df9ef358 100644
--- a/utils/lib_sxng_container.sh
+++ b/utils/lib_sxng_container.sh
@@ -19,24 +19,14 @@ container.build() {
local variant
local platform
- # Check if git is installed
- if ! command -v git &>/dev/null; then
- die 1 "Git is not installed"
- fi
+ required_commands git
# Check if podman or docker is installed
- if [ "$1" = "docker" ]; then
- if command -v docker &>/dev/null; then
- container_engine="docker"
- else
- die 1 "Docker is not installed"
- fi
- elif [ "$1" = "podman" ]; then
- if command -v podman &>/dev/null; then
- container_engine="podman"
- else
- die 1 "Podman is not installed"
+ if [ "$1" = "podman" ] || [ "$1" = "docker" ]; then
+ if ! command -v "$1" &>/dev/null; then
+ die 42 "$1 is not installed"
fi
+ container_engine="$1"
else
# If no explicit engine is passed, prioritize podman over docker
if command -v podman &>/dev/null; then
@@ -44,7 +34,7 @@ container.build() {
elif command -v docker &>/dev/null; then
container_engine="docker"
else
- die 1 "Podman/Docker is not installed"
+ die 42 "no compatible container engine is installed (podman or docker)"
fi
fi
info_msg "Selected engine: $container_engine"
@@ -168,10 +158,7 @@ container.test() {
die 1 "This command is intended to be run in GitHub Actions"
fi
- # Check if podman is installed
- if ! command -v podman &>/dev/null; then
- die 1 "podman is not installed"
- fi
+ required_commands podman
# Setup arch specific
case $parch in
@@ -234,10 +221,7 @@ container.push() {
die 1 "This command is intended to be run in GitHub Actions"
fi
- # Check if podman is installed
- if ! command -v podman &>/dev/null; then
- die 1 "podman is not installed"
- fi
+ required_commands podman
for arch in "${release_archs[@]}"; do
case $arch in