Musl support

This commit is contained in:
peterz 2024-02-22 11:15:19 +03:00 committed by Fabio Niephaus
parent df4b80eebe
commit 049aa7c191
No known key found for this signature in database
GPG Key ID: F21CF5275F31DFD6
3 changed files with 45 additions and 12 deletions

View File

@ -1,4 +1,5 @@
import * as liberica from '../src/liberica'
import * as c from '../src/constants'
import * as path from 'path'
import * as semver from 'semver'
import {expect, test} from '@jest/globals'
@ -35,18 +36,22 @@ test('find latest JDK version', async () => {
}, 30000)
test('find asset URL', async () => {
await expectURL(
'17.0.10+13',
'core',
'bellsoft-liberica-vm-core-openjdk17.0.10'
)
await expectURL('11.0.22+12', '', 'bellsoft-liberica-vm-openjdk11.0.22')
await expectURL('17.0.10+13', 'std', 'bellsoft-liberica-vm-openjdk17.0.10')
await expectURL(
'21.0.2+14',
'full',
'bellsoft-liberica-vm-full-openjdk21.0.2'
'core',
'bellsoft-liberica-vm-core-openjdk21.0.2'
)
await expectURL('21.0.2+14', '', 'bellsoft-liberica-vm-openjdk21.0.2')
if (!c.IS_LINUX) {
// This check can fail on Linux because there's no `full` version for aarch64 and musl
await expectURL(
'21.0.2+14',
'full',
'bellsoft-liberica-vm-full-openjdk21.0.2'
)
}
}, 10000)
type verifier = (

18
dist/main/index.js generated vendored
View File

@ -94349,6 +94349,7 @@ const c = __importStar(__nccwpck_require__(9042));
const semver = __importStar(__nccwpck_require__(1383));
const utils_1 = __nccwpck_require__(1314);
const tool_cache_1 = __nccwpck_require__(7784);
const child_process_1 = __nccwpck_require__(2081);
const LIBERICA_GH_USER = 'bell-sw';
const LIBERICA_RELEASES_REPO = 'LibericaNIK';
const LIBERICA_JDK_TAG_PREFIX = 'jdk-';
@ -94409,8 +94410,21 @@ function determineToolName(javaVersion, version) {
return `${LIBERICA_VM_PREFIX}${determineToolVersionPart(version)}openjdk${javaVersion}-${determinePlatformPart()}`;
}
function determinePlatformPart() {
// for linux-musl, return `linux-${c.JDK_ARCH}-musl`
return `${c.JDK_PLATFORM}-${c.GRAALVM_ARCH}`;
if (isMuslBasedLinux()) {
return `linux-${c.JDK_ARCH}-musl`;
}
else {
return `${c.JDK_PLATFORM}-${c.GRAALVM_ARCH}`;
}
}
function isMuslBasedLinux() {
if (c.IS_LINUX) {
const output = (0, child_process_1.spawnSync)('ldd', ['--version']).stderr.toString('utf8');
if (output.indexOf('musl') > -1) {
return true;
}
}
return false;
}
function isDigit(c) {
return c.charAt(0) >= '0' && c.charAt(0) <= '9';

View File

@ -6,6 +6,7 @@ import {
getMatchingTags
} from './utils'
import {downloadTool} from '@actions/tool-cache'
import {spawnSync} from 'child_process'
const LIBERICA_GH_USER = 'bell-sw'
const LIBERICA_RELEASES_REPO = 'LibericaNIK'
@ -96,8 +97,21 @@ function determineToolName(javaVersion: string, version: string) {
}
function determinePlatformPart() {
// for linux-musl, return `linux-${c.JDK_ARCH}-musl`
return `${c.JDK_PLATFORM}-${c.GRAALVM_ARCH}`
if (isMuslBasedLinux()) {
return `linux-${c.JDK_ARCH}-musl`
} else {
return `${c.JDK_PLATFORM}-${c.GRAALVM_ARCH}`
}
}
function isMuslBasedLinux() {
if (c.IS_LINUX) {
const output = spawnSync('ldd', ['--version']).stderr.toString('utf8')
if (output.indexOf('musl') > -1) {
return true
}
}
return false
}
function isDigit(c: string) {