Skip to content

Commit

Permalink
Merge pull request #3055 from LibreSign/backport/3049/stable28
Browse files Browse the repository at this point in the history
[stable28] fix: check if is alpine
  • Loading branch information
vitormattos authored May 23, 2024
2 parents 01044de + 5b002e1 commit 75fa43d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/Service/Install/InstallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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=(?<version>.*)$/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) {
Expand Down

0 comments on commit 75fa43d

Please sign in to comment.