Skip to content

Commit 4fd9a47

Browse files
Allow for Local ARM64 Linux Building (#1451)
* 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
1 parent efa324a commit 4fd9a47

File tree

7 files changed

+56
-16
lines changed

7 files changed

+56
-16
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
SKIP_PREFLIGHT_CHECK=true
22
ESLINT_NO_DEV_ERRORS=true
33
DISABLE_ESLINT_PLUGIN=true
4-
SKIP_PREFLIGHT_CHECK=true

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
},
7979
"cpu": [
8080
"x64",
81-
"arm64"
81+
"arm64",
82+
"arm"
8283
],
8384
"browserslist": {
8485
"production": [
@@ -122,9 +123,9 @@
122123
"concurrently": "^6.2.1",
123124
"cross-env": "^7.0.3",
124125
"dotenv": "^10.0.0",
125-
"electron": "^19.0.4",
126-
"electron-builder": "^23.0.3",
127-
"electron-updater": "^5.0.1",
126+
"electron": "^19.0.5",
127+
"electron-builder": "^23.0.9",
128+
"electron-updater": "^5.0.4",
128129
"eslint": "^7.32.0",
129130
"eslint-config-airbnb": "^19.0.4",
130131
"eslint-config-prettier": "^8.3.0",
@@ -152,12 +153,12 @@
152153
"webpack-merge": "^5.8.0"
153154
},
154155
"dependencies": {
155-
"7zip-bin": "^5.1.1",
156156
"@loadable/babel-plugin": "^5.13.2",
157157
"@sentry/integrations": "^6.16.1",
158158
"@sentry/react": "^6.16.1",
159159
"@sentry/tracing": "^6.16.1",
160160
"@sentry/utils": "^6.16.1",
161+
"7zip-bin": "^5.1.1",
161162
"antd": "^4.21.5",
162163
"axios": "^0.27.2",
163164
"base64-stream": "^1.0.0",

public/electron.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ const get7zPath = async () => {
241241
if (process.platform === 'win32') {
242242
baseDir = path.join(baseDir, '7zip-bin/win/x64');
243243
} else if (process.platform === 'linux') {
244-
baseDir = path.join(baseDir, '7zip-bin/linux/x64');
244+
baseDir = path.join(baseDir, '7zip-bin/linux', process.arch);
245245
} else if (process.platform === 'darwin') {
246246
baseDir = path.resolve(baseDir, '../../../', '7zip-bin/mac/x64');
247247
}

scripts/createDeploy.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ if (process.platform === 'win32') {
109109
filter: '**/*'
110110
});
111111
} else if (process.platform === 'linux') {
112-
sevenZipPath = 'node_modules/7zip-bin/linux/x64/7za';
112+
if (process.arch === 'arm64') {
113+
sevenZipPath = 'node_modules/7zip-bin/linux/arm64/7za';
114+
} else if (process.arch === 'arm') {
115+
sevenZipPath = 'node_modules/7zip-bin/linux/arm/7za';
116+
} else {
117+
sevenZipPath = 'node_modules/7zip-bin/linux/x64/7za';
118+
}
113119
} else if (process.platform === 'darwin') {
114120
sevenZipPath = 'node_modules/7zip-bin/mac/x64/7za';
115121
}
@@ -191,8 +197,8 @@ const commonConfig = {
191197
...(process.platform === 'linux' && {
192198
linux:
193199
type === 'setup'
194-
? ['appimage:x64', 'zip:x64', 'deb:x64', 'rpm:x64']
195-
: ['snap:x64']
200+
? ['appimage', 'zip', 'deb', 'rpm'].map(x => `${x}:${process.arch}`)
201+
: [`snap:${process.arch}`]
196202
}),
197203
...(process.platform === 'win32' && {
198204
win: [type === 'setup' ? 'nsis:x64' : 'zip:x64']
@@ -215,6 +221,13 @@ const main = async () => {
215221

216222
const { productName } = commonConfig.config;
217223

224+
let linuxyml = '';
225+
if (process.arch === 'x64') {
226+
linuxyml = 'latest-linux.yml';
227+
} else {
228+
linuxyml = `latest-linux-${process.arch}.yml`;
229+
}
230+
218231
const allFiles = {
219232
setup: {
220233
darwin: [
@@ -232,7 +245,7 @@ const main = async () => {
232245
`${productName}-linux-${type}.AppImage`,
233246
`${productName}-linux-${type}.deb`,
234247
`${productName}-linux-${type}.rpm`,
235-
'latest-linux.yml'
248+
`${linuxyml}`
236249
]
237250
},
238251
portable: {

src/app/desktop/utils/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ export const convertOSToJavaFormat = ElectronFormat => {
8181
}
8282
};
8383

84+
export const convertArchToJavaFormat = ElectronFormat => {
85+
switch (ElectronFormat) {
86+
case 'x64':
87+
return 'amd64';
88+
case 'ia32':
89+
return 'x32';
90+
case 'arm':
91+
return 'arm';
92+
case 'arm64':
93+
return 'aarch64';
94+
default:
95+
return false;
96+
}
97+
};
98+
8499
export const skipLibrary = lib => {
85100
let skip = false;
86101
if (lib.rules) {
@@ -321,6 +336,7 @@ export const isLatestJavaDownloaded = async (
321336
version = 8
322337
) => {
323338
const javaOs = convertOSToJavaFormat(process.platform);
339+
const javaArch = convertArchToJavaFormat(process.arch);
324340
let log = null;
325341

326342
const isJavaLatest = version === LATEST_JAVA_VERSION;
@@ -330,7 +346,7 @@ export const isLatestJavaDownloaded = async (
330346
const javaMeta = manifest.find(
331347
v =>
332348
v.os === javaOs &&
333-
v.architecture === 'x64' &&
349+
v.architecture === javaArch &&
334350
(v.binary_type === 'jre' || v.binary_type === 'jdk')
335351
);
336352
const javaFolder = path.join(

src/common/modals/JavaSetup.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Modal from '../components/Modal';
1515
import { downloadFile } from '../../app/desktop/utils/downloader';
1616
import {
1717
convertOSToJavaFormat,
18+
convertArchToJavaFormat,
1819
extractAll,
1920
isLatestJavaDownloaded
2021
} from '../../app/desktop/utils';
@@ -367,11 +368,17 @@ const AutomaticSetup = ({
367368

368369
const installJava = async () => {
369370
const javaOs = convertOSToJavaFormat(process.platform);
370-
const java8Meta = javaManifest.find(v => v.os === javaOs);
371+
const javaArch = convertArchToJavaFormat(process.arch);
372+
const java8Meta = javaManifest.find(
373+
v =>
374+
v.os === javaOs &&
375+
v.architecture === javaArch &&
376+
(v.binary_type === 'jre' || v.binary_type === 'jdk')
377+
);
371378
const javaLatestMeta = javaLatestManifest.find(
372379
v =>
373380
v.os === javaOs &&
374-
v.architecture === 'x64' &&
381+
v.architecture === javaArch &&
375382
(v.binary_type === 'jre' || v.binary_type === 'jdk')
376383
);
377384

src/common/utils/selectors.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { createSelector } from 'reselect';
22
import path from 'path';
33
import memoize from 'lodash/memoize';
4-
import { convertOSToJavaFormat } from '../../app/desktop/utils';
4+
import {
5+
convertOSToJavaFormat,
6+
convertArchToJavaFormat
7+
} from '../../app/desktop/utils';
58
import { LATEST_JAVA_VERSION } from './constants';
69

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

6164
const javaOs = convertOSToJavaFormat(process.platform);
65+
const javaArch = convertArchToJavaFormat(process.arch);
6266
const javaMeta = manifest.find(
6367
version =>
6468
version.os === javaOs &&
65-
version.architecture === 'x64' &&
69+
version.architecture === javaArch &&
6670
(version.binary_type === 'jre' || version.binary_type === 'jdk')
6771
);
6872
const {

0 commit comments

Comments
 (0)