#!/bin/sh
set -u
set -e

# Clean up any java-* packages that have been installed that do not match
# our stated JAVA_VERSION-JAVA_VENDOR (e.g.: 11-openjdk; 1.8.0-openj9)
rpm -qa java-\* | while read pkg; do
    if ! echo "$pkg" | grep -q "^java-${JAVA_VERSION}-${JAVA_VENDOR}"; then
        rpm -e --nodeps "$pkg"
    fi
done

#!/bin/sh
set -u
set -e

if [ -z "$JAVA_VERSION" ]; then
  echo "JAVA_VERSION needs to be defined to use this module" >&2
  exit 1
fi
if [ -z "$JAVA_VENDOR" ]; then
  echo "JAVA_VENDOR needs to be defined to use this module" >&2
  exit 1
fi

# Clean up any java-* packages that have been installed that do not match
# our stated JAVA_VERSION-JAVA_VENDOR (e.g.: 11-openjdk; 1.8.0-openj9)
rpm -qa java-\* | while read pkg; do
    if ! echo "$pkg" | grep -q "^java-${JAVA_VERSION}-${JAVA_VENDOR}"; then
        rpm -e --nodeps "$pkg"
    fi
done

Add pre-check that JAVA_VENDOR and JAVA_VERSION aren't empty
Add pre-check that JAVA_VENDOR and JAVA_VERSION aren't empty

Signed-off-by: Jonathan Dowland <c0ba515c40872faa4125f492781ab4f735e85bcc@redhat.com>
