diff --git a/build.sh b/build.sh index 99d2a82..373bc64 100755 --- a/build.sh +++ b/build.sh @@ -8,7 +8,22 @@ if [ -z "$1" ]; then exit fi -RUNNER="${XCPNG_OCI_RUNNER:-docker}" +RUNNER="" +if [ -n "$XCPNG_OCI_RUNNER" ]; then + RUNNER="$XCPNG_OCI_RUNNER" +else + SUPPORTED_RUNNERS="docker podman" + for COMMAND in $SUPPORTED_RUNNERS; do + if command -v $COMMAND >/dev/null; then + RUNNER="$COMMAND" + break + fi + done + if [ -z "$RUNNER" ]; then + echo >&2 "cannot found a supported runner: $SUPPORTED_RUNNERS" + exit 1 + fi +fi cd $(dirname "$0") diff --git a/run.py b/run.py index 18f9c0d..6c4fc09 100755 --- a/run.py +++ b/run.py @@ -20,7 +20,15 @@ DEFAULT_BRANCH = '8.3' DEFAULT_ULIMIT_NOFILE = 1024 -RUNNER = os.getenv("XCPNG_OCI_RUNNER", "docker") +RUNNER = os.getenv("XCPNG_OCI_RUNNER") +if RUNNER is None: + SUPPORTED_RUNNERS = "docker podman" + for command in SUPPORTED_RUNNERS.split(): + if shutil.which(command): + RUNNER = command + break + else: + raise Exception(f"cannot found a supported runner: {SUPPORTED_RUNNERS}") def make_mount_dir(): """ Make a randomly-named directory under SRPMS_MOUNT_ROOT. """