Fix dependency error in plan-publish.js

This commit is contained in:
Radon Rosborough 2021-01-17 21:26:20 -08:00
parent a29329f71c
commit 36a0a86bd3
2 changed files with 85 additions and 71 deletions

View File

@ -31,6 +31,8 @@ export async function getSharedDeps() {
// Return a list of objects representing the packages to be built. See // Return a list of objects representing the packages to be built. See
// the function implementation for the full list of keys. // the function implementation for the full list of keys.
export async function getPackages() { export async function getPackages() {
// The order (shared, lang, config) is important to get dependencies
// correct due to poor abstractions in plan-publish.js.
const packages = []; const packages = [];
for (const lang of await getSharedDeps()) { for (const lang of await getSharedDeps()) {
const type = "shared"; const type = "shared";

View File

@ -92,8 +92,7 @@ async function planDebianPackages(opts) {
(await getLangs()).map(async (id) => [id, await readLangConfig(id)]) (await getLangs()).map(async (id) => [id, await readLangConfig(id)])
) )
); );
return _.sortBy( const plan = await Promise.all(
await Promise.all(
packages.map(async ({ lang, type, name, buildScriptPath, debPath }) => { packages.map(async ({ lang, type, name, buildScriptPath, debPath }) => {
const desired = crypto const desired = crypto
.createHash("sha1") .createHash("sha1")
@ -159,13 +158,26 @@ async function planDebianPackages(opts) {
type, type,
}; };
}) })
),
({ type, desired, local, remote }) => {
// If *not* a shared package, and all we have to do is download
// it, then sort to the end.
return type !== "shared" && local !== desired && remote === desired;
}
); );
const lazilyDownloadedLanguages = new Set();
for (const { type, lang, desired, local, remote } of plan) {
if (type === "shared") {
continue;
}
// If *not* a shared package, and all we have to do is download
// it, then sort to the end. Unless of course this is the lang
// package, and we need to rebuild the config package, in which
// case the config package (which comes later) will remove that
// lang from the set again.
if (local !== desired && remote === desired) {
lazilyDownloadedLanguages.add(lang);
} else {
lazilyDownloadedLanguages.delete(lang);
}
}
return _.sortBy(plan, ({ type, lang }) => {
return type !== "shared" && lazilyDownloadedLanguages.has(lang);
});
} }
async function computePlan() { async function computePlan() {