From 8b062ac0cf8238c62b2aae01fc6bffb175b547b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20Gr=C3=A9goire?= Date: Tue, 14 Apr 2020 14:51:01 -0400 Subject: [PATCH 1/2] Quick fix for 32-bit architecture support. --- dist/index.js | 21 ++++++++++++++++----- src/installer.ts | 21 +++++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/dist/index.js b/dist/index.js index 966326536..d81245c07 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4696,7 +4696,7 @@ function getJava(version, arch, jdkFile, javaPackage) { } const contents = yield response.readBody(); const refs = contents.match(//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'; @@ -4804,20 +4804,31 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) { } }); } -function getDownloadInfo(refs, version, javaPackage) { +function getDownloadInfo(refs, version, arch, javaPackage) { version = normalizeVersion(version); + let archExtension = ''; + if (arch === 'x86') { + archExtension = 'i686'; + } + else if (arch === 'x64') { + archExtension = 'x64'; + } + else { + throw new Error(`architecture "${arch}" is not int [x86 | 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') { diff --git a/src/installer.ts b/src/installer.ts index cce8fa3d3..5a2c0ae96 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -60,7 +60,7 @@ export async function getJava( const contents = await response.readBody(); const refs = contents.match(//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'; @@ -188,20 +188,33 @@ async function unzipJavaDownload( function getDownloadInfo( refs: string[], version: string, + arch: string, javaPackage: string ): {version: string; url: string} { version = normalizeVersion(version); + + let archExtension = ''; + if (arch === 'x86') { + archExtension = 'i686'; + } else if (arch === 'x64') { + archExtension = 'x64'; + } else { + throw new Error(`architecture "${arch}" is not int [x86 | 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') { From 1ba1e1b1f660d6a178bc41988fe65a8da9abf393 Mon Sep 17 00:00:00 2001 From: Austin Shalit Date: Wed, 19 Aug 2020 21:22:33 -0700 Subject: [PATCH 2/2] Validate arch at input --- dist/setup/index.js | 14 ++++---------- src/installer.ts | 9 +-------- src/setup-java.ts | 5 +++++ 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index d23c95eed..28c5c3ccc 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -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 }); @@ -33541,16 +33544,7 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) { } function getDownloadInfo(refs, version, arch, javaPackage) { version = normalizeVersion(version); - let archExtension = ''; - if (arch === 'x86') { - archExtension = 'i686'; - } - else if (arch === 'x64') { - archExtension = 'x64'; - } - else { - throw new Error(`architecture "${arch}" is not int [x86 | x64]`); - } + const archExtension = arch === 'x86' ? 'i686' : 'x64'; let extension = ''; if (IS_WINDOWS) { extension = `-win_${archExtension}.zip`; diff --git a/src/installer.ts b/src/installer.ts index d7eb276f4..b48eeb0be 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -186,14 +186,7 @@ function getDownloadInfo( ): {version: string; url: string} { version = normalizeVersion(version); - let archExtension = ''; - if (arch === 'x86') { - archExtension = 'i686'; - } else if (arch === 'x64') { - archExtension = 'x64'; - } else { - throw new Error(`architecture "${arch}" is not int [x86 | x64]`); - } + const archExtension = arch === 'x86' ? 'i686' : 'x64'; let extension = ''; if (IS_WINDOWS) { diff --git a/src/setup-java.ts b/src/setup-java.ts index db169f296..5ba352971 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -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 });