diff --git a/lib/Service/Install/InstallService.php b/lib/Service/Install/InstallService.php index f64794df03..16c0e5cf2e 100644 --- a/lib/Service/Install/InstallService.php +++ b/lib/Service/Install/InstallService.php @@ -341,12 +341,13 @@ public function installJava(?bool $async = false): void { * https://jdk.java.net/java-se-ri/8-MR3 */ if (PHP_OS_FAMILY === 'Linux') { + $linuxDistribution = $this->getLinuxDistributionToDownloadJava(); $architecture = php_uname('m'); if ($architecture === 'x86_64') { - $compressedFileName = 'OpenJDK21U-jre_x64_linux_hotspot_' . self::JAVA_PARTIAL_VERSION . '.tar.gz'; + $compressedFileName = 'OpenJDK21U-jre_x64_' . $linuxDistribution . '_hotspot_' . self::JAVA_PARTIAL_VERSION . '.tar.gz'; $url = 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2+13/' . $compressedFileName; } elseif ($architecture === 'aarch64') { - $compressedFileName = 'OpenJDK21U-jre_aarch64_linux_hotspot_' . self::JAVA_PARTIAL_VERSION . '.tar.gz'; + $compressedFileName = 'OpenJDK21U-jre_aarch64_' . $linuxDistribution . '_hotspot_' . self::JAVA_PARTIAL_VERSION . '.tar.gz'; $url = 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2+13/' . $compressedFileName; } $class = TAR::class; @@ -372,6 +373,18 @@ public function installJava(?bool $async = false): void { $this->removeDownloadProgress(); } + /** + * Return linux or alpine-linux + */ + private function getLinuxDistributionToDownloadJava(): string { + $distribution = shell_exec('cat /etc/*-release'); + preg_match('/^ID=(?.*)$/m', $distribution, $matches); + if (isset($matches['version']) && strtolower($matches['version']) === 'alpine') { + return 'alpine-linux'; + } + return 'linux'; + } + public function uninstallJava(): void { $javaPath = $this->appConfig->getAppValue('java_path'); if (!$javaPath) {