Many: replace 'which' with 'type -p' in test cases

Unfortunately, `which` does not seem to be installed by default on our
F41 CI images. Instead of doing the dance with rebuilds, which has been
problematic recently, let's not rely on `which` in scripts any more,
since we can replace it with the Bash built-in `type` command.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2025-01-23 09:15:03 +01:00 committed by Achilleas Koutsou
parent 55c22bf4df
commit 2bc27d2d85
13 changed files with 24 additions and 24 deletions

View file

@ -101,9 +101,9 @@ export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
# #
# Set up the database queue # Set up the database queue
# #
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -20,9 +20,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -11,9 +11,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -24,9 +24,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -37,7 +37,7 @@ function cleanup_on_exit() {
trap cleanup_on_exit EXIT trap cleanup_on_exit EXIT
# Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image # Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image
OSBUILD_LABEL=$(matchpathcon -n "$(which osbuild)") OSBUILD_LABEL=$(matchpathcon -n "$(type -p osbuild)")
sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info
# Build ostree image. # Build ostree image.

View file

@ -19,9 +19,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -12,9 +12,9 @@ CONTAINER_MINIO_SERVER="quay.io/minio/minio:latest"
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -97,7 +97,7 @@ run_test_case () {
cd $WORKING_DIRECTORY cd $WORKING_DIRECTORY
# Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image # Workaround the problem that 'image-info' can not read SELinux labels unknown to the host from the image
OSBUILD_LABEL=$(matchpathcon -n "$(which osbuild)") OSBUILD_LABEL=$(matchpathcon -n "$(type -p osbuild)")
sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info sudo chcon "$OSBUILD_LABEL" /usr/libexec/osbuild-composer-test/image-info
# Run each test case. # Run each test case.

View file

@ -78,9 +78,9 @@ if [[ "$TEST_TYPE" == "$TEST_TYPE_CLOUD_UPLOAD" ]]; then
# Container image used for cloud provider CLI tools # Container image used for cloud provider CLI tools
export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
export CONTAINER_RUNTIME=podman export CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
export CONTAINER_RUNTIME=docker export CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -17,9 +17,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -84,9 +84,9 @@ sudo dnf install -y osbuild-composer-worker podman composer-cli
# verify the right worker is installed just to be sure # verify the right worker is installed just to be sure
rpm -q "$DESIRED_WORKER_RPM" rpm -q "$DESIRED_WORKER_RPM"
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -19,9 +19,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.

View file

@ -22,9 +22,9 @@ KEYPAIR=${TEMPDIR}/keypair.pem
INSTANCE_ID=$(curl -Ls http://169.254.169.254/latest/meta-data/instance-id) INSTANCE_ID=$(curl -Ls http://169.254.169.254/latest/meta-data/instance-id)
# Check available container runtime # Check available container runtime
if which podman 2>/dev/null >&2; then if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker CONTAINER_RUNTIME=docker
else else
echo No container runtime found, install podman or docker. echo No container runtime found, install podman or docker.