mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
@@ -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
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user