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 29 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import * as liberica from '../src/liberica' import * as liberica from '../src/liberica'
import * as c from '../src/constants'
import * as path from 'path' import * as path from 'path'
import * as semver from 'semver' import * as semver from 'semver'
import {expect, test} from '@jest/globals' import {expect, test} from '@jest/globals'
@ -35,18 +36,22 @@ test('find latest JDK version', async () => {
}, 30000) }, 30000)
test('find asset URL', async () => { test('find asset URL', async () => {
await expectURL( await expectURL('11.0.22+12', '', 'bellsoft-liberica-vm-openjdk11.0.22')
'17.0.10+13',
'core',
'bellsoft-liberica-vm-core-openjdk17.0.10'
)
await expectURL('17.0.10+13', 'std', 'bellsoft-liberica-vm-openjdk17.0.10') await expectURL('17.0.10+13', 'std', 'bellsoft-liberica-vm-openjdk17.0.10')
await expectURL( await expectURL(
'21.0.2+14', '21.0.2+14',
'full', 'core',
'bellsoft-liberica-vm-full-openjdk21.0.2' '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) }, 10000)
type verifier = ( type verifier = (

BIN
dist/main/index.js generated vendored

Binary file not shown.

View File

@ -6,6 +6,7 @@ import {
getMatchingTags getMatchingTags
} from './utils' } from './utils'
import {downloadTool} from '@actions/tool-cache' import {downloadTool} from '@actions/tool-cache'
import {spawnSync} from 'child_process'
const LIBERICA_GH_USER = 'bell-sw' const LIBERICA_GH_USER = 'bell-sw'
const LIBERICA_RELEASES_REPO = 'LibericaNIK' const LIBERICA_RELEASES_REPO = 'LibericaNIK'
@ -96,8 +97,21 @@ function determineToolName(javaVersion: string, version: string) {
} }
function determinePlatformPart() { function determinePlatformPart() {
// for linux-musl, return `linux-${c.JDK_ARCH}-musl` if (isMuslBasedLinux()) {
return `${c.JDK_PLATFORM}-${c.GRAALVM_ARCH}` 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) { function isDigit(c: string) {