From df637acee41c1c69f54a60536a773f9c24f3daed Mon Sep 17 00:00:00 2001 From: "Stefano C. Coronado" Date: Sun, 29 Dec 2019 13:00:19 -0500 Subject: [PATCH] caught blind case if engine fails to build when both not installed --- pkg-install | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg-install b/pkg-install index f1cd745..bcfbfb2 100755 --- a/pkg-install +++ b/pkg-install @@ -48,19 +48,18 @@ ENTRYPOINT [\"/usr/bin/env\", \"{command}\"]" # check if either docker or podman are installed -docker_check = which("docker") +try: + if which("docker") is None: + print("Docker not installed, building with Podman") + engine = "podman" + elif which("podman") is None: + engine = "docker" + else: + print("Podman/Docker are not installed! Exiting...") + exit(1) -podman_check = which("podman") -if docker_check is None: - print("Docker not installed, building with Podman") - engine = "podman" -elif podman_check is None: - engine = "docker" -else: - print("Podman/Docker are not installed! Exiting...") + subprocess.run([engine, "build", "-t", command, "-"], input = dockerfile, encoding = 'UTF-8') +except FileNotFoundError: + print("An Error has occured while attempting to build the image.") exit(1) - - -subprocess.run([engine, "build", "-t", command, "-"], input = dockerfile, encoding = 'UTF-8') -