Skip to content

Commit

Permalink
Always update package list to avoid errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Jan 13, 2025
1 parent e06eed2 commit 6d98ee0
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions functions/java-jre.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}... "
Expand All @@ -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
Expand Down

0 comments on commit 6d98ee0

Please sign in to comment.