fix(launchdoctor): fix launch doctor (#4387)

New webkit build, generated by 19f21b1bde, changed webkit build
layout: now there are subfolders that contain libraries and executables, and some of the dependencies are no longer bundled.

This patch:
- teaches launch doctor new directories structure: subfolders are now inspected for missing dependencies, and they are also used in the `LD_LIBRARY_PATH`.
- adds `libevent` and `libicudata` libs to the mapping for ubuntu 18.04
This commit is contained in:
Andrey Lushnikov 2020-11-09 16:47:15 -08:00 committed by GitHub
parent 488b256c47
commit 775be21db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -109,7 +109,7 @@ async function validateDependenciesLinux(browserPath: string, browser: BrowserDe
const lddPaths: string[] = []; const lddPaths: string[] = [];
for (const directoryPath of directoryPaths) for (const directoryPath of directoryPaths)
lddPaths.push(...(await executablesOrSharedLibraries(directoryPath))); lddPaths.push(...(await executablesOrSharedLibraries(directoryPath)));
const allMissingDeps = await Promise.all(lddPaths.map(lddPath => missingFileDependencies(lddPath))); const allMissingDeps = await Promise.all(lddPaths.map(lddPath => missingFileDependencies(lddPath, directoryPaths)));
const missingDeps: Set<string> = new Set(); const missingDeps: Set<string> = new Set();
for (const deps of allMissingDeps) { for (const deps of allMissingDeps) {
for (const dep of deps) for (const dep of deps)
@ -210,18 +210,21 @@ async function missingFileDependenciesWindows(filePath: string): Promise<Array<s
return missingDeps; return missingDeps;
} }
async function missingFileDependencies(filePath: string): Promise<Array<string>> { async function missingFileDependencies(filePath: string, extraLDPaths: string[]): Promise<Array<string>> {
const dirname = path.dirname(filePath); const dirname = path.dirname(filePath);
let LD_LIBRARY_PATH = extraLDPaths.join(':');
if (process.env.LD_LIBRARY_PATH)
LD_LIBRARY_PATH = `${process.env.LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}`;
const {stdout, code} = await spawnAsync('ldd', [filePath], { const {stdout, code} = await spawnAsync('ldd', [filePath], {
cwd: dirname, cwd: dirname,
env: { env: {
...process.env, ...process.env,
LD_LIBRARY_PATH: process.env.LD_LIBRARY_PATH ? `${process.env.LD_LIBRARY_PATH}:${dirname}` : dirname, LD_LIBRARY_PATH,
}, },
}); });
if (code !== 0) if (code !== 0)
return []; return [];
const missingDeps = stdout.split('\n').map(line => line.trim()).filter(line => line.endsWith('not found') && line.includes('=>')).map(line => line.split('=>')[0].trim().toLowerCase()); const missingDeps = stdout.split('\n').map(line => line.trim()).filter(line => line.endsWith('not found') && line.includes('=>')).map(line => line.split('=>')[0].trim());
return missingDeps; return missingDeps;
} }
@ -269,6 +272,7 @@ const LIBRARY_TO_PACKAGE_NAME_UBUNTU_18_04: { [s: string]: string} = {
'libEGL.so.1': 'libegl1', 'libEGL.so.1': 'libegl1',
'libenchant.so.1': 'libenchant1c2a', 'libenchant.so.1': 'libenchant1c2a',
'libepoxy.so.0': 'libepoxy0', 'libepoxy.so.0': 'libepoxy0',
'libevent-2.1.so.6': 'libevent-2.1-6',
'libfontconfig.so.1': 'libfontconfig1', 'libfontconfig.so.1': 'libfontconfig1',
'libfreetype.so.6': 'libfreetype6', 'libfreetype.so.6': 'libfreetype6',
'libgbm.so.1': 'libgbm1', 'libgbm.so.1': 'libgbm1',
@ -297,6 +301,7 @@ const LIBRARY_TO_PACKAGE_NAME_UBUNTU_18_04: { [s: string]: string} = {
'libharfbuzz-icu.so.0': 'libharfbuzz-icu0', 'libharfbuzz-icu.so.0': 'libharfbuzz-icu0',
'libharfbuzz.so.0': 'libharfbuzz0b', 'libharfbuzz.so.0': 'libharfbuzz0b',
'libhyphen.so.0': 'libhyphen0', 'libhyphen.so.0': 'libhyphen0',
'libicudata.so.60': 'libicu60',
'libicui18n.so.60': 'libicu60', 'libicui18n.so.60': 'libicu60',
'libicuuc.so.60': 'libicu60', 'libicuuc.so.60': 'libicu60',
'libjpeg.so.8': 'libjpeg-turbo8', 'libjpeg.so.8': 'libjpeg-turbo8',

View file

@ -56,7 +56,11 @@ export function linuxLddDirectories(browserPath: string, browser: BrowserDescrip
if (browser.name === 'webkit') { if (browser.name === 'webkit') {
return [ return [
path.join(browserPath, 'minibrowser-gtk'), path.join(browserPath, 'minibrowser-gtk'),
path.join(browserPath, 'minibrowser-gtk', 'bin'),
path.join(browserPath, 'minibrowser-gtk', 'lib'),
path.join(browserPath, 'minibrowser-wpe'), path.join(browserPath, 'minibrowser-wpe'),
path.join(browserPath, 'minibrowser-wpe', 'bin'),
path.join(browserPath, 'minibrowser-wpe', 'lib'),
]; ];
} }
return []; return [];