mirror of
https://github.com/actions/setup-java.git
synced 2026-08-19 12:12:51 +00:00
Add Red Hat Build of OpenJDK support (#1241)
* Add Red Hat Build of OpenJDK support Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Fix Red Hat tests on Windows Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Update compiled Red Hat distribution Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot App
Copilot Autofix powered by AI
parent
5f75b27283
commit
416c6d1e8a
Vendored
+139
@@ -0,0 +1,139 @@
|
||||
export const id = 228;
|
||||
export const ids = [228];
|
||||
export const modules = {
|
||||
|
||||
/***/ 8228:
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ RedHatDistribution: () => (/* binding */ RedHatDistribution)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3838);
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9896);
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6928);
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2088);
|
||||
/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(semver__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* 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 _platform_types_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7444);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const DISCO_API_URL = 'https://api.foojay.io/disco/v3.0';
|
||||
class RedHatDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_5__/* .JavaBase */ .O {
|
||||
constructor(installerOptions) {
|
||||
super('RedHat', installerOptions);
|
||||
}
|
||||
async findPackageForDownload(range) {
|
||||
if (!this.stable) {
|
||||
throw new Error('Early access versions are not supported');
|
||||
}
|
||||
const availablePackages = await this.getAvailablePackages();
|
||||
const normalizedPackages = availablePackages
|
||||
.map(item => ({
|
||||
item,
|
||||
version: this.normalizeDiscoVersion(item.java_version)
|
||||
}))
|
||||
.filter((item) => item.version !== null)
|
||||
.sort((left, right) => -semver__WEBPACK_IMPORTED_MODULE_3___default().compareBuild(left.version, right.version));
|
||||
const selectedPackage = normalizedPackages.find(item => (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .isVersionSatisfies */ .y)(range, item.version));
|
||||
if (!selectedPackage) {
|
||||
throw this.createVersionNotFoundError(range, normalizedPackages.map(item => item.version), `Operating system: ${this.getOperatingSystem()}`);
|
||||
}
|
||||
const detailsUrl = `${DISCO_API_URL}/ids/${selectedPackage.item.id}`;
|
||||
const response = await this.http.getJson(detailsUrl);
|
||||
const details = response.result?.result?.[0];
|
||||
if (!details?.direct_download_uri) {
|
||||
throw new Error(`Foojay Disco returned no direct Red Hat download URL for package '${selectedPackage.item.id}'.`);
|
||||
}
|
||||
const checksum = details.checksum?.trim();
|
||||
if (details.checksum_type?.toLowerCase() !== 'sha256' || !checksum) {
|
||||
throw new Error(`Foojay Disco returned no SHA-256 checksum for Red Hat package '${selectedPackage.item.id}'.`);
|
||||
}
|
||||
return {
|
||||
version: selectedPackage.version,
|
||||
url: details.direct_download_uri,
|
||||
checksum: {
|
||||
algorithm: 'sha256',
|
||||
value: checksum,
|
||||
source: detailsUrl
|
||||
}
|
||||
};
|
||||
}
|
||||
async downloadTool(javaRelease) {
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||
let javaArchivePath = await this.downloadAndVerify(javaRelease);
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq('Extracting Java archive...');
|
||||
const archiveType = this.getArchiveType();
|
||||
if (archiveType === 'zip') {
|
||||
javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .renameWinArchive */ .n2)(javaArchivePath);
|
||||
}
|
||||
const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .extractJdkFile */ .PE)(javaArchivePath, archiveType);
|
||||
const archiveName = fs__WEBPACK_IMPORTED_MODULE_1___default().readdirSync(extractedJavaPath)[0];
|
||||
if (!archiveName) {
|
||||
throw new Error(`The Red Hat archive for Java ${javaRelease.version} was empty.`);
|
||||
}
|
||||
const archivePath = path__WEBPACK_IMPORTED_MODULE_2___default().join(extractedJavaPath, archiveName);
|
||||
const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
}
|
||||
async getAvailablePackages() {
|
||||
const operatingSystem = this.getOperatingSystem();
|
||||
const archiveType = this.getArchiveType();
|
||||
const query = new URLSearchParams({
|
||||
distro: 'redhat',
|
||||
release_status: 'ga',
|
||||
operating_system: operatingSystem,
|
||||
architecture: this.distributionArchitecture(),
|
||||
package_type: this.packageType,
|
||||
archive_type: archiveType,
|
||||
directly_downloadable: 'true'
|
||||
});
|
||||
const url = `${DISCO_API_URL}/packages?${query.toString()}`;
|
||||
const response = await this.http.getJson(url);
|
||||
const packages = response.result?.result;
|
||||
if (!Array.isArray(packages)) {
|
||||
throw new Error(`Could not fetch Red Hat package metadata from Foojay Disco: ${url}`);
|
||||
}
|
||||
return packages.filter(item => item.distribution === 'redhat' &&
|
||||
item.release_status === 'ga' &&
|
||||
item.operating_system === operatingSystem &&
|
||||
item.architecture === this.distributionArchitecture() &&
|
||||
item.package_type === this.packageType &&
|
||||
item.archive_type === archiveType &&
|
||||
item.directly_downloadable);
|
||||
}
|
||||
getOperatingSystem(alpine = (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_6__/* .isAlpineLinux */ .G6)()) {
|
||||
if (alpine) {
|
||||
throw new Error("Distribution 'redhat' does not support Alpine Linux because Red Hat portable archives require glibc.");
|
||||
}
|
||||
return process.platform === 'win32' ? 'windows' : 'linux';
|
||||
}
|
||||
getArchiveType() {
|
||||
return process.platform === 'win32' ? 'zip' : 'tar.xz';
|
||||
}
|
||||
normalizeDiscoVersion(version) {
|
||||
let normalizedVersion = version.trim();
|
||||
if (/^\d+\+\d+$/.test(normalizedVersion)) {
|
||||
normalizedVersion = normalizedVersion.replace('+', '.0.0+');
|
||||
}
|
||||
else if (/^\d+$/.test(normalizedVersion)) {
|
||||
normalizedVersion = `${normalizedVersion}.0.0`;
|
||||
}
|
||||
else if (/^\d+\.\d+$/.test(normalizedVersion)) {
|
||||
normalizedVersion = `${normalizedVersion}.0`;
|
||||
}
|
||||
return semver__WEBPACK_IMPORTED_MODULE_3___default().valid(normalizedVersion) ? normalizedVersion : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
Vendored
+25
-2
@@ -30915,6 +30915,7 @@ var JavaDistribution;
|
||||
JavaDistribution["JetBrains"] = "jetbrains";
|
||||
JavaDistribution["Kona"] = "kona";
|
||||
JavaDistribution["OracleOpenJdk"] = "oracle-openjdk";
|
||||
JavaDistribution["RedHat"] = "redhat";
|
||||
})(JavaDistribution || (JavaDistribution = {}));
|
||||
const JAVA_PACKAGE_CAPABILITIES = {
|
||||
[JavaDistribution.Temurin]: ['jdk', 'jre', 'jdk+jmods'],
|
||||
@@ -30946,7 +30947,8 @@ const JAVA_PACKAGE_CAPABILITIES = {
|
||||
'jre+ft'
|
||||
],
|
||||
[JavaDistribution.Kona]: ['jdk'],
|
||||
[JavaDistribution.OracleOpenJdk]: ['jdk']
|
||||
[JavaDistribution.OracleOpenJdk]: ['jdk'],
|
||||
[JavaDistribution.RedHat]: ['jdk', 'jre']
|
||||
};
|
||||
function validateJavaPackage(distributionName, packageType, version) {
|
||||
if (!isJavaDistribution(distributionName)) {
|
||||
@@ -31131,6 +31133,19 @@ const JAVA_PLATFORM_CAPABILITIES = {
|
||||
macos: X64_ARM64,
|
||||
windows: ['x64']
|
||||
}
|
||||
},
|
||||
[_package_types_js__WEBPACK_IMPORTED_MODULE_2__/* .JavaDistribution */ .zS.RedHat]: {
|
||||
platforms: {
|
||||
linux: [
|
||||
'x64',
|
||||
{ architecture: 'aarch64', versionRange: '<12' },
|
||||
{ architecture: 'ppc64le', versionRange: '<12' }
|
||||
],
|
||||
windows: [
|
||||
{ architecture: 'x64', versionRange: '<22' },
|
||||
{ architecture: 'x86', versionRange: '<11' }
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const ARCHITECTURE_ALIASES = {
|
||||
@@ -31346,7 +31361,9 @@ async function extractJdkFile(toolPath, extension) {
|
||||
if (!extension) {
|
||||
extension = toolPath.endsWith('.tar.gz')
|
||||
? 'tar.gz'
|
||||
: path__WEBPACK_IMPORTED_MODULE_1___default().extname(toolPath);
|
||||
: toolPath.endsWith('.tar.xz')
|
||||
? 'tar.xz'
|
||||
: path__WEBPACK_IMPORTED_MODULE_1___default().extname(toolPath);
|
||||
if (extension.startsWith('.')) {
|
||||
extension = extension.substring(1);
|
||||
}
|
||||
@@ -31354,6 +31371,8 @@ async function extractJdkFile(toolPath, extension) {
|
||||
switch (extension) {
|
||||
case 'tar.gz':
|
||||
return await extractTarGz(toolPath);
|
||||
case 'tar.xz':
|
||||
return await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .extractTar */ .nN(toolPath, undefined, 'xJ');
|
||||
case 'tar':
|
||||
return await _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__/* .extractTar */ .nN(toolPath);
|
||||
case 'zip':
|
||||
@@ -36309,6 +36328,10 @@ async function getJavaDistribution(distributionName, installerOptions, jdkFile)
|
||||
const { OpenJdkDistribution } = await Promise.all(/* import() */[__nccwpck_require__.e(242), __nccwpck_require__.e(735)]).then(__nccwpck_require__.bind(__nccwpck_require__, 3735));
|
||||
return new OpenJdkDistribution(normalizedInstallerOptions);
|
||||
}
|
||||
case package_types/* JavaDistribution */.zS.RedHat: {
|
||||
const { RedHatDistribution } = await Promise.all(/* import() */[__nccwpck_require__.e(242), __nccwpck_require__.e(228)]).then(__nccwpck_require__.bind(__nccwpck_require__, 8228));
|
||||
return new RedHatDistribution(normalizedInstallerOptions);
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user