Skip to content

Commit

Permalink
Many: replace 'which' with 'type -p' in test cases
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thozza committed Jan 23, 2025
1 parent be70e29 commit b43ef2d
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions test/cases/api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
#
# 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
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/aws_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/azure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
2 changes: 1 addition & 1 deletion test/cases/filesystem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function cleanup_on_exit() {
trap cleanup_on_exit EXIT

# 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

# Build ostree image.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/gcp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/generic_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ CONTAINER_MINIO_SERVER="quay.io/minio/minio:latest"
/usr/libexec/osbuild-composer-test/provision.sh none

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
2 changes: 1 addition & 1 deletion test/cases/image_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ run_test_case () {
cd $WORKING_DIRECTORY

# 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

# Run each test case.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/koji.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ if [[ "$TEST_TYPE" == "$TEST_TYPE_CLOUD_UPLOAD" ]]; then
# Container image used for cloud provider CLI tools
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
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
export CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/oci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
# Provision the software under test.
/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
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/regression-old-worker-new-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ sudo dnf install -y osbuild-composer-worker podman composer-cli
# verify the right worker is installed just to be sure
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
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/ubi-wsl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
/usr/libexec/osbuild-composer-test/provision.sh none

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down
4 changes: 2 additions & 2 deletions test/cases/worker-executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ KEYPAIR=${TEMPDIR}/keypair.pem
INSTANCE_ID=$(curl -Ls http://169.254.169.254/latest/meta-data/instance-id)

# Check available container runtime
if which podman 2>/dev/null >&2; then
if type -p podman 2>/dev/null >&2; then
CONTAINER_RUNTIME=podman
elif which docker 2>/dev/null >&2; then
elif type -p docker 2>/dev/null >&2; then
CONTAINER_RUNTIME=docker
else
echo No container runtime found, install podman or docker.
Expand Down

0 comments on commit b43ef2d

Please sign in to comment.