Skip to content

Commit

Permalink
Fallback to podman automatically if docker is not installed
Browse files Browse the repository at this point in the history
Signed-off-by: Yann Dirson <[email protected]>
  • Loading branch information
ydirson committed Nov 13, 2023
1 parent 69eaa4b commit be45a39
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 16 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 find a supported runner: $SUPPORTED_RUNNERS"
exit 1
fi
fi

cd $(dirname "$0")

Expand Down
10 changes: 9 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 find a supported runner: {SUPPORTED_RUNNERS}")

def make_mount_dir():
""" Make a randomly-named directory under SRPMS_MOUNT_ROOT. """
Expand Down

0 comments on commit be45a39

Please sign in to comment.