Skip to content

Commit

Permalink
Allow for Local ARM64 Linux Building (#1451)
Browse files Browse the repository at this point in the history
* update project/deploy configs

* add system architecture detection to java jre/jvm downloader

* Update package.json

* update electron-builder and electron-updater

arm is added as an alias for armv7l
makes building easier
  • Loading branch information
theofficialgman authored Jan 16, 2023
1 parent efa324a commit 4fd9a47
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 16 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
SKIP_PREFLIGHT_CHECK=true
ESLINT_NO_DEV_ERRORS=true
DISABLE_ESLINT_PLUGIN=true
SKIP_PREFLIGHT_CHECK=true
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
},
"cpu": [
"x64",
"arm64"
"arm64",
"arm"
],
"browserslist": {
"production": [
Expand Down Expand Up @@ -122,9 +123,9 @@
"concurrently": "^6.2.1",
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"electron": "^19.0.4",
"electron-builder": "^23.0.3",
"electron-updater": "^5.0.1",
"electron": "^19.0.5",
"electron-builder": "^23.0.9",
"electron-updater": "^5.0.4",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
Expand Down Expand Up @@ -152,12 +153,12 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"7zip-bin": "^5.1.1",
"@loadable/babel-plugin": "^5.13.2",
"@sentry/integrations": "^6.16.1",
"@sentry/react": "^6.16.1",
"@sentry/tracing": "^6.16.1",
"@sentry/utils": "^6.16.1",
"7zip-bin": "^5.1.1",
"antd": "^4.21.5",
"axios": "^0.27.2",
"base64-stream": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const get7zPath = async () => {
if (process.platform === 'win32') {
baseDir = path.join(baseDir, '7zip-bin/win/x64');
} else if (process.platform === 'linux') {
baseDir = path.join(baseDir, '7zip-bin/linux/x64');
baseDir = path.join(baseDir, '7zip-bin/linux', process.arch);
} else if (process.platform === 'darwin') {
baseDir = path.resolve(baseDir, '../../../', '7zip-bin/mac/x64');
}
Expand Down
21 changes: 17 additions & 4 deletions scripts/createDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ if (process.platform === 'win32') {
filter: '**/*'
});
} else if (process.platform === 'linux') {
sevenZipPath = 'node_modules/7zip-bin/linux/x64/7za';
if (process.arch === 'arm64') {
sevenZipPath = 'node_modules/7zip-bin/linux/arm64/7za';
} else if (process.arch === 'arm') {
sevenZipPath = 'node_modules/7zip-bin/linux/arm/7za';
} else {
sevenZipPath = 'node_modules/7zip-bin/linux/x64/7za';
}
} else if (process.platform === 'darwin') {
sevenZipPath = 'node_modules/7zip-bin/mac/x64/7za';
}
Expand Down Expand Up @@ -191,8 +197,8 @@ const commonConfig = {
...(process.platform === 'linux' && {
linux:
type === 'setup'
? ['appimage:x64', 'zip:x64', 'deb:x64', 'rpm:x64']
: ['snap:x64']
? ['appimage', 'zip', 'deb', 'rpm'].map(x => `${x}:${process.arch}`)
: [`snap:${process.arch}`]
}),
...(process.platform === 'win32' && {
win: [type === 'setup' ? 'nsis:x64' : 'zip:x64']
Expand All @@ -215,6 +221,13 @@ const main = async () => {

const { productName } = commonConfig.config;

let linuxyml = '';
if (process.arch === 'x64') {
linuxyml = 'latest-linux.yml';
} else {
linuxyml = `latest-linux-${process.arch}.yml`;
}

const allFiles = {
setup: {
darwin: [
Expand All @@ -232,7 +245,7 @@ const main = async () => {
`${productName}-linux-${type}.AppImage`,
`${productName}-linux-${type}.deb`,
`${productName}-linux-${type}.rpm`,
'latest-linux.yml'
`${linuxyml}`
]
},
portable: {
Expand Down
18 changes: 17 additions & 1 deletion src/app/desktop/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ export const convertOSToJavaFormat = ElectronFormat => {
}
};

export const convertArchToJavaFormat = ElectronFormat => {
switch (ElectronFormat) {
case 'x64':
return 'amd64';
case 'ia32':
return 'x32';
case 'arm':
return 'arm';
case 'arm64':
return 'aarch64';
default:
return false;
}
};

export const skipLibrary = lib => {
let skip = false;
if (lib.rules) {
Expand Down Expand Up @@ -321,6 +336,7 @@ export const isLatestJavaDownloaded = async (
version = 8
) => {
const javaOs = convertOSToJavaFormat(process.platform);
const javaArch = convertArchToJavaFormat(process.arch);
let log = null;

const isJavaLatest = version === LATEST_JAVA_VERSION;
Expand All @@ -330,7 +346,7 @@ export const isLatestJavaDownloaded = async (
const javaMeta = manifest.find(
v =>
v.os === javaOs &&
v.architecture === 'x64' &&
v.architecture === javaArch &&
(v.binary_type === 'jre' || v.binary_type === 'jdk')
);
const javaFolder = path.join(
Expand Down
11 changes: 9 additions & 2 deletions src/common/modals/JavaSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Modal from '../components/Modal';
import { downloadFile } from '../../app/desktop/utils/downloader';
import {
convertOSToJavaFormat,
convertArchToJavaFormat,
extractAll,
isLatestJavaDownloaded
} from '../../app/desktop/utils';
Expand Down Expand Up @@ -367,11 +368,17 @@ const AutomaticSetup = ({

const installJava = async () => {
const javaOs = convertOSToJavaFormat(process.platform);
const java8Meta = javaManifest.find(v => v.os === javaOs);
const javaArch = convertArchToJavaFormat(process.arch);
const java8Meta = javaManifest.find(
v =>
v.os === javaOs &&
v.architecture === javaArch &&
(v.binary_type === 'jre' || v.binary_type === 'jdk')
);
const javaLatestMeta = javaLatestManifest.find(
v =>
v.os === javaOs &&
v.architecture === 'x64' &&
v.architecture === javaArch &&
(v.binary_type === 'jre' || v.binary_type === 'jdk')
);

Expand Down
8 changes: 6 additions & 2 deletions src/common/utils/selectors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { createSelector } from 'reselect';
import path from 'path';
import memoize from 'lodash/memoize';
import { convertOSToJavaFormat } from '../../app/desktop/utils';
import {
convertOSToJavaFormat,
convertArchToJavaFormat
} from '../../app/desktop/utils';
import { LATEST_JAVA_VERSION } from './constants';

const _instances = state => state.instances;
Expand Down Expand Up @@ -59,10 +62,11 @@ export const _getJavaPath = createSelector(
ver === LATEST_JAVA_VERSION ? java.pathLatest : java.path;

const javaOs = convertOSToJavaFormat(process.platform);
const javaArch = convertArchToJavaFormat(process.arch);
const javaMeta = manifest.find(
version =>
version.os === javaOs &&
version.architecture === 'x64' &&
version.architecture === javaArch &&
(version.binary_type === 'jre' || version.binary_type === 'jdk')
);
const {
Expand Down

0 comments on commit 4fd9a47

Please sign in to comment.