Skip to content

Commit

Permalink
feat: improve error reporting on aarch64 (#5167)
Browse files Browse the repository at this point in the history
* feat: support aarch64 architecture

This patch provides architecture check for aarch64 to use local chromium binary.

Fixes #5147
  • Loading branch information
ossdev07 committed Jun 10, 2020
1 parent 9c656d4 commit 354f942
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
9 changes: 6 additions & 3 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

const compileTypeScriptIfRequired = require('./typescript-if-required');
const os = require('os');

const firefoxVersions =
'https://product-details.mozilla.org/1.0/firefox_versions.json';
Expand Down Expand Up @@ -99,9 +100,11 @@ async function download() {
* @return {!Promise}
*/
function onSuccess(localRevisions) {
logPolitely(
`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`
);
if (os.arch() !== 'arm64') {
logPolitely(
`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`
);
}
localRevisions = localRevisions.filter(
(revision) => revision !== revisionInfo.revision
);
Expand Down
14 changes: 14 additions & 0 deletions src/BrowserFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ function downloadURL(
return url;
}

function handleArm64() {
fs.stat('/usr/bin/chromium-browser', function (err, stats) {
if (stats === undefined) {
console.error(`The chromium binary is not available for arm64: `);
console.error(`If you are on Ubuntu, you can install with: `);
console.error(`\n apt-get install chromium-browser\n`);
throw new Error();
}
});
}
const readdirAsync = helper.promisify(fs.readdir.bind(fs));
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
const unlinkAsync = helper.promisify(fs.unlink.bind(fs));
Expand Down Expand Up @@ -219,6 +229,10 @@ export class BrowserFetcher {
if (await existsAsync(outputPath)) return this.revisionInfo(revision);
if (!(await existsAsync(this._downloadsFolder)))
await mkdirAsync(this._downloadsFolder);
if (os.arch() === 'arm64') {
handleArm64();
return;
}
try {
await downloadFile(url, archivePath, progressCallback);
await install(archivePath, outputPath);
Expand Down
4 changes: 3 additions & 1 deletion src/Launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class ChromeLauncher implements ProductLauncher {
}

let chromeExecutable = executablePath;
if (!executablePath) {
if (os.arch() === 'arm64') {
chromeExecutable = '/usr/bin/chromium-browser';

This comment has been minimized.

Copy link
@fxp

fxp Oct 6, 2020

Why static path? Some RaspberryPi OS don't have chromium on this path.

} else if (!executablePath) {
const { missingText, executablePath } = resolveExecutablePath(this);
if (missingText) throw new Error(missingText);
chromeExecutable = executablePath;
Expand Down

0 comments on commit 354f942

Please sign in to comment.