mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Polish RPM dependencies generator (#147336)
* Print dependencies * Add reference deps for rpm package * Add flag to control new deps behaviour * Add dependencies by arch * Link arch properly
This commit is contained in:
@@ -9,7 +9,15 @@ const child_process_1 = require("child_process");
|
||||
const fs_1 = require("fs");
|
||||
const path = require("path");
|
||||
const dep_lists_1 = require("./dep-lists");
|
||||
function getDependencies(buildDir, applicationName) {
|
||||
// A flag that can easily be toggled.
|
||||
// Make sure to compile the build directory after toggling the value.
|
||||
// If false, we warn about new dependencies if they show up
|
||||
// while running the rpm prepare package task for a release.
|
||||
// If true, we fail the build if there are new dependencies found during that task.
|
||||
// The reference dependencies, which one has to update when the new dependencies
|
||||
// are valid, are in dep-lists.ts
|
||||
const FAIL_BUILD_FOR_NEW_DEPENDENCIES = true;
|
||||
function getDependencies(buildDir, applicationName, arch) {
|
||||
// Get the files for which we want to find dependencies.
|
||||
const nativeModulesPath = path.join(buildDir, 'resources', 'app', 'node_modules.asar.unpacked');
|
||||
const findResult = (0, child_process_1.spawnSync)('find', [nativeModulesPath, '-name', '*.node']);
|
||||
@@ -40,9 +48,22 @@ function getDependencies(buildDir, applicationName) {
|
||||
sortedDependencies = sortedDependencies.filter(dependency => {
|
||||
return !dep_lists_1.bundledDeps.some(bundledDep => dependency.startsWith(bundledDep));
|
||||
});
|
||||
const referenceGeneratedDeps = dep_lists_1.referenceGeneratedDepsByArch[arch];
|
||||
if (JSON.stringify(sortedDependencies) !== JSON.stringify(referenceGeneratedDeps)) {
|
||||
const failMessage = 'The dependencies list has changed. '
|
||||
+ 'Printing newer dependencies list that one can use to compare against referenceGeneratedDeps:\n'
|
||||
+ sortedDependencies.join('\n');
|
||||
if (FAIL_BUILD_FOR_NEW_DEPENDENCIES) {
|
||||
throw new Error(failMessage);
|
||||
}
|
||||
else {
|
||||
console.warn(failMessage);
|
||||
}
|
||||
}
|
||||
return sortedDependencies;
|
||||
}
|
||||
exports.getDependencies = getDependencies;
|
||||
// Based on https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/rpm/calculate_package_deps.py.
|
||||
function calculatePackageDeps(binaryPath) {
|
||||
try {
|
||||
if (!((0, fs_1.statSync)(binaryPath).mode & fs_1.constants.S_IXUSR)) {
|
||||
@@ -58,9 +79,6 @@ function calculatePackageDeps(binaryPath) {
|
||||
throw new Error(`find-requires failed with exit code ${findRequiresResult.status}.\nstderr: ${findRequiresResult.stderr}`);
|
||||
}
|
||||
const requires = new Set(findRequiresResult.stdout.toString('utf-8').trimEnd().split('\n'));
|
||||
// we only need to use provides to check for newer dependencies
|
||||
// const provides = readFileSync('dist_package_provides.json');
|
||||
// const jsonProvides = JSON.parse(provides.toString('utf-8'));
|
||||
return requires;
|
||||
}
|
||||
// Based on https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/rpm/merge_package_deps.py
|
||||
|
||||
Reference in New Issue
Block a user