diff --git a/functions/java-jre.bash b/functions/java-jre.bash index 9461fabf7..b86b523f4 100644 --- a/functions/java-jre.bash +++ b/functions/java-jre.bash @@ -31,16 +31,14 @@ java_install() { ## adoptium_fetch_apt() ## adoptium_fetch_apt() { - if ! apt-cache show "temurin-${1}-jre" &> /dev/null; then - local keyName="adoptium" + local keyName="adoptium" - if ! add_keys "https://packages.adoptium.net/artifactory/api/gpg/key/public" "$keyName"; then return 1; fi - cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 843C48A565F8F04B + if ! add_keys "https://packages.adoptium.net/artifactory/api/gpg/key/public" "$keyName"; then return 1; fi + cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 843C48A565F8F04B - echo -n "$(timestamp) [openHABian] Adding Adoptium repository to apt... " - if ! echo "deb https://packages.adoptium.net/artifactory/deb ${osrelease:-bookworm} main" > /etc/apt/sources.list.d/adoptium.list; then echo "FAILED"; return 1; fi - if cond_redirect apt-get update; then echo "OK"; else echo "FAILED (update apt lists)"; return 1; fi - fi + echo -n "$(timestamp) [openHABian] Adding Adoptium repository to apt... " + if ! echo "deb https://packages.adoptium.net/artifactory/deb ${osrelease:-bookworm} main" > /etc/apt/sources.list.d/adoptium.list; then echo "FAILED"; return 1; fi + if cond_redirect apt-get update; then echo "OK"; else echo "FAILED (update apt lists)"; return 1; fi echo -n "$(timestamp) [openHABian] Fetching Adoptium Eclipse Temurin JDK... " if cond_redirect apt-get install --download-only --yes "temurin-${1}-jre"; then echo "OK"; else echo "FAILED"; return 1; fi @@ -56,7 +54,7 @@ adoptium_install_apt() { echo -n "$(timestamp) [openHABian] Installing Adoptium Eclipse Temurin JDK... " cond_redirect java_alternatives_reset if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" "temurin-${1}-jre"; then echo "OK"; else echo "FAILED"; return 1; fi - elif dpkg -s "temurin-${1}-jre" &> /dev/null; then + else echo -n "$(timestamp) [openHABian] Reconfiguring Adoptium Eclipse Temurin JDK... " cond_redirect java_alternatives_reset if cond_redirect dpkg-reconfigure "temurin-${1}-jre"; then echo "OK"; else echo "FAILED"; return 1; fi @@ -73,16 +71,14 @@ adoptium_install_apt() { ## openjdk_fetch_apt() ## openjdk_fetch_apt() { - if ! apt-cache show "openjdk-${1}-jre-headless" &> /dev/null; then - echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/java.list - cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC - cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 + echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/java.list + cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 04EE7237B7D453EC + cond_redirect apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 - # important to avoid release mixing: - # prevent RPi from using the Debian distro for normal Raspbian packages - echo -e "Package: *\\nPin: release a=unstable\\nPin-Priority: 90\\n" > /etc/apt/preferences.d/limit-unstable - cond_redirect apt-get update - fi + # important to avoid release mixing: + # prevent RPi from using the Debian distro for normal Raspbian packages + echo -e "Package: *\\nPin: release a=unstable\\nPin-Priority: 90\\n" > /etc/apt/preferences.d/limit-unstable + cond_redirect apt-get update dpkg --configure -a echo -n "$(timestamp) [openHABian] Fetching OpenJDK ${1}... " @@ -99,7 +95,7 @@ openjdk_install_apt() { echo -n "$(timestamp) [openHABian] Installing OpenJDK ${1}... " cond_redirect java_alternatives_reset if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi - elif dpkg -s "openjdk-${1}-jre-headless" &> /dev/null; then + else echo -n "$(timestamp) [openHABian] Reconfiguring OpenJDK ${1}... " cond_redirect java_alternatives_reset if cond_redirect dpkg-reconfigure "openjdk-${1}-jre-headless"; then echo "OK"; else echo "FAILED"; return 1; fi