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
This commit is contained in:
ossdev07 2020-06-10 20:44:23 +05:30 committed by GitHub
parent 9c656d417e
commit 354f9424ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -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
);

View File

@ -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);

View File

@ -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;