Add SHA hashes for packages (#1351)

This commit is contained in:
be5invis 2022-05-13 00:17:38 -07:00
parent c901d79f70
commit 8ef19e1b65
2 changed files with 45 additions and 16 deletions

View file

@ -0,0 +1,31 @@
const fs = require("fs");
const crypto = require("crypto");
module.exports = async function (out, archiveFiles) {
let s = "";
for (const file of archiveFiles) {
s += `${file.base}\t${await hashFile(file.full)}\n`;
}
await fs.promises.writeFile(out, s);
};
function hashFile(path) {
return new Promise((resolve, reject) => {
let sum = crypto.createHash("sha256");
let fileStream = fs.createReadStream(path);
fileStream.on("error", err => {
return reject(err);
});
fileStream.on("data", chunk => {
try {
sum.update(chunk);
} catch (ex) {
return reject(ex);
}
});
fileStream.on("end", () => {
return resolve(sum.digest("hex"));
});
});
}

View file

@ -889,28 +889,26 @@ phony(`clean`, async () => {
build.deleteJournal();
});
phony(`release`, async target => {
const [collectPlans] = await target.need(CollectPlans);
const [version, collectPlans] = await target.need(Version, CollectPlans);
let goals = [];
for (const [cgr, plan] of Object.entries(collectPlans)) {
if (!plan.inRelease) continue;
goals.push(ReleaseGroup(cgr));
const subGroups = collectPlans[cgr].groupDecomposition;
goals.push(TtcArchiveFile(cgr, version));
goals.push(SuperTtcArchiveFile(cgr, version));
for (const gr of subGroups) {
goals.push(GroupTtfArchiveFile(gr, version));
goals.push(GroupTtfUnhintedArchiveFile(gr, version));
goals.push(GroupWebArchiveFile(gr, version));
}
}
await target.need(goals);
const [archiveFiles] = await target.need(goals);
// Create hash of packages
await target.need(fu`utility/create-sha-file.js`);
await node("utility/create-sha-file.js", "doc/packages-sha.txt", archiveFiles);
// Images and release notes
await target.need(SampleImages, Pages, AmendReadme, ReleaseNotes, ChangeLog);
});
const ReleaseGroup = phony.group("release-group", async (target, cgr) => {
const [version, collectPlans] = await target.need(Version, CollectPlans);
const subGroups = collectPlans[cgr].groupDecomposition;
let goals = [TtcArchiveFile(cgr, version), SuperTtcArchiveFile(cgr, version)];
for (const gr of subGroups) {
goals.push(GroupTtfArchiveFile(gr, version));
goals.push(GroupTtfUnhintedArchiveFile(gr, version));
goals.push(GroupWebArchiveFile(gr, version));
}
await target.need(goals);
});
///////////////////////////////////////////////////////////
////// Script Building //////