[mod] lib_sxng_container.sh use required_commands() helper
Suggested-by: @return42 https://github.com/searxng/searxng/pull/4764#discussion_r2083564489
This commit is contained in:
		
							parent
							
								
									346d7fe019
								
							
						
					
					
						commit
						64a5b6920f
					
				| @ -19,24 +19,14 @@ container.build() { | |||||||
|     local variant |     local variant | ||||||
|     local platform |     local platform | ||||||
| 
 | 
 | ||||||
|     # Check if git is installed |     required_commands git | ||||||
|     if ! command -v git &>/dev/null; then |  | ||||||
|         die 1 "Git is not installed" |  | ||||||
|     fi |  | ||||||
| 
 | 
 | ||||||
|     # Check if podman or docker is installed |     # Check if podman or docker is installed | ||||||
|     if [ "$1" = "docker" ]; then |     if [ "$1" = "podman" ] || [ "$1" = "docker" ]; then | ||||||
|         if command -v docker &>/dev/null; then |         if ! command -v "$1" &>/dev/null; then | ||||||
|             container_engine="docker" |             die 42 "$1 is not installed" | ||||||
|         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" |  | ||||||
|         fi |         fi | ||||||
|  |         container_engine="$1" | ||||||
|     else |     else | ||||||
|         # If no explicit engine is passed, prioritize podman over docker |         # If no explicit engine is passed, prioritize podman over docker | ||||||
|         if command -v podman &>/dev/null; then |         if command -v podman &>/dev/null; then | ||||||
| @ -44,7 +34,7 @@ container.build() { | |||||||
|         elif command -v docker &>/dev/null; then |         elif command -v docker &>/dev/null; then | ||||||
|             container_engine="docker" |             container_engine="docker" | ||||||
|         else |         else | ||||||
|             die 1 "Podman/Docker is not installed" |             die 42 "no compatible container engine is installed (podman or docker)" | ||||||
|         fi |         fi | ||||||
|     fi |     fi | ||||||
|     info_msg "Selected engine: $container_engine" |     info_msg "Selected engine: $container_engine" | ||||||
| @ -168,10 +158,7 @@ container.test() { | |||||||
|         die 1 "This command is intended to be run in GitHub Actions" |         die 1 "This command is intended to be run in GitHub Actions" | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     # Check if podman is installed |     required_commands podman | ||||||
|     if ! command -v podman &>/dev/null; then |  | ||||||
|         die 1 "podman is not installed" |  | ||||||
|     fi |  | ||||||
| 
 | 
 | ||||||
|     # Setup arch specific |     # Setup arch specific | ||||||
|     case $parch in |     case $parch in | ||||||
| @ -234,10 +221,7 @@ container.push() { | |||||||
|         die 1 "This command is intended to be run in GitHub Actions" |         die 1 "This command is intended to be run in GitHub Actions" | ||||||
|     fi |     fi | ||||||
| 
 | 
 | ||||||
|     # Check if podman is installed |     required_commands podman | ||||||
|     if ! command -v podman &>/dev/null; then |  | ||||||
|         die 1 "podman is not installed" |  | ||||||
|     fi |  | ||||||
| 
 | 
 | ||||||
|     for arch in "${release_archs[@]}"; do |     for arch in "${release_archs[@]}"; do | ||||||
|         case $arch in |         case $arch in | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ivan Gabaldon
						Ivan Gabaldon