From 354f9424ae4014e0cd276a930d86a6dae8fe427e Mon Sep 17 00:00:00 2001 From: ossdev07 <39188636+ossdev07@users.noreply.github.com> Date: Wed, 10 Jun 2020 20:44:23 +0530 Subject: [PATCH] feat: improve error reporting on aarch64 (#5167) * feat: support aarch64 architecture This patch provides architecture check for aarch64 to use local chromium binary. Fixes #5147 --- install.js | 9 ++++++--- src/BrowserFetcher.ts | 14 ++++++++++++++ src/Launcher.ts | 4 +++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/install.js b/install.js index 7398398ffcd..e33485cd0e7 100644 --- a/install.js +++ b/install.js @@ -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'; @@ -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 ); diff --git a/src/BrowserFetcher.ts b/src/BrowserFetcher.ts index b46fec8890b..9c63c968a58 100644 --- a/src/BrowserFetcher.ts +++ b/src/BrowserFetcher.ts @@ -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)); @@ -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); diff --git a/src/Launcher.ts b/src/Launcher.ts index f6e90eaebad..7499ca3e2d0 100644 --- a/src/Launcher.ts +++ b/src/Launcher.ts @@ -106,7 +106,9 @@ class ChromeLauncher implements ProductLauncher { } let chromeExecutable = executablePath; - if (!executablePath) { + if (os.arch() === 'arm64') { + chromeExecutable = '/usr/bin/chromium-browser'; + } else if (!executablePath) { const { missingText, executablePath } = resolveExecutablePath(this); if (missingText) throw new Error(missingText); chromeExecutable = executablePath;