Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/linux/debian/calculate-deps.js
3520 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
exports.generatePackageDeps = generatePackageDeps;
7
/*---------------------------------------------------------------------------------------------
8
* Copyright (c) Microsoft Corporation. All rights reserved.
9
* Licensed under the MIT License. See License.txt in the project root for license information.
10
*--------------------------------------------------------------------------------------------*/
11
const child_process_1 = require("child_process");
12
const fs_1 = require("fs");
13
const os_1 = require("os");
14
const path_1 = __importDefault(require("path"));
15
const cgmanifest_json_1 = __importDefault(require("../../../cgmanifest.json"));
16
const dep_lists_1 = require("./dep-lists");
17
function generatePackageDeps(files, arch, chromiumSysroot, vscodeSysroot) {
18
const dependencies = files.map(file => calculatePackageDeps(file, arch, chromiumSysroot, vscodeSysroot));
19
const additionalDepsSet = new Set(dep_lists_1.additionalDeps);
20
dependencies.push(additionalDepsSet);
21
return dependencies;
22
}
23
// Based on https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/debian/calculate_package_deps.py.
24
function calculatePackageDeps(binaryPath, arch, chromiumSysroot, vscodeSysroot) {
25
try {
26
if (!((0, fs_1.statSync)(binaryPath).mode & fs_1.constants.S_IXUSR)) {
27
throw new Error(`Binary ${binaryPath} needs to have an executable bit set.`);
28
}
29
}
30
catch (e) {
31
// The package might not exist. Don't re-throw the error here.
32
console.error('Tried to stat ' + binaryPath + ' but failed.');
33
}
34
// Get the Chromium dpkg-shlibdeps file.
35
const chromiumManifest = cgmanifest_json_1.default.registrations.filter(registration => {
36
return registration.component.type === 'git' && registration.component.git.name === 'chromium';
37
});
38
const dpkgShlibdepsUrl = `https://raw.githubusercontent.com/chromium/chromium/${chromiumManifest[0].version}/third_party/dpkg-shlibdeps/dpkg-shlibdeps.pl`;
39
const dpkgShlibdepsScriptLocation = `${(0, os_1.tmpdir)()}/dpkg-shlibdeps.pl`;
40
const result = (0, child_process_1.spawnSync)('curl', [dpkgShlibdepsUrl, '-o', dpkgShlibdepsScriptLocation]);
41
if (result.status !== 0) {
42
throw new Error('Cannot retrieve dpkg-shlibdeps. Stderr:\n' + result.stderr);
43
}
44
const cmd = [dpkgShlibdepsScriptLocation, '--ignore-weak-undefined'];
45
switch (arch) {
46
case 'amd64':
47
cmd.push(`-l${chromiumSysroot}/usr/lib/x86_64-linux-gnu`, `-l${chromiumSysroot}/lib/x86_64-linux-gnu`, `-l${vscodeSysroot}/usr/lib/x86_64-linux-gnu`, `-l${vscodeSysroot}/lib/x86_64-linux-gnu`);
48
break;
49
case 'armhf':
50
cmd.push(`-l${chromiumSysroot}/usr/lib/arm-linux-gnueabihf`, `-l${chromiumSysroot}/lib/arm-linux-gnueabihf`, `-l${vscodeSysroot}/usr/lib/arm-linux-gnueabihf`, `-l${vscodeSysroot}/lib/arm-linux-gnueabihf`);
51
break;
52
case 'arm64':
53
cmd.push(`-l${chromiumSysroot}/usr/lib/aarch64-linux-gnu`, `-l${chromiumSysroot}/lib/aarch64-linux-gnu`, `-l${vscodeSysroot}/usr/lib/aarch64-linux-gnu`, `-l${vscodeSysroot}/lib/aarch64-linux-gnu`);
54
break;
55
}
56
cmd.push(`-l${chromiumSysroot}/usr/lib`);
57
cmd.push(`-L${vscodeSysroot}/debian/libxkbfile1/DEBIAN/shlibs`);
58
cmd.push('-O', '-e', path_1.default.resolve(binaryPath));
59
const dpkgShlibdepsResult = (0, child_process_1.spawnSync)('perl', cmd, { cwd: chromiumSysroot });
60
if (dpkgShlibdepsResult.status !== 0) {
61
throw new Error(`dpkg-shlibdeps failed with exit code ${dpkgShlibdepsResult.status}. stderr:\n${dpkgShlibdepsResult.stderr} `);
62
}
63
const shlibsDependsPrefix = 'shlibs:Depends=';
64
const requiresList = dpkgShlibdepsResult.stdout.toString('utf-8').trimEnd().split('\n');
65
let depsStr = '';
66
for (const line of requiresList) {
67
if (line.startsWith(shlibsDependsPrefix)) {
68
depsStr = line.substring(shlibsDependsPrefix.length);
69
}
70
}
71
// Refs https://chromium-review.googlesource.com/c/chromium/src/+/3572926
72
// Chromium depends on libgcc_s, is from the package libgcc1. However, in
73
// Bullseye, the package was renamed to libgcc-s1. To avoid adding a dep
74
// on the newer package, this hack skips the dep. This is safe because
75
// libgcc-s1 is a dependency of libc6. This hack can be removed once
76
// support for Debian Buster and Ubuntu Bionic are dropped.
77
//
78
// Remove kerberos native module related dependencies as the versions
79
// computed from sysroot will not satisfy the minimum supported distros
80
// Refs https://github.com/microsoft/vscode/issues/188881.
81
// TODO(deepak1556): remove this workaround in favor of computing the
82
// versions from build container for native modules.
83
const filteredDeps = depsStr.split(', ').filter(dependency => {
84
return !dependency.startsWith('libgcc-s1');
85
}).sort();
86
const requires = new Set(filteredDeps);
87
return requires;
88
}
89
//# sourceMappingURL=calculate-deps.js.map
90