From d34a7e45c8812086e1d752fd33b1ba46216a6fdd Mon Sep 17 00:00:00 2001 From: Austin Shalit Date: Mon, 24 Aug 2020 06:35:41 -0400 Subject: [PATCH] Architecture Support (#95) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Quick fix for 32-bit architecture support. * Validate arch at input Co-authored-by: Émile Grégoire --- dist/index.js | Bin 169530 -> 168618 bytes dist/setup/index.js | 15 ++++++++++----- src/installer.ts | 14 ++++++++++---- src/setup-java.ts | 5 +++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dist/index.js b/dist/index.js index d77e3beb31427bed5ab566eabefe2c8b0a2a2b67..d81245c076c8dfc79aea8ac3e49578ca42ac0ad3 100644 GIT binary patch delta 1252 zcmaKsPiz}S6vj0#P8yunP2#vsn?D+FQ+ro&7lNt?6_Qe-RzXS|lN6~{aFgwNVlT0G z-Q98G)^?SO1Es*BSjv;QBLs~Qhe(UK0EeOqBm^7?2dByrK@U`Fk&?86v7Lsfk-C@F z%=>*a@4atkzFzcx{)u;fiM+Gy{;*6Ep5bB6GecIKIqGR^mc^sYPHQGJdFpb6{vR7- zj+M1_R%Nya#u*#sNoGgzMwxWstupDvJ7sbR|1OgNKDR=;v3G?Wa8Is~JNt-)z6T^I ze&h=gy}la`;^YIeL}c_oB(Jn9^f={7!%-*GT5gPS+h7jurG0qyA^9^vZRTVw(_w0w zIgXZKG!&v3{g`yPU;RVo>q1`o)F~3s){>nZu7!SrT43T;o}%a-hUOQY5^&KzeX~gLvGJ z!Vq}XquF{A?~X%f=>@;Xy`6x;I$TY`yQM!meeREGcxz7$Ih=>rMk?^hoam_|ED|+^ z!!K7&Hm0duiP3=pF`0X*KdjLFmi;?aM!z61_yGi--=^w6`fOEB02ut4bYRz2Xz8yg z4bF6)wHcLq@|AH>qJ~3Fi&MkobV4LT3smT0Q%Wt-B3{VD>wy}*RY_63Vq~UjYe#RA zKHSJdpnV6#HCs(wnZoaWB5eyz;ICjl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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') { diff --git a/src/installer.ts b/src/installer.ts index 88a8ff18..b48eeb0b 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -45,7 +45,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'; @@ -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') { diff --git a/src/setup-java.ts b/src/setup-java.ts index db169f29..5ba35297 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 });