Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/linux/rpm/calculate-deps.js
3520 views
1
"use strict";
2
Object.defineProperty(exports, "__esModule", { value: true });
3
exports.generatePackageDeps = generatePackageDeps;
4
/*---------------------------------------------------------------------------------------------
5
* Copyright (c) Microsoft Corporation. All rights reserved.
6
* Licensed under the MIT License. See License.txt in the project root for license information.
7
*--------------------------------------------------------------------------------------------*/
8
const child_process_1 = require("child_process");
9
const fs_1 = require("fs");
10
const dep_lists_1 = require("./dep-lists");
11
function generatePackageDeps(files) {
12
const dependencies = files.map(file => calculatePackageDeps(file));
13
const additionalDepsSet = new Set(dep_lists_1.additionalDeps);
14
dependencies.push(additionalDepsSet);
15
return dependencies;
16
}
17
// Based on https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/rpm/calculate_package_deps.py.
18
function calculatePackageDeps(binaryPath) {
19
try {
20
if (!((0, fs_1.statSync)(binaryPath).mode & fs_1.constants.S_IXUSR)) {
21
throw new Error(`Binary ${binaryPath} needs to have an executable bit set.`);
22
}
23
}
24
catch (e) {
25
// The package might not exist. Don't re-throw the error here.
26
console.error('Tried to stat ' + binaryPath + ' but failed.');
27
}
28
const findRequiresResult = (0, child_process_1.spawnSync)('/usr/lib/rpm/find-requires', { input: binaryPath + '\n' });
29
if (findRequiresResult.status !== 0) {
30
throw new Error(`find-requires failed with exit code ${findRequiresResult.status}.\nstderr: ${findRequiresResult.stderr}`);
31
}
32
const requires = new Set(findRequiresResult.stdout.toString('utf-8').trimEnd().split('\n'));
33
return requires;
34
}
35
//# sourceMappingURL=calculate-deps.js.map
36