Architecture Support (#95)

* Quick fix for 32-bit architecture support.

* Validate arch at input

Co-authored-by: Émile Grégoire <eg@emilegregoire.ca>
This commit is contained in:
Austin Shalit 2020-08-24 06:35:41 -04:00 committed by GitHub
parent 3019d15cad
commit d34a7e45c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 9 deletions

BIN
dist/index.js vendored

Binary file not shown.

15
dist/setup/index.js vendored
View File

@ -28685,6 +28685,9 @@ function run() {
version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
}
const arch = core.getInput(constants.INPUT_ARCHITECTURE, { required: true });
if (!['x86', 'x64'].includes(arch)) {
throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
}
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
required: true
});
@ -33423,7 +33426,7 @@ function getJava(version, arch, jdkFile, javaPackage) {
}
const contents = yield response.readBody();
const refs = contents.match(/<a href.*\">/gi) || [];
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
jdkFile = yield tc.downloadTool(downloadInfo.url);
version = downloadInfo.version;
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@ -33539,20 +33542,22 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
}
});
}
function getDownloadInfo(refs, version, javaPackage) {
function getDownloadInfo(refs, version, arch, javaPackage) {
version = normalizeVersion(version);
const archExtension = arch === 'x86' ? 'i686' : 'x64';
let extension = '';
if (IS_WINDOWS) {
extension = `-win_x64.zip`;
extension = `-win_${archExtension}.zip`;
}
else {
if (process.platform === 'darwin') {
extension = `-macosx_x64.tar.gz`;
extension = `-macosx_${archExtension}.tar.gz`;
}
else {
extension = `-linux_x64.tar.gz`;
extension = `-linux_${archExtension}.tar.gz`;
}
}
core.debug(`Searching for files with extension: ${extension}`);
let pkgRegexp = new RegExp('');
let pkgTypeLength = 0;
if (javaPackage === 'jdk') {

View File

@ -45,7 +45,7 @@ export async function getJava(
const contents = await response.readBody();
const refs = contents.match(/<a href.*\">/gi) || [];
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
jdkFile = await tc.downloadTool(downloadInfo.url);
version = downloadInfo.version;
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@ -181,20 +181,26 @@ async function unzipJavaDownload(
function getDownloadInfo(
refs: string[],
version: string,
arch: string,
javaPackage: string
): {version: string; url: string} {
version = normalizeVersion(version);
const archExtension = arch === 'x86' ? 'i686' : 'x64';
let extension = '';
if (IS_WINDOWS) {
extension = `-win_x64.zip`;
extension = `-win_${archExtension}.zip`;
} else {
if (process.platform === 'darwin') {
extension = `-macosx_x64.tar.gz`;
extension = `-macosx_${archExtension}.tar.gz`;
} else {
extension = `-linux_x64.tar.gz`;
extension = `-linux_${archExtension}.tar.gz`;
}
}
core.debug(`Searching for files with extension: ${extension}`);
let pkgRegexp = new RegExp('');
let pkgTypeLength = 0;
if (javaPackage === 'jdk') {

View File

@ -11,7 +11,12 @@ async function run() {
if (!version) {
version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
}
const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true});
if (!['x86', 'x64'].includes(arch)) {
throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
}
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
required: true
});