Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Apple Silicon) aarch64 OpenJDK detect and install #273

Merged
merged 8 commits into from
Mar 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/assets/js/assetguard.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,17 @@ class DLTracker {

class Util {


isARM64 = process.arch === "arm64";
dscalzi marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns true if the actual version is greater than
* or equal to the desired version.
*
* @param {string} desired The desired version.
* @param {string} actual The actual version.
*/

static mcVersionAtLeast(desired, actual){
const des = desired.split('.')
const act = actual.split('.')
Expand Down Expand Up @@ -302,7 +306,7 @@ class JavaGuard extends EventEmitter {
break
}

const arch = process.arch.includes('arm') ? 'aarch64' : 'x64'
const arch = isARM64 ? 'aarch64' : 'x64'
const url = `https://corretto.aws/downloads/latest/amazon-corretto-${major}-${arch}-${sanitizedOS}-jdk.${ext}`

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -904,7 +908,7 @@ class JavaGuard extends EventEmitter {
// TODO Revise this a bit, seems to work for now. Discovery logic should
// probably just filter out the invalid architectures before it even
// gets to this point.
if (process.arch.includes('arm')) {
if (isARM64) {
return pathArr.find(({ isARM }) => isARM)?.execPath ?? null
} else {
return pathArr.find(({ isARM }) => !isARM)?.execPath ?? null
Expand Down