Fix JDK resolution cache platform identity (#1210)

* Fix JDK resolution cache platform identity

Include the effective Linux libc platform in JDK resolution cache keys so Alpine/musl and glibc runners cannot restore each other's release metadata. Bump the cache namespace and share Alpine detection with affected distributors.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 4f95577c-567c-47a8-92f2-b4dced527866

* Update generated action bundles

Regenerate setup and cleanup distributions for the platform-aware JDK resolution cache.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 4f95577c-567c-47a8-92f2-b4dced527866

* Cover the platform-identity fallback and Alpine short-circuit

getJavaPlatformIdentity's `?? platform` fallback and the alias path for
platforms other than linux/darwin/win32 had no coverage, and isAlpineLinux
had no direct test at all.

Verified by mutation: replacing the fallback with a constant, and dropping
the `platform === 'linux'` short-circuit from isAlpineLinux, both left the
existing suite fully green. The added cases fail on each.

The short-circuit case matters beyond coverage bookkeeping: it is what keeps
the /etc/alpine-release probe from running on non-Linux runners, so a stray
file can never make Windows or macOS resolve as musl.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db

* Carry the platform identity into the floating resolution request

Merging main brought in #1219, which added getFloatingResolutionRequest
as a second construction site for JdkResolutionRequest. It predates the
required `platform` field, so the merged tree did not compile.

The floating request already carries `source`, which pins the artifact
bytes, so this changes no lookup behaviour on its own -- it keeps the two
request builders consistent and the tree building.

Also refreshes dist/, which the textual merge left stale.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db

---------

Co-authored-by: Bruno Borges <brborges@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 74248bb0-72af-41d8-b85d-b0f5836e68db
This commit is contained in:
Julien Dubois
2026-08-05 18:45:11 +02:00
committed by GitHub
parent fb58a661f3
commit d0e61fe743
14 changed files with 149 additions and 38 deletions
@@ -101,6 +101,8 @@ const tc = await import('@actions/tool-cache');
const util = await import('../../src/util.js'); const util = await import('../../src/util.js');
const jdkCache = await import('../../src/jdk-cache.js'); const jdkCache = await import('../../src/jdk-cache.js');
const jdkResolutionCache = await import('../../src/jdk-resolution-cache.js'); const jdkResolutionCache = await import('../../src/jdk-resolution-cache.js');
const {getJavaPlatformIdentity} =
await import('../../src/distributions/platform-types.js');
const {JavaBase} = await import('../../src/distributions/base-installer.js'); const {JavaBase} = await import('../../src/distributions/base-installer.js');
class EmptyJavaBase extends JavaBase { class EmptyJavaBase extends JavaBase {
@@ -1290,6 +1292,7 @@ describe('setupJava', () => {
const expectedRequest = { const expectedRequest = {
distribution: 'Empty', distribution: 'Empty',
packageType: 'jdk', packageType: 'jdk',
platform: getJavaPlatformIdentity(),
architecture: 'x86', architecture: 'x86',
versionSpec: '11.0.9', versionSpec: '11.0.9',
stable: true stable: true
@@ -1406,6 +1409,7 @@ describe('setupJava', () => {
{ {
distribution: 'Empty', distribution: 'Empty',
packageType: 'jdk', packageType: 'jdk',
platform: getJavaPlatformIdentity(),
architecture: 'x86', architecture: 'x86',
versionSpec: '11.0.9', versionSpec: '11.0.9',
stable: true, stable: true,
+34
View File
@@ -1,6 +1,8 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { import {
getJavaPlatformIdentity,
isAlpineLinux,
JAVA_PLATFORM_CAPABILITIES, JAVA_PLATFORM_CAPABILITIES,
normalizeArchitecture, normalizeArchitecture,
validateJavaPlatform validateJavaPlatform
@@ -28,6 +30,38 @@ describe('Java platform capabilities', () => {
expect(normalizeArchitecture(input)).toBe(expected); expect(normalizeArchitecture(input)).toBe(expected);
}); });
it.each([
['linux', false, 'linux-glibc'],
['linux', true, 'linux-musl'],
['darwin', false, 'macos'],
['win32', false, 'windows'],
// Exercises the normalizePlatform alias path and the `?? platform`
// fallback for a platform that has no Java alias.
['sunos', false, 'solaris'],
['aix', false, 'aix']
] as const)(
'identifies %s with Alpine release %s as %s',
(platform, alpineReleaseExists, expected) => {
expect(getJavaPlatformIdentity(platform, alpineReleaseExists)).toBe(
expected
);
}
);
// The platform check has to short-circuit before the filesystem probe, so a
// stray /etc/alpine-release can never make a non-Linux runner look like musl.
it.each([
['linux', true, true],
['linux', false, false],
['darwin', true, false],
['win32', true, false]
] as const)(
'treats %s with Alpine release %s as Alpine: %s',
(platform, alpineReleaseExists, expected) => {
expect(isAlpineLinux(platform, alpineReleaseExists)).toBe(expected);
}
);
it('uses the normalized architecture for validation', () => { it('uses the normalized architecture for validation', () => {
expect(validateJavaPlatform('microsoft', 'linux', 'arm64', '25')).toBe( expect(validateJavaPlatform('microsoft', 'linux', 'arm64', '25')).toBe(
'aarch64' 'aarch64'
+23 -8
View File
@@ -25,6 +25,7 @@ const {restoreJdkResolution, registerJdkResolution, saveJdkResolutionCaches} =
const request = { const request = {
distribution: 'Temurin-Hotspot', distribution: 'Temurin-Hotspot',
packageType: 'jdk', packageType: 'jdk',
platform: 'linux-glibc',
architecture: 'x64', architecture: 'x64',
versionSpec: '21', versionSpec: '21',
stable: true stable: true
@@ -102,10 +103,24 @@ describe('JDK resolution cache', () => {
expect(paths[0]).not.toContain(bucket()); expect(paths[0]).not.toContain(bucket());
expect(primaryKey).toBe(`${restoreKeys[0]}${bucket()}`); expect(primaryKey).toBe(`${restoreKeys[0]}${bucket()}`);
expect(restoreKeys[0]).toMatch( expect(restoreKeys[0]).toMatch(
/^setup-java-jdkres-v1-Linux-x64-[0-9a-f]{64}-$/ /^setup-java-jdkres-v2-Linux-x64-[0-9a-f]{64}-$/
); );
}); });
it('separates glibc and musl Linux resolutions', async () => {
createRunnerTemp();
await restoreJdkResolution(request);
const [glibcPaths, glibcKey] = jest.mocked(cache.restoreCache).mock
.calls[0] as [string[], string];
await restoreJdkResolution({...request, platform: 'linux-musl'});
const [muslPaths, muslKey] = jest.mocked(cache.restoreCache).mock
.calls[1] as [string[], string];
expect(muslKey).not.toBe(glibcKey);
expect(muslPaths).not.toEqual(glibcPaths);
});
it('holds the key steady for a week and then rolls it', async () => { it('holds the key steady for a week and then rolls it', async () => {
createRunnerTemp(); createRunnerTemp();
const nowSpy = jest.spyOn(Date, 'now'); const nowSpy = jest.spyOn(Date, 'now');
@@ -129,7 +144,7 @@ describe('JDK resolution cache', () => {
it('reports a hit on the current bucket as fresh', async () => { it('reports a hit on the current bucket as fresh', async () => {
createRunnerTemp(); createRunnerTemp();
const key = `setup-java-jdkres-v1-Linux-x64-${'0'.repeat(64)}-${bucket()}`; const key = `setup-java-jdkres-v2-Linux-x64-${'0'.repeat(64)}-${bucket()}`;
restoreWith(JSON.stringify(release), key); restoreWith(JSON.stringify(release), key);
// The key the module computes is the one it passes to restoreCache, so // The key the module computes is the one it passes to restoreCache, so
@@ -152,7 +167,7 @@ describe('JDK resolution cache', () => {
it('reports a hit on an older bucket as stale', async () => { it('reports a hit on an older bucket as stale', async () => {
createRunnerTemp(); createRunnerTemp();
restoreWith(JSON.stringify(release), 'setup-java-jdkres-v1-old'); restoreWith(JSON.stringify(release), 'setup-java-jdkres-v2-old');
const restored = await restoreJdkResolution(request); const restored = await restoreJdkResolution(request);
expect(restored?.fresh).toBe(false); expect(restored?.fresh).toBe(false);
@@ -233,7 +248,7 @@ describe('JDK resolution cache', () => {
] ]
])('rejects an entry with %s', async (_name, contents) => { ])('rejects an entry with %s', async (_name, contents) => {
createRunnerTemp(); createRunnerTemp();
restoreWith(contents, 'setup-java-jdkres-v1-old'); restoreWith(contents, 'setup-java-jdkres-v2-old');
await expect(restoreJdkResolution(request)).resolves.toBeUndefined(); await expect(restoreJdkResolution(request)).resolves.toBeUndefined();
}); });
@@ -251,7 +266,7 @@ describe('JDK resolution cache', () => {
}, },
floating: true floating: true
}; };
restoreWith(JSON.stringify(full), 'setup-java-jdkres-v1-old'); restoreWith(JSON.stringify(full), 'setup-java-jdkres-v2-old');
const restored = await restoreJdkResolution(request); const restored = await restoreJdkResolution(request);
expect(restored?.release).toEqual(full); expect(restored?.release).toEqual(full);
@@ -261,7 +276,7 @@ describe('JDK resolution cache', () => {
createRunnerTemp(); createRunnerTemp();
restoreWith( restoreWith(
JSON.stringify({...release, evil: 'payload'}), JSON.stringify({...release, evil: 'payload'}),
'setup-java-jdkres-v1-old' 'setup-java-jdkres-v2-old'
); );
const restored = await restoreJdkResolution(request); const restored = await restoreJdkResolution(request);
@@ -332,7 +347,7 @@ describe('JDK resolution cache', () => {
const stateFor = (cachePath: string) => const stateFor = (cachePath: string) =>
JSON.stringify([ JSON.stringify([
{ {
key: 'setup-java-jdkres-v1-key', key: 'setup-java-jdkres-v2-key',
path: cachePath, path: cachePath,
release: JSON.stringify(release) release: JSON.stringify(release)
} }
@@ -350,7 +365,7 @@ describe('JDK resolution cache', () => {
await saveJdkResolutionCaches(); await saveJdkResolutionCaches();
expect(cache.saveCache).toHaveBeenCalledWith( expect(cache.saveCache).toHaveBeenCalledWith(
[root], [root],
'setup-java-jdkres-v1-key' 'setup-java-jdkres-v2-key'
); );
}); });
+2 -1
View File
@@ -23,7 +23,7 @@ export const modules = {
const STATE_JDK_RESOLUTIONS = 'jdk-resolutions'; const STATE_JDK_RESOLUTIONS = 'jdk-resolutions';
const JDK_RESOLUTION_KEY_VERSION = 1; const JDK_RESOLUTION_KEY_VERSION = 2;
const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution'; const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution';
const RESOLUTION_FILE_NAME = 'release.json'; const RESOLUTION_FILE_NAME = 'release.json';
const pendingResolutions = (/* unused pure expression or super */ null && ([])); const pendingResolutions = (/* unused pure expression or super */ null && ([]));
@@ -146,6 +146,7 @@ function getResolutionIdentity(request) {
runnerOs: getRunnerOs(), runnerOs: getRunnerOs(),
distribution: request.distribution.toLowerCase(), distribution: request.distribution.toLowerCase(),
packageType: request.packageType.toLowerCase(), packageType: request.packageType.toLowerCase(),
platform: request.platform.toLowerCase(),
architecture: request.architecture.toLowerCase(), architecture: request.architecture.toLowerCase(),
versionSpec: request.versionSpec, versionSpec: request.versionSpec,
stable: request.stable, stable: request.stable,
+2
View File
@@ -441,6 +441,7 @@ class JavaBase {
const request = { const request = {
distribution: this.distribution, distribution: this.distribution,
packageType: this.packageType, packageType: this.packageType,
platform: (0,platform_types/* getJavaPlatformIdentity */.U)(),
architecture: this.architecture, architecture: this.architecture,
versionSpec: this.version, versionSpec: this.version,
stable: this.stable stable: this.stable
@@ -517,6 +518,7 @@ class JavaBase {
return { return {
distribution: this.distribution, distribution: this.distribution,
packageType: this.packageType, packageType: this.packageType,
platform: (0,platform_types/* getJavaPlatformIdentity */.U)(),
architecture: this.architecture, architecture: this.architecture,
versionSpec: this.version, versionSpec: this.version,
stable: this.stable, stable: this.stable,
+2 -1
View File
@@ -24,7 +24,7 @@ export const modules = {
const STATE_JDK_RESOLUTIONS = 'jdk-resolutions'; const STATE_JDK_RESOLUTIONS = 'jdk-resolutions';
const JDK_RESOLUTION_KEY_VERSION = 1; const JDK_RESOLUTION_KEY_VERSION = 2;
const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution'; const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution';
const RESOLUTION_FILE_NAME = 'release.json'; const RESOLUTION_FILE_NAME = 'release.json';
const pendingResolutions = []; const pendingResolutions = [];
@@ -147,6 +147,7 @@ function getResolutionIdentity(request) {
runnerOs: getRunnerOs(), runnerOs: getRunnerOs(),
distribution: request.distribution.toLowerCase(), distribution: request.distribution.toLowerCase(),
packageType: request.packageType.toLowerCase(), packageType: request.packageType.toLowerCase(),
platform: request.platform.toLowerCase(),
architecture: request.architecture.toLowerCase(), architecture: request.architecture.toLowerCase(),
versionSpec: request.versionSpec, versionSpec: request.versionSpec,
stable: request.stable, stable: request.stable,
+4 -1
View File
@@ -68,6 +68,8 @@ var base_installer = __webpack_require__(6242);
var constants = __webpack_require__(7242); var constants = __webpack_require__(7242);
// EXTERNAL MODULE: ./src/util.ts // EXTERNAL MODULE: ./src/util.ts
var util = __webpack_require__(4527); var util = __webpack_require__(4527);
// EXTERNAL MODULE: ./src/distributions/platform-types.ts
var platform_types = __webpack_require__(7444);
;// CONCATENATED MODULE: ./src/distributions/temurin/installer.ts ;// CONCATENATED MODULE: ./src/distributions/temurin/installer.ts
@@ -79,6 +81,7 @@ var util = __webpack_require__(4527);
var TemurinImplementation; var TemurinImplementation;
(function (TemurinImplementation) { (function (TemurinImplementation) {
TemurinImplementation["Hotspot"] = "Hotspot"; TemurinImplementation["Hotspot"] = "Hotspot";
@@ -246,7 +249,7 @@ class TemurinDistribution extends base_installer/* JavaBase */.O {
case 'win32': case 'win32':
return 'windows'; return 'windows';
case 'linux': case 'linux':
if (external_fs_default().existsSync('/etc/alpine-release')) { if ((0,platform_types/* isAlpineLinux */.G6)()) {
return 'alpine-linux'; return 'alpine-linux';
} }
return 'linux'; return 'linux';
+3 -1
View File
@@ -17,6 +17,8 @@ export const modules = {
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4527); /* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4527);
/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6242); /* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6242);
/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7444);
@@ -163,7 +165,7 @@ class SapMachineDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE
return 'macos'; return 'macos';
case 'linux': case 'linux':
// figure out if alpine/musl // figure out if alpine/musl
if (fs__WEBPACK_IMPORTED_MODULE_2___default().existsSync('/etc/alpine-release')) { if ((0,_platform_types_js__WEBPACK_IMPORTED_MODULE_6__/* .isAlpineLinux */ .G6)()) {
return 'linux-musl'; return 'linux-musl';
} }
return 'linux'; return 'linux';
+39 -22
View File
@@ -30988,33 +30988,38 @@ function createUnsupportedPackageError(distributionName, packageType, supportedP
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { /* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ G6: () => (/* binding */ isAlpineLinux),
/* harmony export */ U: () => (/* binding */ getJavaPlatformIdentity),
/* harmony export */ dV: () => (/* binding */ normalizeArchitecture), /* harmony export */ dV: () => (/* binding */ normalizeArchitecture),
/* harmony export */ sZ: () => (/* binding */ validateJavaPlatform) /* harmony export */ sZ: () => (/* binding */ validateJavaPlatform)
/* harmony export */ }); /* harmony export */ });
/* unused harmony exports JAVA_PLATFORM_CAPABILITIES, normalizePlatform */ /* unused harmony exports JAVA_PLATFORM_CAPABILITIES, normalizePlatform */
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(2088); /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(9896);
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(semver__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _package_types_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(7835); /* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(2088);
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__nccwpck_require__.n(semver__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _package_types_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(7835);
const X64_ARM64 = ['x64', 'aarch64']; const X64_ARM64 = ['x64', 'aarch64'];
const STANDARD_LINUX = ['x64', 'x86', 'aarch64', 'ppc64le', 's390x']; const STANDARD_LINUX = ['x64', 'x86', 'aarch64', 'ppc64le', 's390x'];
const JAVA_PLATFORM_CAPABILITIES = { const JAVA_PLATFORM_CAPABILITIES = {
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Temurin]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Temurin]: {
platforms: { platforms: {
linux: [...STANDARD_LINUX, { architecture: 'armv7', versionRange: '<18' }], linux: [...STANDARD_LINUX, { architecture: 'armv7', versionRange: '<18' }],
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64', 'x86', 'aarch64'] windows: ['x64', 'x86', 'aarch64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Zulu]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Zulu]: {
platforms: { platforms: {
linux: ['x64', 'x86', 'armv7', 'aarch64'], linux: ['x64', 'x86', 'armv7', 'aarch64'],
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64', 'x86', 'aarch64'] windows: ['x64', 'x86', 'aarch64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Liberica]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Liberica]: {
platforms: { platforms: {
linux: ['x64', 'x86', 'armv7', 'aarch64', 'ppc64le'], linux: ['x64', 'x86', 'armv7', 'aarch64', 'ppc64le'],
macos: X64_ARM64, macos: X64_ARM64,
@@ -31022,31 +31027,31 @@ const JAVA_PLATFORM_CAPABILITIES = {
solaris: ['x64'] solaris: ['x64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.LibericaNik]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.LibericaNik]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: X64_ARM64 windows: X64_ARM64
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.JdkFile]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.JdkFile]: {
unrestricted: true unrestricted: true
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Microsoft]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Microsoft]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: X64_ARM64 windows: X64_ARM64
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Semeru]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Semeru]: {
platforms: { platforms: {
linux: ['x64', 'x86', 'ppc64le', 'ppc64', 's390x', 'aarch64'], linux: ['x64', 'x86', 'ppc64le', 'ppc64', 's390x', 'aarch64'],
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64', 'aarch64'] windows: ['x64', 'aarch64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Corretto]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Corretto]: {
platforms: { platforms: {
linux: [ linux: [
'x64', 'x64',
@@ -31058,55 +31063,55 @@ const JAVA_PLATFORM_CAPABILITIES = {
windows: ['x64', { architecture: 'x86', versionRange: '<12' }] windows: ['x64', { architecture: 'x86', versionRange: '<12' }]
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Oracle]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Oracle]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64'] windows: ['x64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Dragonwell]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Dragonwell]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
windows: ['x64'] windows: ['x64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.SapMachine]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.SapMachine]: {
platforms: { platforms: {
linux: ['x64', 'aarch64', 'ppc64le'], linux: ['x64', 'aarch64', 'ppc64le'],
macos: X64_ARM64, macos: X64_ARM64,
windows: X64_ARM64 windows: X64_ARM64
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.GraalVM]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.GraalVM]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64'] windows: ['x64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.GraalVMCommunity]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.GraalVMCommunity]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64'] windows: ['x64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.JetBrains]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.JetBrains]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: X64_ARM64 windows: X64_ARM64
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.Kona]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.Kona]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
windows: ['x64'] windows: ['x64']
} }
}, },
[_package_types_js__WEBPACK_IMPORTED_MODULE_1__/* .JavaDistribution */ .zS.OracleOpenJdk]: { [_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.OracleOpenJdk]: {
platforms: { platforms: {
linux: X64_ARM64, linux: X64_ARM64,
macos: X64_ARM64, macos: X64_ARM64,
@@ -31146,6 +31151,18 @@ function normalizeArchitecture(architecture) {
function normalizePlatform(platform) { function normalizePlatform(platform) {
return PLATFORM_ALIASES[platform]; return PLATFORM_ALIASES[platform];
} }
function isAlpineLinux(platform = process.platform, alpineReleaseExists) {
return (platform === 'linux' &&
(alpineReleaseExists ?? fs__WEBPACK_IMPORTED_MODULE_0___default().existsSync('/etc/alpine-release')));
}
function getJavaPlatformIdentity(platform = process.platform, alpineReleaseExists) {
if (platform === 'linux') {
return isAlpineLinux(platform, alpineReleaseExists)
? 'linux-musl'
: 'linux-glibc';
}
return normalizePlatform(platform) ?? platform;
}
function validateJavaPlatform(distributionName, platform, architecture, version) { function validateJavaPlatform(distributionName, platform, architecture, version) {
const normalizedArchitecture = normalizeArchitecture(architecture); const normalizedArchitecture = normalizeArchitecture(architecture);
if (!isJavaDistribution(distributionName)) { if (!isJavaDistribution(distributionName)) {
@@ -31181,8 +31198,8 @@ function isVersionCompatible(version, supportedRange) {
if (/^\d+(\.\d+){3,}$/.test(normalizedVersion)) { if (/^\d+(\.\d+){3,}$/.test(normalizedVersion)) {
normalizedVersion = normalizeExtendedVersionToSemver(normalizedVersion); normalizedVersion = normalizeExtendedVersionToSemver(normalizedVersion);
} }
const requestedRange = semver__WEBPACK_IMPORTED_MODULE_0___default().validRange(normalizedVersion.replace(/-ea$/, '')); const requestedRange = semver__WEBPACK_IMPORTED_MODULE_1___default().validRange(normalizedVersion.replace(/-ea$/, ''));
const capabilityRange = semver__WEBPACK_IMPORTED_MODULE_0___default().validRange(supportedRange); const capabilityRange = semver__WEBPACK_IMPORTED_MODULE_1___default().validRange(supportedRange);
if (!requestedRange || !capabilityRange) { if (!requestedRange || !capabilityRange) {
return true; return true;
} }
@@ -31194,7 +31211,7 @@ function isVersionCompatible(version, supportedRange) {
} }
return version; return version;
} }
return semver__WEBPACK_IMPORTED_MODULE_0___default().intersects(requestedRange, capabilityRange, { return semver__WEBPACK_IMPORTED_MODULE_1___default().intersects(requestedRange, capabilityRange, {
includePrerelease: true includePrerelease: true
}); });
} }
+6 -1
View File
@@ -20,7 +20,10 @@ import {MACOS_JAVA_CONTENT_POSTFIX} from '../constants.js';
import {RetryingHttpClient} from '../retrying-http-client.js'; import {RetryingHttpClient} from '../retrying-http-client.js';
import os from 'os'; import os from 'os';
import {expectedDigestLength, verifyChecksum} from '../checksum.js'; import {expectedDigestLength, verifyChecksum} from '../checksum.js';
import {normalizeArchitecture} from './platform-types.js'; import {
getJavaPlatformIdentity,
normalizeArchitecture
} from './platform-types.js';
import type {JdkCache} from '../jdk-cache.js'; import type {JdkCache} from '../jdk-cache.js';
export abstract class JavaBase { export abstract class JavaBase {
@@ -313,6 +316,7 @@ export abstract class JavaBase {
const request = { const request = {
distribution: this.distribution, distribution: this.distribution,
packageType: this.packageType, packageType: this.packageType,
platform: getJavaPlatformIdentity(),
architecture: this.architecture, architecture: this.architecture,
versionSpec: this.version, versionSpec: this.version,
stable: this.stable stable: this.stable
@@ -428,6 +432,7 @@ export abstract class JavaBase {
return { return {
distribution: this.distribution, distribution: this.distribution,
packageType: this.packageType, packageType: this.packageType,
platform: getJavaPlatformIdentity(),
architecture: this.architecture, architecture: this.architecture,
versionSpec: this.version, versionSpec: this.version,
stable: this.stable, stable: this.stable,
+23
View File
@@ -1,3 +1,4 @@
import fs from 'fs';
import semver from 'semver'; import semver from 'semver';
import {JavaDistribution} from './package-types.js'; import {JavaDistribution} from './package-types.js';
@@ -191,6 +192,28 @@ export function normalizePlatform(
return PLATFORM_ALIASES[platform]; return PLATFORM_ALIASES[platform];
} }
export function isAlpineLinux(
platform: NodeJS.Platform = process.platform,
alpineReleaseExists?: boolean
): boolean {
return (
platform === 'linux' &&
(alpineReleaseExists ?? fs.existsSync('/etc/alpine-release'))
);
}
export function getJavaPlatformIdentity(
platform: NodeJS.Platform = process.platform,
alpineReleaseExists?: boolean
): string {
if (platform === 'linux') {
return isAlpineLinux(platform, alpineReleaseExists)
? 'linux-musl'
: 'linux-glibc';
}
return normalizePlatform(platform) ?? platform;
}
export function validateJavaPlatform( export function validateJavaPlatform(
distributionName: string, distributionName: string,
platform: NodeJS.Platform, platform: NodeJS.Platform,
+2 -1
View File
@@ -17,6 +17,7 @@ import {
JavaInstallerOptions, JavaInstallerOptions,
JavaInstallerResults JavaInstallerResults
} from '../base-models.js'; } from '../base-models.js';
import {isAlpineLinux} from '../platform-types.js';
import {ISapMachineAllVersions, ISapMachineVersions} from './models.js'; import {ISapMachineAllVersions, ISapMachineVersions} from './models.js';
export class SapMachineDistribution extends JavaBase { export class SapMachineDistribution extends JavaBase {
@@ -242,7 +243,7 @@ export class SapMachineDistribution extends JavaBase {
return 'macos'; return 'macos';
case 'linux': case 'linux':
// figure out if alpine/musl // figure out if alpine/musl
if (fs.existsSync('/etc/alpine-release')) { if (isAlpineLinux()) {
return 'linux-musl'; return 'linux-musl';
} }
return 'linux'; return 'linux';
+2 -1
View File
@@ -24,6 +24,7 @@ import {
MAX_PAGINATION_PAGES, MAX_PAGINATION_PAGES,
validatePaginationUrl validatePaginationUrl
} from '../../util.js'; } from '../../util.js';
import {isAlpineLinux} from '../platform-types.js';
export {ADOPTIUM_PUBLIC_KEY} from './adoptium-key.js'; export {ADOPTIUM_PUBLIC_KEY} from './adoptium-key.js';
@@ -274,7 +275,7 @@ export class TemurinDistribution extends JavaBase {
case 'win32': case 'win32':
return 'windows'; return 'windows';
case 'linux': case 'linux':
if (fs.existsSync('/etc/alpine-release')) { if (isAlpineLinux()) {
return 'alpine-linux'; return 'alpine-linux';
} }
return 'linux'; return 'linux';
+3 -1
View File
@@ -9,7 +9,7 @@ import {
} from './distributions/base-models.js'; } from './distributions/base-models.js';
const STATE_JDK_RESOLUTIONS = 'jdk-resolutions'; const STATE_JDK_RESOLUTIONS = 'jdk-resolutions';
const JDK_RESOLUTION_KEY_VERSION = 1; const JDK_RESOLUTION_KEY_VERSION = 2;
const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution'; const RESOLUTION_DIRECTORY = 'setup-java-jdk-resolution';
const RESOLUTION_FILE_NAME = 'release.json'; const RESOLUTION_FILE_NAME = 'release.json';
@@ -22,6 +22,7 @@ const RESOLUTION_FILE_NAME = 'release.json';
export interface JdkResolutionRequest { export interface JdkResolutionRequest {
distribution: string; distribution: string;
packageType: string; packageType: string;
platform: string;
architecture: string; architecture: string;
versionSpec: string; versionSpec: string;
stable: boolean; stable: boolean;
@@ -214,6 +215,7 @@ function getResolutionIdentity(request: JdkResolutionRequest): string {
runnerOs: getRunnerOs(), runnerOs: getRunnerOs(),
distribution: request.distribution.toLowerCase(), distribution: request.distribution.toLowerCase(),
packageType: request.packageType.toLowerCase(), packageType: request.packageType.toLowerCase(),
platform: request.platform.toLowerCase(),
architecture: request.architecture.toLowerCase(), architecture: request.architecture.toLowerCase(),
versionSpec: request.versionSpec, versionSpec: request.versionSpec,
stable: request.stable, stable: request.stable,