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
3 changed files with 23 additions and 4 deletions

View File

@@ -25,6 +25,7 @@
*/ */
const compileTypeScriptIfRequired = require('./typescript-if-required'); const compileTypeScriptIfRequired = require('./typescript-if-required');
const os = require('os');
const firefoxVersions = const firefoxVersions =
'https://product-details.mozilla.org/1.0/firefox_versions.json'; 'https://product-details.mozilla.org/1.0/firefox_versions.json';
@@ -99,9 +100,11 @@ async function download() {
* @return {!Promise} * @return {!Promise}
*/ */
function onSuccess(localRevisions) { function onSuccess(localRevisions) {
logPolitely( if (os.arch() !== 'arm64') {
`${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}` logPolitely(
); `${supportedProducts[product]} (${revisionInfo.revision}) downloaded to ${revisionInfo.folderPath}`
);
}
localRevisions = localRevisions.filter( localRevisions = localRevisions.filter(
(revision) => revision !== revisionInfo.revision (revision) => revision !== revisionInfo.revision
); );

View File

@@ -101,6 +101,16 @@ function downloadURL(
return url; 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 readdirAsync = helper.promisify(fs.readdir.bind(fs));
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs)); const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
const unlinkAsync = helper.promisify(fs.unlink.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(outputPath)) return this.revisionInfo(revision);
if (!(await existsAsync(this._downloadsFolder))) if (!(await existsAsync(this._downloadsFolder)))
await mkdirAsync(this._downloadsFolder); await mkdirAsync(this._downloadsFolder);
if (os.arch() === 'arm64') {
handleArm64();
return;
}
try { try {
await downloadFile(url, archivePath, progressCallback); await downloadFile(url, archivePath, progressCallback);
await install(archivePath, outputPath); await install(archivePath, outputPath);

View File

@@ -106,7 +106,9 @@ class ChromeLauncher implements ProductLauncher {
} }
let chromeExecutable = executablePath; let chromeExecutable = executablePath;
if (!executablePath) { if (os.arch() === 'arm64') {
chromeExecutable = '/usr/bin/chromium-browser';
} else if (!executablePath) {
const { missingText, executablePath } = resolveExecutablePath(this); const { missingText, executablePath } = resolveExecutablePath(this);
if (missingText) throw new Error(missingText); if (missingText) throw new Error(missingText);
chromeExecutable = executablePath; chromeExecutable = executablePath;