Skip to content

Commit d34a7e4

Browse files
AustinShalitemgre
andauthored
Architecture Support (actions#95)
* Quick fix for 32-bit architecture support. * Validate arch at input Co-authored-by: Émile Grégoire <eg@emilegregoire.ca>
1 parent 3019d15 commit d34a7e4

File tree

4 files changed

+72
-85
lines changed

4 files changed

+72
-85
lines changed

dist/index.js

Lines changed: 47 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28685,6 +28685,9 @@ function run() {
2868528685
version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
2868628686
}
2868728687
const arch = core.getInput(constants.INPUT_ARCHITECTURE, { required: true });
28688+
if (!['x86', 'x64'].includes(arch)) {
28689+
throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
28690+
}
2868828691
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
2868928692
required: true
2869028693
});
@@ -33423,7 +33426,7 @@ function getJava(version, arch, jdkFile, javaPackage) {
3342333426
}
3342433427
const contents = yield response.readBody();
3342533428
const refs = contents.match(/<a href.*\">/gi) || [];
33426-
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
33429+
const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
3342733430
jdkFile = yield tc.downloadTool(downloadInfo.url);
3342833431
version = downloadInfo.version;
3342933432
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@@ -33539,20 +33542,22 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) {
3353933542
}
3354033543
});
3354133544
}
33542-
function getDownloadInfo(refs, version, javaPackage) {
33545+
function getDownloadInfo(refs, version, arch, javaPackage) {
3354333546
version = normalizeVersion(version);
33547+
const archExtension = arch === 'x86' ? 'i686' : 'x64';
3354433548
let extension = '';
3354533549
if (IS_WINDOWS) {
33546-
extension = `-win_x64.zip`;
33550+
extension = `-win_${archExtension}.zip`;
3354733551
}
3354833552
else {
3354933553
if (process.platform === 'darwin') {
33550-
extension = `-macosx_x64.tar.gz`;
33554+
extension = `-macosx_${archExtension}.tar.gz`;
3355133555
}
3355233556
else {
33553-
extension = `-linux_x64.tar.gz`;
33557+
extension = `-linux_${archExtension}.tar.gz`;
3355433558
}
3355533559
}
33560+
core.debug(`Searching for files with extension: ${extension}`);
3355633561
let pkgRegexp = new RegExp('');
3355733562
let pkgTypeLength = 0;
3355833563
if (javaPackage === 'jdk') {

src/installer.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function getJava(
4545

4646
const contents = await response.readBody();
4747
const refs = contents.match(/<a href.*\">/gi) || [];
48-
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
48+
const downloadInfo = getDownloadInfo(refs, version, arch, javaPackage);
4949
jdkFile = await tc.downloadTool(downloadInfo.url);
5050
version = downloadInfo.version;
5151
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
@@ -181,20 +181,26 @@ async function unzipJavaDownload(
181181
function getDownloadInfo(
182182
refs: string[],
183183
version: string,
184+
arch: string,
184185
javaPackage: string
185186
): {version: string; url: string} {
186187
version = normalizeVersion(version);
188+
189+
const archExtension = arch === 'x86' ? 'i686' : 'x64';
190+
187191
let extension = '';
188192
if (IS_WINDOWS) {
189-
extension = `-win_x64.zip`;
193+
extension = `-win_${archExtension}.zip`;
190194
} else {
191195
if (process.platform === 'darwin') {
192-
extension = `-macosx_x64.tar.gz`;
196+
extension = `-macosx_${archExtension}.tar.gz`;
193197
} else {
194-
extension = `-linux_x64.tar.gz`;
198+
extension = `-linux_${archExtension}.tar.gz`;
195199
}
196200
}
197201

202+
core.debug(`Searching for files with extension: ${extension}`);
203+
198204
let pkgRegexp = new RegExp('');
199205
let pkgTypeLength = 0;
200206
if (javaPackage === 'jdk') {

src/setup-java.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ async function run() {
1111
if (!version) {
1212
version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
1313
}
14+
1415
const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true});
16+
if (!['x86', 'x64'].includes(arch)) {
17+
throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
18+
}
19+
1520
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
1621
required: true
1722
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy