@adea-ai/app-framework-release-tools 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +879 -148
- package/dist/index.js +467 -0
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ var __export = (target, all) => {
|
|
|
18
18
|
// src/index.ts
|
|
19
19
|
var exports_src = {};
|
|
20
20
|
__export(exports_src, {
|
|
21
|
+
buildLinuxFormats: () => buildLinuxFormats,
|
|
21
22
|
createDailyNativeReceipt: () => createDailyNativeReceipt,
|
|
22
23
|
createGitHubPromotionProvider: () => createGitHubPromotionProvider,
|
|
23
24
|
createGitHubReleasePublisher: () => createGitHubReleasePublisher,
|
|
@@ -41,6 +42,7 @@ __export(exports_src, {
|
|
|
41
42
|
selectRetainedStep: () => selectRetainedStep,
|
|
42
43
|
signReleaseArtifact: () => signReleaseArtifact,
|
|
43
44
|
stageBuildStep: () => stageBuildStep,
|
|
45
|
+
stageLinuxPackagePair: () => stageLinuxPackagePair,
|
|
44
46
|
stagePlatformArtifacts: () => stagePlatformArtifacts,
|
|
45
47
|
stageReleaseDescriptors: () => stageReleaseDescriptors,
|
|
46
48
|
verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
|
|
@@ -49,10 +51,10 @@ __export(exports_src, {
|
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
// src/cli.ts
|
|
52
|
-
import { Effect as
|
|
54
|
+
import { Effect as Effect30 } from "effect";
|
|
53
55
|
|
|
54
56
|
// src/cli-commands.ts
|
|
55
|
-
import { Effect as
|
|
57
|
+
import { Effect as Effect29 } from "effect";
|
|
56
58
|
|
|
57
59
|
// ../../src/installer/hosted-runner.ts
|
|
58
60
|
import { isAbsolute } from "path";
|
|
@@ -8238,6 +8240,469 @@ var stageBuildStep = (context, directory, artifacts) => run2(context, stageBuild
|
|
|
8238
8240
|
var inspectStagedStep = (context, directory) => run2(context, inspectStagedStepEffect(context, directory));
|
|
8239
8241
|
var qualifyStep = (context, directory) => run2(context, qualifyStepEffect(context, directory));
|
|
8240
8242
|
var qualifyUpgradeStep = (context, directory, onStage) => run2(context, qualifyUpgradeStepEffect(context, directory, onStage));
|
|
8243
|
+
// src/library/linux-package-pair.ts
|
|
8244
|
+
import { execFile as execFile3 } from "child_process";
|
|
8245
|
+
import {
|
|
8246
|
+
chmod as chmod3,
|
|
8247
|
+
link,
|
|
8248
|
+
mkdir as mkdir11,
|
|
8249
|
+
mkdtemp as mkdtemp10,
|
|
8250
|
+
open as open13,
|
|
8251
|
+
readFile as readFile10,
|
|
8252
|
+
realpath as realpath10,
|
|
8253
|
+
rm as rm10,
|
|
8254
|
+
writeFile as writeFile11
|
|
8255
|
+
} from "fs/promises";
|
|
8256
|
+
import { dirname as dirname14, join as join34, resolve as resolve16 } from "path";
|
|
8257
|
+
import { promisify as promisify2 } from "util";
|
|
8258
|
+
var shasum = /^[a-f0-9]{64}$/;
|
|
8259
|
+
var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
8260
|
+
var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
8261
|
+
var exec = promisify2(execFile3);
|
|
8262
|
+
function requireThat2(condition, message) {
|
|
8263
|
+
if (!condition)
|
|
8264
|
+
throw new Error(message);
|
|
8265
|
+
}
|
|
8266
|
+
function record2(value) {
|
|
8267
|
+
requireThat2(typeof value === "object" && value !== null && !Array.isArray(value), "Invalid producer receipt");
|
|
8268
|
+
return value;
|
|
8269
|
+
}
|
|
8270
|
+
function validIdentity(value) {
|
|
8271
|
+
const { name, size, sha256 } = record2(value);
|
|
8272
|
+
requireThat2(typeof name === "string" && basename15.test(name) && typeof size === "number" && Number.isSafeInteger(size) && size > 0 && typeof sha256 === "string" && shasum.test(sha256), "Invalid package artifact identity");
|
|
8273
|
+
return { name, size, sha256 };
|
|
8274
|
+
}
|
|
8275
|
+
var inspectWithNativeTools = async (tool, args) => {
|
|
8276
|
+
try {
|
|
8277
|
+
const { stdout } = await exec(tool, [...args], {
|
|
8278
|
+
encoding: "utf8",
|
|
8279
|
+
maxBuffer: 128 * 1024,
|
|
8280
|
+
timeout: 30000,
|
|
8281
|
+
env: { PATH: process.env.PATH, LC_ALL: "C" }
|
|
8282
|
+
});
|
|
8283
|
+
return stdout;
|
|
8284
|
+
} catch (error) {
|
|
8285
|
+
if (error.code === "ENOENT")
|
|
8286
|
+
throw new Error(`${tool} is required to inspect Linux package candidates`, { cause: error });
|
|
8287
|
+
throw new Error(`${tool} could not inspect Linux package candidate`, { cause: error });
|
|
8288
|
+
}
|
|
8289
|
+
};
|
|
8290
|
+
function parseDebianIdentity(text, packageName, version) {
|
|
8291
|
+
const fields = text.trimEnd().split(/\r?\n/);
|
|
8292
|
+
requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`, "Architecture: amd64"].every((value) => fields.includes(value)), "Debian package name, version or architecture does not match the release policy");
|
|
8293
|
+
}
|
|
8294
|
+
function requireRegularDesktopEntry(listing, id) {
|
|
8295
|
+
const lines = listing.trimEnd().split(/\r?\n/);
|
|
8296
|
+
const fields = /^[d-][-rwxstST]{9} +\d+\/\d+ +\d+ +\d{4}-\d{2}-\d{2} \d{2}:\d{2} (.+)$/;
|
|
8297
|
+
requireThat2(lines.length === 2 && lines[0]?.startsWith("d") && fields.exec(lines[0])?.[1] === "squashfs-root" && lines[1]?.startsWith("-") && fields.exec(lines[1])?.[1] === `squashfs-root/${id}`, "AppImage must contain one regular root desktop entry");
|
|
8298
|
+
}
|
|
8299
|
+
function requireDesktopIdentity(text, name, version) {
|
|
8300
|
+
let inDesktop = false;
|
|
8301
|
+
let foundGroup = false;
|
|
8302
|
+
const fields = new Map;
|
|
8303
|
+
for (const line of text.split(/\r?\n/)) {
|
|
8304
|
+
if (/^\[.*\]$/.test(line)) {
|
|
8305
|
+
inDesktop = line === "[Desktop Entry]";
|
|
8306
|
+
if (inDesktop) {
|
|
8307
|
+
requireThat2(!foundGroup, "Duplicate AppImage desktop entry");
|
|
8308
|
+
foundGroup = true;
|
|
8309
|
+
}
|
|
8310
|
+
continue;
|
|
8311
|
+
}
|
|
8312
|
+
if (!inDesktop || !line || line.startsWith("#"))
|
|
8313
|
+
continue;
|
|
8314
|
+
const match = /^([^=]+)=(.*)$/.exec(line);
|
|
8315
|
+
requireThat2(match && !fields.has(match[1]), "Malformed or duplicate AppImage desktop fields");
|
|
8316
|
+
fields.set(match[1], match[2]);
|
|
8317
|
+
}
|
|
8318
|
+
requireThat2(fields.get("Type") === "Application" && fields.get("Name") === name && fields.get("X-AppImage-Version") === version, "AppImage desktop entry has wrong app identity or release version");
|
|
8319
|
+
}
|
|
8320
|
+
function digestWindow(runtime) {
|
|
8321
|
+
const sectionStart = Number(runtime.readBigUInt64LE(40));
|
|
8322
|
+
const sectionSize = runtime.readUInt16LE(58);
|
|
8323
|
+
const count = runtime.readUInt16LE(60);
|
|
8324
|
+
const namesIndex = runtime.readUInt16LE(62);
|
|
8325
|
+
requireThat2(Number.isSafeInteger(sectionStart) && sectionStart >= 64 && sectionSize === 64 && namesIndex < count && sectionStart + count * sectionSize <= runtime.length, "Invalid pinned AppImage runtime ELF section table");
|
|
8326
|
+
const namesHeader = sectionStart + sectionSize * namesIndex;
|
|
8327
|
+
const namesStart = Number(runtime.readBigUInt64LE(namesHeader + 24));
|
|
8328
|
+
const namesSize = Number(runtime.readBigUInt64LE(namesHeader + 32));
|
|
8329
|
+
requireThat2(Number.isSafeInteger(namesStart) && Number.isSafeInteger(namesSize) && namesStart >= 64 && namesStart + namesSize <= runtime.length, "Invalid pinned AppImage runtime ELF section names");
|
|
8330
|
+
const names = runtime.subarray(namesStart, namesStart + namesSize);
|
|
8331
|
+
const matches = [];
|
|
8332
|
+
for (let i = 0;i < count; i++) {
|
|
8333
|
+
const section = sectionStart + sectionSize * i;
|
|
8334
|
+
const nameAt = runtime.readUInt32LE(section);
|
|
8335
|
+
const end = names.indexOf(0, nameAt);
|
|
8336
|
+
if (end < 0 || names.toString("ascii", nameAt, end) !== ".digest_md5")
|
|
8337
|
+
continue;
|
|
8338
|
+
const dataAt = Number(runtime.readBigUInt64LE(section + 24));
|
|
8339
|
+
const dataSize = Number(runtime.readBigUInt64LE(section + 32));
|
|
8340
|
+
requireThat2(Number.isSafeInteger(dataAt) && Number.isSafeInteger(dataSize) && dataAt >= 64 && dataSize >= 16 && dataAt + dataSize <= runtime.length, "Invalid pinned AppImage runtime digest section");
|
|
8341
|
+
matches.push(dataAt);
|
|
8342
|
+
}
|
|
8343
|
+
requireThat2(matches.length === 1, "Expected one pinned AppImage runtime digest section");
|
|
8344
|
+
return matches[0];
|
|
8345
|
+
}
|
|
8346
|
+
function type2X64(bytes) {
|
|
8347
|
+
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) === 62;
|
|
8348
|
+
}
|
|
8349
|
+
async function verifyEmbeddedRuntime(path, runtime) {
|
|
8350
|
+
requireThat2(type2X64(runtime), "Expected a pinned Type 2 x86_64 AppImage runtime");
|
|
8351
|
+
const ignored = digestWindow(runtime);
|
|
8352
|
+
const fd = await open13(path, "r");
|
|
8353
|
+
try {
|
|
8354
|
+
const prefix = Buffer.alloc(runtime.length + 4);
|
|
8355
|
+
let filled = 0;
|
|
8356
|
+
while (filled < prefix.length) {
|
|
8357
|
+
const { bytesRead } = await fd.read(prefix, filled, prefix.length - filled, filled);
|
|
8358
|
+
if (!bytesRead)
|
|
8359
|
+
throw new Error("Incomplete embedded AppImage runtime or SquashFS header");
|
|
8360
|
+
filled += bytesRead;
|
|
8361
|
+
}
|
|
8362
|
+
requireThat2(type2X64(prefix), "Expected a Type 2 x86_64 AppImage");
|
|
8363
|
+
requireThat2(runtime.subarray(0, ignored).equals(prefix.subarray(0, ignored)) && runtime.subarray(ignored + 16).equals(prefix.subarray(ignored + 16, runtime.length)), "AppImage runtime differs from its trusted pin outside the tool-generated digest");
|
|
8364
|
+
requireThat2(prefix.toString("ascii", runtime.length) === "hsqs", "Missing embedded SquashFS at the pinned runtime offset");
|
|
8365
|
+
} finally {
|
|
8366
|
+
await fd.close();
|
|
8367
|
+
}
|
|
8368
|
+
}
|
|
8369
|
+
async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
8370
|
+
const { expected, sources } = options;
|
|
8371
|
+
const receipt = record2(options.producer);
|
|
8372
|
+
const archive = validIdentity(expected.archive);
|
|
8373
|
+
const runtime = validIdentity(expected.runtime);
|
|
8374
|
+
requireThat2(validTag.test(expected.tag) && /^[a-f0-9]{40}$/.test(expected.sourceSha) && basename15.test(expected.debName) && expected.debName.endsWith(".deb") && basename15.test(expected.appImageName) && expected.appImageName.endsWith(".AppImage") && archive.name.endsWith(".tar.zst") && /^[a-z0-9][a-z0-9+.-]+$/.test(expected.debPackage) && /^[A-Za-z0-9][A-Za-z0-9_.-]*\.desktop$/.test(expected.desktopId) && expected.desktopName.length > 0 && !/[\r\n]/.test(expected.desktopName) && Number.isSafeInteger(expected.runtime.size) && expected.runtime.size >= 64 && expected.runtime.size <= 64 * 1024 * 1024 && shasum.test(expected.runtime.sha256), "Invalid trusted Linux package policy");
|
|
8375
|
+
requireThat2(receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform === "linux-x64" && receipt.updateArchiveSha256 === archive.sha256 && Array.isArray(receipt.artifacts) && receipt.artifacts.length === 2, "Package producer receipt names a different source, tag, platform or update archive");
|
|
8376
|
+
const names = [expected.debName, expected.appImageName];
|
|
8377
|
+
const artifacts = receipt.artifacts.map(validIdentity);
|
|
8378
|
+
const trustedArtifacts = expected.artifacts.map(validIdentity);
|
|
8379
|
+
requireThat2(trustedArtifacts.length === 2 && names.every((name) => {
|
|
8380
|
+
const fromProducer = artifacts.find((file) => file.name === name);
|
|
8381
|
+
const trusted = trustedArtifacts.find((file) => file.name === name);
|
|
8382
|
+
return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
|
|
8383
|
+
}), "Package producer receipt must describe exactly the protected DEB and AppImage");
|
|
8384
|
+
const destination = resolve16(options.output);
|
|
8385
|
+
const parent = await realpath10(dirname14(destination));
|
|
8386
|
+
const work = await mkdtemp10(join34(parent, ".linux-package-pair-"));
|
|
8387
|
+
try {
|
|
8388
|
+
const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
|
|
8389
|
+
directory: work,
|
|
8390
|
+
expected: [...names, archive.name, runtime.name],
|
|
8391
|
+
sources
|
|
8392
|
+
})));
|
|
8393
|
+
requireThat2([...artifacts, archive, runtime].every((asset) => files.some((file) => file.name === asset.name && file.size === asset.size && file.digest === `sha256:${asset.sha256}`)), "Staged package or update archive does not agree with its bound size and digest");
|
|
8394
|
+
const deb = join34(work, expected.debName);
|
|
8395
|
+
const image = join34(work, expected.appImageName);
|
|
8396
|
+
const version = expected.tag.slice(1);
|
|
8397
|
+
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
|
|
8398
|
+
await verifyEmbeddedRuntime(image, await readFile10(join34(work, runtime.name)));
|
|
8399
|
+
const offset = String(runtime.size);
|
|
8400
|
+
requireRegularDesktopEntry(await inspect("unsquashfs", [
|
|
8401
|
+
"-offset",
|
|
8402
|
+
offset,
|
|
8403
|
+
"-lln",
|
|
8404
|
+
"-no-wildcards",
|
|
8405
|
+
image,
|
|
8406
|
+
expected.desktopId
|
|
8407
|
+
]), expected.desktopId);
|
|
8408
|
+
requireDesktopIdentity(await inspect("unsquashfs", [
|
|
8409
|
+
"-offset",
|
|
8410
|
+
offset,
|
|
8411
|
+
"-cat",
|
|
8412
|
+
"-no-wildcards",
|
|
8413
|
+
image,
|
|
8414
|
+
expected.desktopId
|
|
8415
|
+
]), expected.desktopName, version);
|
|
8416
|
+
await chmod3(image, 493);
|
|
8417
|
+
const staged = {
|
|
8418
|
+
schema: "linux-package-pair/v1",
|
|
8419
|
+
tag: expected.tag,
|
|
8420
|
+
sourceSha: expected.sourceSha,
|
|
8421
|
+
platform: "linux-x64",
|
|
8422
|
+
updateArchiveSha256: archive.sha256,
|
|
8423
|
+
artifacts: names.map((name) => artifacts.find((file) => file.name === name))
|
|
8424
|
+
};
|
|
8425
|
+
await mkdir11(destination);
|
|
8426
|
+
try {
|
|
8427
|
+
for (const name of names)
|
|
8428
|
+
await link(join34(work, name), join34(destination, name));
|
|
8429
|
+
await writeFile11(join34(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
|
|
8430
|
+
`, {
|
|
8431
|
+
flag: "wx"
|
|
8432
|
+
});
|
|
8433
|
+
} catch (error) {
|
|
8434
|
+
await rm10(destination, { recursive: true, force: true });
|
|
8435
|
+
throw error;
|
|
8436
|
+
}
|
|
8437
|
+
return staged;
|
|
8438
|
+
} finally {
|
|
8439
|
+
await rm10(work, { recursive: true, force: true });
|
|
8440
|
+
}
|
|
8441
|
+
}
|
|
8442
|
+
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
8443
|
+
// src/library/linux-format-producer.ts
|
|
8444
|
+
import { createHash as createHash16 } from "crypto";
|
|
8445
|
+
import { createReadStream, createWriteStream } from "fs";
|
|
8446
|
+
import {
|
|
8447
|
+
chmod as chmod4,
|
|
8448
|
+
cp,
|
|
8449
|
+
lstat as lstat20,
|
|
8450
|
+
lutimes,
|
|
8451
|
+
mkdir as mkdir12,
|
|
8452
|
+
mkdtemp as mkdtemp11,
|
|
8453
|
+
open as open14,
|
|
8454
|
+
readdir as readdir12,
|
|
8455
|
+
readlink as readlink3,
|
|
8456
|
+
realpath as realpath11,
|
|
8457
|
+
rm as rm11,
|
|
8458
|
+
utimes,
|
|
8459
|
+
writeFile as writeFile12
|
|
8460
|
+
} from "fs/promises";
|
|
8461
|
+
import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute6, join as join35, relative as relative6, resolve as resolve17 } from "path";
|
|
8462
|
+
import { pipeline as pipeline2 } from "stream/promises";
|
|
8463
|
+
var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
8464
|
+
var sha256 = /^[a-f0-9]{64}$/;
|
|
8465
|
+
var sum = async (path) => {
|
|
8466
|
+
const hash = createHash16("sha256");
|
|
8467
|
+
for await (const chunk of createReadStream(path))
|
|
8468
|
+
hash.update(chunk);
|
|
8469
|
+
return hash.digest("hex");
|
|
8470
|
+
};
|
|
8471
|
+
var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
|
|
8472
|
+
var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
|
|
8473
|
+
function check(ok, message) {
|
|
8474
|
+
if (!ok)
|
|
8475
|
+
throw new Error(message);
|
|
8476
|
+
}
|
|
8477
|
+
async function exactCopy(pin, to) {
|
|
8478
|
+
check(sha256.test(pin.sha256), "Missing protected input digest");
|
|
8479
|
+
const before = await lstat20(pin.path);
|
|
8480
|
+
check(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
|
|
8481
|
+
const input = await open14(pin.path, "r");
|
|
8482
|
+
try {
|
|
8483
|
+
const after = await input.stat();
|
|
8484
|
+
check(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
|
|
8485
|
+
await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
|
|
8486
|
+
} finally {
|
|
8487
|
+
await input.close();
|
|
8488
|
+
}
|
|
8489
|
+
check((await lstat20(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
|
|
8490
|
+
}
|
|
8491
|
+
async function regular(root, path) {
|
|
8492
|
+
const file = join35(root, path);
|
|
8493
|
+
check((await lstat20(file)).isFile() && await realpath11(file) === file, "Required bundle member is not a regular file");
|
|
8494
|
+
return file;
|
|
8495
|
+
}
|
|
8496
|
+
async function elf(path, appImage = false) {
|
|
8497
|
+
const input = await open14(path, "r");
|
|
8498
|
+
try {
|
|
8499
|
+
const h = Buffer.alloc(20);
|
|
8500
|
+
const { bytesRead } = await input.read(h, 0, h.length, 0);
|
|
8501
|
+
check(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === 62 && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected native Linux x64 executable");
|
|
8502
|
+
} finally {
|
|
8503
|
+
await input.close();
|
|
8504
|
+
}
|
|
8505
|
+
}
|
|
8506
|
+
async function normalizeTree(root, dir = root) {
|
|
8507
|
+
for (const name of await readdir12(dir)) {
|
|
8508
|
+
const file = join35(dir, name);
|
|
8509
|
+
const st = await lstat20(file);
|
|
8510
|
+
if (st.isSymbolicLink()) {
|
|
8511
|
+
check(!isAbsolute6(await readlink3(file)), "Absolute bundle symlink");
|
|
8512
|
+
const target = relative6(root, await realpath11(file));
|
|
8513
|
+
check(target !== ".." && !target.startsWith("../") && !isAbsolute6(target), "Escaping bundle symlink");
|
|
8514
|
+
} else if (st.isDirectory()) {
|
|
8515
|
+
await chmod4(file, 493);
|
|
8516
|
+
await normalizeTree(root, file);
|
|
8517
|
+
} else {
|
|
8518
|
+
check(st.isFile(), "Unsupported bundle entry");
|
|
8519
|
+
await chmod4(file, st.mode & 73 ? 493 : 420);
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8522
|
+
}
|
|
8523
|
+
async function normalizeBuildTimes(directory, epoch) {
|
|
8524
|
+
for (const name of (await readdir12(directory)).toSorted()) {
|
|
8525
|
+
const path = join35(directory, name);
|
|
8526
|
+
const info = await lstat20(path);
|
|
8527
|
+
if (info.isSymbolicLink()) {
|
|
8528
|
+
await lutimes(path, epoch, epoch);
|
|
8529
|
+
} else if (info.isDirectory()) {
|
|
8530
|
+
await normalizeBuildTimes(path, epoch);
|
|
8531
|
+
} else {
|
|
8532
|
+
check(info.isFile(), "Unsupported packaging entry");
|
|
8533
|
+
await utimes(path, epoch, epoch);
|
|
8534
|
+
}
|
|
8535
|
+
}
|
|
8536
|
+
await chmod4(directory, 493);
|
|
8537
|
+
await utimes(directory, epoch, epoch);
|
|
8538
|
+
}
|
|
8539
|
+
async function write(root, path, value, mode = 420) {
|
|
8540
|
+
const target = join35(root, path);
|
|
8541
|
+
await mkdir12(dirname15(target), { recursive: true });
|
|
8542
|
+
await writeFile12(target, value, { flag: "wx", mode });
|
|
8543
|
+
await chmod4(target, mode);
|
|
8544
|
+
}
|
|
8545
|
+
function validatePolicy(policy) {
|
|
8546
|
+
check([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha256.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => /^[a-z0-9][a-z0-9+.-]*(?: \| [a-z0-9][a-z0-9+.-]*)*$/.test(x)), "Invalid app Linux packaging policy");
|
|
8547
|
+
check(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
|
|
8548
|
+
}
|
|
8549
|
+
async function buildLinuxFormats(input, host) {
|
|
8550
|
+
const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
|
|
8551
|
+
check(host.os === "linux" && host.arch === "x64", "Requires native Linux x64");
|
|
8552
|
+
check(/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) && /^[a-f0-9]{40}$/.test(sourceSha) && sourceSha === expectedSourceSha, "Wrong protected build source or tag");
|
|
8553
|
+
check(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
|
|
8554
|
+
const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
|
|
8555
|
+
validatePolicy(policy);
|
|
8556
|
+
const requested = resolve17(input.output);
|
|
8557
|
+
const parent = await realpath11(dirname15(requested));
|
|
8558
|
+
const output = join35(parent, basename16(requested));
|
|
8559
|
+
const work = await mkdtemp11(join35(parent, ".linux-formats-"));
|
|
8560
|
+
try {
|
|
8561
|
+
const archive = join35(work, "payload.tar.zst");
|
|
8562
|
+
const tool = join35(work, "appimagetool");
|
|
8563
|
+
const runtime = join35(work, "runtime");
|
|
8564
|
+
for (const [pin, dest] of [
|
|
8565
|
+
[input.archive, archive],
|
|
8566
|
+
[input.tool, tool],
|
|
8567
|
+
[input.runtime, runtime]
|
|
8568
|
+
])
|
|
8569
|
+
await exactCopy(pin, dest);
|
|
8570
|
+
await elf(tool, true);
|
|
8571
|
+
await elf(runtime, true);
|
|
8572
|
+
await host.inspectAppArchive(archive);
|
|
8573
|
+
check((await lstat20(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
|
|
8574
|
+
await chmod4(tool, 448);
|
|
8575
|
+
const extracted = join35(work, "extract");
|
|
8576
|
+
await mkdir12(extracted);
|
|
8577
|
+
await host.run("tar", [
|
|
8578
|
+
"--zstd",
|
|
8579
|
+
"--extract",
|
|
8580
|
+
"--file",
|
|
8581
|
+
archive,
|
|
8582
|
+
"--directory",
|
|
8583
|
+
extracted,
|
|
8584
|
+
"--no-same-owner",
|
|
8585
|
+
"--no-same-permissions"
|
|
8586
|
+
], { env });
|
|
8587
|
+
const source = join35(extracted, policy.bundleRoot);
|
|
8588
|
+
check((await lstat20(source)).isDirectory() && await realpath11(source) === source, "Wrong extracted app root");
|
|
8589
|
+
await chmod4(source, 493);
|
|
8590
|
+
await normalizeTree(source);
|
|
8591
|
+
await elf(await regular(source, policy.launcher));
|
|
8592
|
+
for (const pin of policy.debSetuid) {
|
|
8593
|
+
const file = await regular(source, pin.path);
|
|
8594
|
+
await elf(file);
|
|
8595
|
+
check(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
|
|
8596
|
+
}
|
|
8597
|
+
const icon = await regular(source, policy.icon);
|
|
8598
|
+
check(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
|
|
8599
|
+
const stem = `${policy.artifactStem}-${tag}-linux-x64`;
|
|
8600
|
+
const debName = `${stem}.deb`;
|
|
8601
|
+
const imageName = `${stem}.AppImage`;
|
|
8602
|
+
const dest = join35(work, "result");
|
|
8603
|
+
await mkdir12(dest);
|
|
8604
|
+
const version = tag.slice(1);
|
|
8605
|
+
const installed = `usr/lib/${policy.packageName}`;
|
|
8606
|
+
const desktopFile = `${policy.desktopId}.desktop`;
|
|
8607
|
+
const desktop = [
|
|
8608
|
+
"[Desktop Entry]",
|
|
8609
|
+
"Type=Application",
|
|
8610
|
+
`Name=${policy.name}`,
|
|
8611
|
+
`Comment=${policy.description}`,
|
|
8612
|
+
`Exec=${policy.packageName} %U`,
|
|
8613
|
+
`Icon=${policy.desktopId}`,
|
|
8614
|
+
`Categories=${policy.categories.join(";")};`,
|
|
8615
|
+
...policy.mimeTypes.length ? [`MimeType=${policy.mimeTypes.join(";")};`] : [],
|
|
8616
|
+
"Terminal=false",
|
|
8617
|
+
""
|
|
8618
|
+
].join(`
|
|
8619
|
+
`);
|
|
8620
|
+
for (const format of ["deb", "appimage"]) {
|
|
8621
|
+
const tree = join35(work, format);
|
|
8622
|
+
await mkdir12(join35(tree, "usr", "lib"), { recursive: true });
|
|
8623
|
+
const bundle = join35(tree, installed);
|
|
8624
|
+
await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
|
|
8625
|
+
await normalizeTree(bundle);
|
|
8626
|
+
await write(tree, `usr/share/applications/${desktopFile}`, desktop);
|
|
8627
|
+
const iconDest = join35(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
|
|
8628
|
+
await mkdir12(dirname15(iconDest), { recursive: true });
|
|
8629
|
+
await cp(icon, iconDest, { force: false, errorOnExist: true });
|
|
8630
|
+
await chmod4(iconDest, 420);
|
|
8631
|
+
if (format === "deb") {
|
|
8632
|
+
for (const pin of policy.debSetuid)
|
|
8633
|
+
await chmod4(await regular(bundle, pin.path), 2541);
|
|
8634
|
+
await write(tree, `usr/bin/${policy.packageName}`, `#!/bin/sh
|
|
8635
|
+
export ${policy.formatEnvironment}=deb
|
|
8636
|
+
exec '/${installed}/${policy.launcher}' "$@"
|
|
8637
|
+
`, 493);
|
|
8638
|
+
await write(tree, "DEBIAN/control", [
|
|
8639
|
+
`Package: ${policy.packageName}`,
|
|
8640
|
+
`Version: ${version}`,
|
|
8641
|
+
"Architecture: amd64",
|
|
8642
|
+
`Maintainer: ${policy.maintainer}`,
|
|
8643
|
+
`Description: ${policy.description}`,
|
|
8644
|
+
`Homepage: ${policy.homepage}`,
|
|
8645
|
+
...policy.dependencies.length ? [`Depends: ${policy.dependencies.join(", ")}`] : [],
|
|
8646
|
+
""
|
|
8647
|
+
].join(`
|
|
8648
|
+
`));
|
|
8649
|
+
await normalizeBuildTimes(tree, sourceDateEpoch);
|
|
8650
|
+
await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join35(dest, debName)], { env });
|
|
8651
|
+
} else {
|
|
8652
|
+
const rootIcon = join35(tree, `${policy.desktopId}.svg`);
|
|
8653
|
+
await cp(icon, rootIcon, { force: false, errorOnExist: true });
|
|
8654
|
+
await chmod4(rootIcon, 420);
|
|
8655
|
+
await write(tree, desktopFile, desktop);
|
|
8656
|
+
await write(tree, "AppRun", [
|
|
8657
|
+
"#!/bin/sh",
|
|
8658
|
+
"set -eu",
|
|
8659
|
+
'root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)',
|
|
8660
|
+
`export ${policy.formatEnvironment}=appimage`,
|
|
8661
|
+
`exec "$root/${installed}/${policy.launcher}" "$@"`,
|
|
8662
|
+
""
|
|
8663
|
+
].join(`
|
|
8664
|
+
`), 493);
|
|
8665
|
+
await normalizeBuildTimes(tree, sourceDateEpoch);
|
|
8666
|
+
await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join35(dest, imageName)], {
|
|
8667
|
+
executable: tool,
|
|
8668
|
+
env: { ...env, ARCH: "x86_64", VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
|
|
8669
|
+
});
|
|
8670
|
+
}
|
|
8671
|
+
}
|
|
8672
|
+
const artifacts = [];
|
|
8673
|
+
for (const name of [debName, imageName]) {
|
|
8674
|
+
const path = await regular(dest, name);
|
|
8675
|
+
const size = (await lstat20(path)).size;
|
|
8676
|
+
check(size > 0, "Empty produced artifact");
|
|
8677
|
+
artifacts.push({ name, size, sha256: await sum(path) });
|
|
8678
|
+
}
|
|
8679
|
+
const receipt = {
|
|
8680
|
+
schema: "linux-package-formats/v1",
|
|
8681
|
+
tag,
|
|
8682
|
+
sourceSha,
|
|
8683
|
+
sourceDateEpoch,
|
|
8684
|
+
platform: "linux-x64",
|
|
8685
|
+
updateArchiveSha256: input.archive.sha256,
|
|
8686
|
+
artifacts
|
|
8687
|
+
};
|
|
8688
|
+
await mkdir12(output);
|
|
8689
|
+
try {
|
|
8690
|
+
for (const item of artifacts)
|
|
8691
|
+
await cp(join35(dest, item.name), join35(output, basename16(item.name)), {
|
|
8692
|
+
force: false,
|
|
8693
|
+
errorOnExist: true
|
|
8694
|
+
});
|
|
8695
|
+
await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
|
|
8696
|
+
`);
|
|
8697
|
+
} catch (error) {
|
|
8698
|
+
await rm11(output, { recursive: true, force: true });
|
|
8699
|
+
throw error;
|
|
8700
|
+
}
|
|
8701
|
+
return receipt;
|
|
8702
|
+
} finally {
|
|
8703
|
+
await rm11(work, { recursive: true, force: true });
|
|
8704
|
+
}
|
|
8705
|
+
}
|
|
8241
8706
|
// src/framework-loader.ts
|
|
8242
8707
|
var releaseTools = async () => exports_src;
|
|
8243
8708
|
|
|
@@ -8259,25 +8724,280 @@ function electrobunArtifacts(appName, platform) {
|
|
|
8259
8724
|
}[platform];
|
|
8260
8725
|
}
|
|
8261
8726
|
|
|
8727
|
+
// src/library/daily-native-observer.ts
|
|
8728
|
+
import { execFile as execFile4 } from "child_process";
|
|
8729
|
+
import { createHash as createHash17, randomBytes as randomBytes3 } from "crypto";
|
|
8730
|
+
import { join as join36, resolve as resolve18 } from "path";
|
|
8731
|
+
import { Effect as Effect25 } from "effect";
|
|
8732
|
+
var runDailyNativeDriver = (script, input, env) => new Promise((finish, reject) => {
|
|
8733
|
+
const child = execFile4(process.execPath, ["--no-env-file", script], {
|
|
8734
|
+
cwd: input.profile,
|
|
8735
|
+
env,
|
|
8736
|
+
maxBuffer: 16 * 1024,
|
|
8737
|
+
timeout: 120000,
|
|
8738
|
+
killSignal: "SIGKILL",
|
|
8739
|
+
windowsHide: true
|
|
8740
|
+
}, (error, stdout) => {
|
|
8741
|
+
if (error)
|
|
8742
|
+
return reject(new Error("Native observer driver failed"));
|
|
8743
|
+
try {
|
|
8744
|
+
finish(JSON.parse(stdout));
|
|
8745
|
+
} catch {
|
|
8746
|
+
reject(new Error("Native observer driver did not emit one JSON result"));
|
|
8747
|
+
}
|
|
8748
|
+
});
|
|
8749
|
+
child.stdin?.on("error", () => {
|
|
8750
|
+
return;
|
|
8751
|
+
});
|
|
8752
|
+
child.stdin?.end(JSON.stringify(input) + `
|
|
8753
|
+
`);
|
|
8754
|
+
});
|
|
8755
|
+
function phaseEnvironment(env, profile) {
|
|
8756
|
+
const clean = {};
|
|
8757
|
+
for (const key of [
|
|
8758
|
+
"PATH",
|
|
8759
|
+
"SystemRoot",
|
|
8760
|
+
"WINDIR",
|
|
8761
|
+
"COMSPEC",
|
|
8762
|
+
"PATHEXT",
|
|
8763
|
+
"LANG",
|
|
8764
|
+
"LC_ALL",
|
|
8765
|
+
"DISPLAY",
|
|
8766
|
+
"XAUTHORITY",
|
|
8767
|
+
"DBUS_SESSION_BUS_ADDRESS",
|
|
8768
|
+
"CI",
|
|
8769
|
+
"GITHUB_ACTIONS",
|
|
8770
|
+
"RUNNER_ENVIRONMENT",
|
|
8771
|
+
"GITLAB_CI",
|
|
8772
|
+
"CI_JOB_ID",
|
|
8773
|
+
"CIRCLECI",
|
|
8774
|
+
"CIRCLE_BUILD_NUM",
|
|
8775
|
+
"FRAMEWORK_DISPOSABLE_RUNNER"
|
|
8776
|
+
]) {
|
|
8777
|
+
if (env[key])
|
|
8778
|
+
clean[key] = env[key];
|
|
8779
|
+
}
|
|
8780
|
+
return {
|
|
8781
|
+
...clean,
|
|
8782
|
+
HOME: profile,
|
|
8783
|
+
USERPROFILE: profile,
|
|
8784
|
+
LOCALAPPDATA: join36(profile, "LocalAppData"),
|
|
8785
|
+
XDG_CONFIG_HOME: join36(profile, ".config"),
|
|
8786
|
+
XDG_DATA_HOME: join36(profile, ".local", "share"),
|
|
8787
|
+
TEMP: join36(profile, "tmp"),
|
|
8788
|
+
TMP: join36(profile, "tmp"),
|
|
8789
|
+
TMPDIR: join36(profile, "tmp")
|
|
8790
|
+
};
|
|
8791
|
+
}
|
|
8792
|
+
function parseBaseline(value, target) {
|
|
8793
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["kind", "tag", "sourceSha", "directory"]) || value.kind !== "published-installer" && value.kind !== "private-from-verified-payload" || !isReleaseTag(value.tag) || !versionLessThan(value.tag, target) || typeof value.sourceSha !== "string" || !isGitSha(value.sourceSha) || typeof value.directory !== "string" || !value.directory)
|
|
8794
|
+
throw new Error("Native observation needs declared exact older installer provenance");
|
|
8795
|
+
return {
|
|
8796
|
+
kind: value.kind,
|
|
8797
|
+
tag: value.tag,
|
|
8798
|
+
sourceSha: value.sourceSha,
|
|
8799
|
+
directory: value.directory
|
|
8800
|
+
};
|
|
8801
|
+
}
|
|
8802
|
+
function driverPath(value) {
|
|
8803
|
+
if (value.length > 240 || !/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*\.(?:ts|mjs)$/.test(value) || value.split("/").some((part) => part === "." || part === ".."))
|
|
8804
|
+
throw new Error("Invalid native observer path");
|
|
8805
|
+
return value;
|
|
8806
|
+
}
|
|
8807
|
+
var fixtureDigest = (nonce) => "sha256:" + createHash17("sha256").update(nonce).digest("hex");
|
|
8808
|
+
var confirmFixture = (value, nonce) => isRecord(value) && hasExactOwnKeys(value, ["digest"]) && value.digest === fixtureDigest(nonce);
|
|
8809
|
+
var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
|
|
8810
|
+
const { env, platform: os, arch, cwd } = yield* ReleaseConfig;
|
|
8811
|
+
const fs = yield* ReleaseFs;
|
|
8812
|
+
const git = yield* ReleaseGit;
|
|
8813
|
+
const { identity, config, checkName } = options;
|
|
8814
|
+
yield* attempt(() => {
|
|
8815
|
+
assertHostedRunner(env, "Daily native observation");
|
|
8816
|
+
if (env.FRAMEWORK_DAILY_NATIVE_OBSERVER !== "test-only")
|
|
8817
|
+
throw new Error("Daily native observer is disabled without explicit test-only opt-in");
|
|
8818
|
+
assertDailyIdentity(identity);
|
|
8819
|
+
});
|
|
8820
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
8821
|
+
const check = matrix.checks.find((value) => value.name === checkName);
|
|
8822
|
+
if (!check)
|
|
8823
|
+
return yield* fail("Unknown Daily native check");
|
|
8824
|
+
const host = platformTargets[check.platform];
|
|
8825
|
+
if (os !== host[0] || arch !== host[1])
|
|
8826
|
+
return yield* fail(`Daily native check requires ${check.platform}`);
|
|
8827
|
+
if (os === "linux" && !env.DISPLAY)
|
|
8828
|
+
return yield* fail("Daily Linux native observer requires a display");
|
|
8829
|
+
const previous = check.format === "command" ? undefined : yield* attempt(() => parseBaseline(options.baseline, identity.tag));
|
|
8830
|
+
if (check.format === "command" && options.baseline !== undefined)
|
|
8831
|
+
return yield* fail("Command observation does not take an installer baseline");
|
|
8832
|
+
const prior = previous ? yield* attempt(() => priorDailyInstallerNames(config, previous.tag, check)) : undefined;
|
|
8833
|
+
if (previous && (!prior?.installer || previous.kind === "private-from-verified-payload" && !prior.payload))
|
|
8834
|
+
return yield* fail("Missing same-format baseline names");
|
|
8835
|
+
const path = yield* attempt(() => driverPath(options.driver));
|
|
8836
|
+
const revision = yield* step(() => git.run(["rev-parse", "HEAD"]));
|
|
8837
|
+
if (revision !== identity.sourceSha)
|
|
8838
|
+
return yield* fail("Native observer checkout does not match release source");
|
|
8839
|
+
const tree = yield* step(() => git.run(["ls-tree", revision, "--", path]));
|
|
8840
|
+
const blob = /^100(?:644|755) blob ([a-f0-9]{40})\t/.exec(tree)?.[1];
|
|
8841
|
+
if (!blob || tree.slice(tree.indexOf("\t") + 1) !== path)
|
|
8842
|
+
return yield* fail("Native observer is not a regular file of the pinned source");
|
|
8843
|
+
const temp = runnerTemp(env);
|
|
8844
|
+
if (!temp)
|
|
8845
|
+
return yield* fail("Daily native observation needs the runner temp directory");
|
|
8846
|
+
const tempStat = yield* step(() => fs.lstat(temp));
|
|
8847
|
+
if (!tempStat.isDirectory() || tempStat.isSymbolicLink())
|
|
8848
|
+
return yield* fail("Expected real runner temp directory");
|
|
8849
|
+
const root = yield* Effect25.acquireRelease(step(() => fs.mkdtemp(join36(temp, "daily-native-"))), (dir) => Effect25.promise(() => fs.rm(dir, { recursive: true, force: true })));
|
|
8850
|
+
const make = (name) => Effect25.gen(function* () {
|
|
8851
|
+
const dir = join36(root, name);
|
|
8852
|
+
yield* step(() => fs.mkdir(dir, { mode: 448 }));
|
|
8853
|
+
return dir;
|
|
8854
|
+
});
|
|
8855
|
+
const snapshot = (source, target, names) => Effect25.gen(function* () {
|
|
8856
|
+
const directory = resolve18(source);
|
|
8857
|
+
const info = yield* step(() => fs.lstat(directory));
|
|
8858
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
8859
|
+
return yield* fail("Expected real native input directory");
|
|
8860
|
+
return yield* stageExpectedFilesEffect({
|
|
8861
|
+
expected: names,
|
|
8862
|
+
directory: target,
|
|
8863
|
+
sources: Object.fromEntries(names.map((name) => [name, join36(directory, name)]))
|
|
8864
|
+
});
|
|
8865
|
+
});
|
|
8866
|
+
const scriptName = path.endsWith(".mjs") ? "observer.mjs" : "observer.ts";
|
|
8867
|
+
const script = join36(root, scriptName);
|
|
8868
|
+
yield* stageExpectedFilesEffect({
|
|
8869
|
+
directory: root,
|
|
8870
|
+
expected: [scriptName],
|
|
8871
|
+
sources: { [scriptName]: join36(cwd, path) }
|
|
8872
|
+
});
|
|
8873
|
+
const hash = yield* step(() => git.run(["hash-object", "--no-filters", "--", script]));
|
|
8874
|
+
if (hash !== blob)
|
|
8875
|
+
return yield* fail("Native observer file does not match its trusted source blob");
|
|
8876
|
+
const candidate = yield* make("candidate");
|
|
8877
|
+
const assets = yield* snapshot(options.artifacts, candidate, check.assets);
|
|
8878
|
+
const baseline = previous ? yield* make("baseline") : undefined;
|
|
8879
|
+
const baselineFiles = previous ? [
|
|
8880
|
+
prior.installer,
|
|
8881
|
+
...previous.kind === "private-from-verified-payload" ? [prior.payload] : []
|
|
8882
|
+
] : undefined;
|
|
8883
|
+
const earlier = previous && baseline ? yield* snapshot(previous.directory, baseline, baselineFiles) : undefined;
|
|
8884
|
+
const freshProfile = (name) => Effect25.gen(function* () {
|
|
8885
|
+
const dir = yield* make(name);
|
|
8886
|
+
yield* step(() => fs.mkdir(join36(dir, "tmp"), { mode: 448 }));
|
|
8887
|
+
return dir;
|
|
8888
|
+
});
|
|
8889
|
+
const fresh = yield* freshProfile("fresh");
|
|
8890
|
+
const call = (phase, profile, fixture) => step(async () => {
|
|
8891
|
+
if (await git.run(["hash-object", "--no-filters", "--", script]) !== blob)
|
|
8892
|
+
throw new Error("Native observer changed during qualification");
|
|
8893
|
+
const output = await run(script, {
|
|
8894
|
+
phase,
|
|
8895
|
+
tag: identity.tag,
|
|
8896
|
+
check: check.name,
|
|
8897
|
+
format: check.format,
|
|
8898
|
+
candidate,
|
|
8899
|
+
candidateFiles: check.assets,
|
|
8900
|
+
baseline,
|
|
8901
|
+
baselineFiles,
|
|
8902
|
+
baselineTag: previous?.tag,
|
|
8903
|
+
profile,
|
|
8904
|
+
fixture
|
|
8905
|
+
}, phaseEnvironment(env, profile));
|
|
8906
|
+
if (await git.run(["hash-object", "--no-filters", "--", script]) !== blob)
|
|
8907
|
+
throw new Error("Native observer changed during qualification");
|
|
8908
|
+
return output;
|
|
8909
|
+
}).pipe(Effect25.mapError(() => new Error(`Native observer phase failed: ${phase}`)));
|
|
8910
|
+
const installVersion = (phase, version, where) => Effect25.gen(function* () {
|
|
8911
|
+
const result = yield* call(phase, where);
|
|
8912
|
+
if (!isRecord(result) || !hasExactOwnKeys(result, ["version"]) || result.version !== version)
|
|
8913
|
+
return yield* fail(`Native observer did not observe the expected version: ${phase}`);
|
|
8914
|
+
return { version };
|
|
8915
|
+
});
|
|
8916
|
+
const launch = (phase, version, where) => Effect25.gen(function* () {
|
|
8917
|
+
const result = yield* call(phase, where);
|
|
8918
|
+
if (!isRecord(result) || !hasExactOwnKeys(result, ["version", "ready", "stopped"]) || result.version !== version || result.ready !== true || result.stopped !== true)
|
|
8919
|
+
return yield* fail(`Native observer did not observe a ready renderer: ${phase}`);
|
|
8920
|
+
return { version, ready: true };
|
|
8921
|
+
});
|
|
8922
|
+
const version = identity.tag.slice(1);
|
|
8923
|
+
let observations;
|
|
8924
|
+
if (previous && baseline && earlier) {
|
|
8925
|
+
const upgrade = yield* freshProfile("upgrade");
|
|
8926
|
+
const install = yield* installVersion("fresh-install", version, fresh);
|
|
8927
|
+
const launchedFresh = yield* launch("fresh-launch", version, fresh);
|
|
8928
|
+
const installedBefore = yield* installVersion("baseline-install", previous.tag.slice(1), upgrade);
|
|
8929
|
+
const nonce = randomBytes3(24).toString("hex");
|
|
8930
|
+
const before = yield* call("fixture-write", upgrade, nonce);
|
|
8931
|
+
if (!confirmFixture(before, nonce))
|
|
8932
|
+
return yield* fail("Native baseline did not observe synthetic fixture");
|
|
8933
|
+
const upgraded = yield* installVersion("upgrade-install", version, upgrade);
|
|
8934
|
+
const launched = yield* launch("upgrade-launch", version, upgrade);
|
|
8935
|
+
const after = yield* call("fixture-read", upgrade);
|
|
8936
|
+
if (!confirmFixture(after, nonce))
|
|
8937
|
+
return yield* fail("Native upgrade did not retain synthetic fixture");
|
|
8938
|
+
observations = {
|
|
8939
|
+
install,
|
|
8940
|
+
launch: launchedFresh,
|
|
8941
|
+
upgrade: {
|
|
8942
|
+
baselineTag: previous.tag,
|
|
8943
|
+
baselineAsset: earlier[0],
|
|
8944
|
+
baselineOrigin: {
|
|
8945
|
+
kind: previous.kind,
|
|
8946
|
+
sourceSha: previous.sourceSha,
|
|
8947
|
+
...earlier[1] ? { payload: earlier[1] } : {}
|
|
8948
|
+
},
|
|
8949
|
+
baselineVersion: installedBefore.version,
|
|
8950
|
+
upgradedVersion: upgraded.version,
|
|
8951
|
+
ready: launched.ready,
|
|
8952
|
+
fixtureBefore: fixtureDigest(nonce),
|
|
8953
|
+
fixtureAfter: fixtureDigest(nonce)
|
|
8954
|
+
}
|
|
8955
|
+
};
|
|
8956
|
+
} else {
|
|
8957
|
+
const install = yield* installVersion("command-install", version, fresh);
|
|
8958
|
+
const command = yield* call("command-probe", fresh);
|
|
8959
|
+
observations = { install, command };
|
|
8960
|
+
}
|
|
8961
|
+
return yield* createDailyNativeReceiptEffect({
|
|
8962
|
+
config,
|
|
8963
|
+
identity,
|
|
8964
|
+
checkName,
|
|
8965
|
+
artifacts: candidate,
|
|
8966
|
+
baselineArtifacts: baseline,
|
|
8967
|
+
report: {
|
|
8968
|
+
schema: "framework/daily-native-job/v1",
|
|
8969
|
+
...identity,
|
|
8970
|
+
appId: matrix.appId,
|
|
8971
|
+
profile: matrix.profile,
|
|
8972
|
+
check: check.name,
|
|
8973
|
+
platform: check.platform,
|
|
8974
|
+
format: check.format,
|
|
8975
|
+
host: { os, arch },
|
|
8976
|
+
assets,
|
|
8977
|
+
observations
|
|
8978
|
+
}
|
|
8979
|
+
}, { os, arch });
|
|
8980
|
+
}).pipe(Effect25.scoped);
|
|
8981
|
+
|
|
8262
8982
|
// src/library/daily-batch.ts
|
|
8263
|
-
import { join as
|
|
8264
|
-
import { Effect as
|
|
8265
|
-
var stageDailyBatchEffect = (options) =>
|
|
8983
|
+
import { join as join37, resolve as resolve19 } from "path";
|
|
8984
|
+
import { Effect as Effect26, Exit as Exit4 } from "effect";
|
|
8985
|
+
var stageDailyBatchEffect = (options) => Effect26.gen(function* () {
|
|
8266
8986
|
const fs = yield* ReleaseFs;
|
|
8267
|
-
const parent =
|
|
8987
|
+
const parent = resolve19(options.parent);
|
|
8268
8988
|
const root = yield* step(() => fs.lstat(parent));
|
|
8269
8989
|
if (!root.isDirectory() || root.isSymbolicLink())
|
|
8270
8990
|
return yield* fail("Daily staging needs an existing real scratch parent");
|
|
8271
8991
|
const original = yield* verifyDailyReleaseMatrixEffect(options);
|
|
8272
8992
|
const plan = yield* attempt(() => planDailyReleaseMatrix(options.config, options.identity.tag));
|
|
8273
|
-
const directory = yield*
|
|
8274
|
-
const copy = (source, name, expected) =>
|
|
8275
|
-
const target =
|
|
8993
|
+
const directory = yield* Effect26.acquireRelease(step(() => fs.mkdtemp(join37(parent, "daily-candidate-"))), (path, exit) => Exit4.isSuccess(exit) ? Effect26.void : Effect26.promise(() => fs.rm(path, { recursive: true, force: true })));
|
|
8994
|
+
const copy = (source, name, expected) => Effect26.gen(function* () {
|
|
8995
|
+
const target = join37(directory, name);
|
|
8276
8996
|
yield* step(() => fs.mkdir(target, { mode: 448 }));
|
|
8277
8997
|
yield* stageExpectedFilesEffect({
|
|
8278
8998
|
expected,
|
|
8279
8999
|
directory: target,
|
|
8280
|
-
sources: Object.fromEntries(expected.map((file) => [file,
|
|
9000
|
+
sources: Object.fromEntries(expected.map((file) => [file, join37(source, file)]))
|
|
8281
9001
|
});
|
|
8282
9002
|
return target;
|
|
8283
9003
|
});
|
|
@@ -8287,26 +9007,26 @@ var stageDailyBatchEffect = (options) => Effect25.gen(function* () {
|
|
|
8287
9007
|
if (original.assets.some((a, index) => a.name !== staged.assets[index]?.name || a.size !== staged.assets[index]?.size || a.digest !== staged.assets[index]?.digest))
|
|
8288
9008
|
return yield* fail("Daily inputs changed between inspection and local staging");
|
|
8289
9009
|
const manifest = { schema: "framework/daily-staged-batch/v1", ...staged };
|
|
8290
|
-
yield* step(() => fs.writeFile(
|
|
9010
|
+
yield* step(() => fs.writeFile(join37(directory, "candidate.json"), JSON.stringify(manifest) + `
|
|
8291
9011
|
`, {
|
|
8292
9012
|
flag: "wx",
|
|
8293
9013
|
mode: 384
|
|
8294
9014
|
}));
|
|
8295
9015
|
return { directory, ...manifest };
|
|
8296
|
-
}).pipe(
|
|
9016
|
+
}).pipe(Effect26.scoped);
|
|
8297
9017
|
|
|
8298
9018
|
// src/cli-runner.ts
|
|
8299
|
-
import { Cause as Cause3, Effect as
|
|
9019
|
+
import { Cause as Cause3, Effect as Effect27, Exit as Exit5 } from "effect";
|
|
8300
9020
|
function failureError(cause) {
|
|
8301
9021
|
const error = Cause3.squash(cause);
|
|
8302
9022
|
if (error instanceof ReleaseFailure)
|
|
8303
9023
|
return new Error(error.message);
|
|
8304
9024
|
return error instanceof Error ? error : new Error(String(error));
|
|
8305
9025
|
}
|
|
8306
|
-
var runCommand = (failure, program, options = {}) =>
|
|
9026
|
+
var runCommand = (failure, program, options = {}) => Effect27.gen(function* () {
|
|
8307
9027
|
const { env } = yield* ReleaseConfig;
|
|
8308
9028
|
const output = yield* ReleaseOutput;
|
|
8309
|
-
const exit = yield*
|
|
9029
|
+
const exit = yield* Effect27.exit(options.requireGitHubActions && env.GITHUB_ACTIONS !== "true" ? refuse("untrusted", "Invalid workflow invocation") : program);
|
|
8310
9030
|
if (Exit5.isSuccess(exit))
|
|
8311
9031
|
return 0;
|
|
8312
9032
|
if (Cause3.hasInterruptsOnly(exit.cause))
|
|
@@ -8317,7 +9037,7 @@ var runCommand = (failure, program, options = {}) => Effect26.gen(function* () {
|
|
|
8317
9037
|
return 1;
|
|
8318
9038
|
});
|
|
8319
9039
|
var readReleaseConfig = (path) => readBoundedJson(path, 262144);
|
|
8320
|
-
var readBoundedJson = (path, maxBytes, name = "configuration file") =>
|
|
9040
|
+
var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect27.gen(function* () {
|
|
8321
9041
|
const fs = yield* ReleaseFs;
|
|
8322
9042
|
const info = yield* step(() => fs.lstat(path));
|
|
8323
9043
|
if (!info.isFile() || info.size < 1 || info.size > maxBytes)
|
|
@@ -8327,27 +9047,27 @@ var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect26.
|
|
|
8327
9047
|
return yield* refuse("file-changed", `${name[0].toUpperCase()}${name.slice(1)} changed`);
|
|
8328
9048
|
return yield* step(async () => JSON.parse(bytes.toString("utf8")));
|
|
8329
9049
|
});
|
|
8330
|
-
var provideLivePorts = (program) => program.pipe(
|
|
9050
|
+
var provideLivePorts = (program) => program.pipe(Effect27.provideService(ReleaseConfig, {
|
|
8331
9051
|
env: process.env,
|
|
8332
9052
|
platform: process.platform,
|
|
8333
9053
|
arch: process.arch,
|
|
8334
9054
|
cwd: process.cwd()
|
|
8335
|
-
}),
|
|
9055
|
+
}), Effect27.provideService(ReleaseOutput, {
|
|
8336
9056
|
stdout: (text) => void process.stdout.write(text),
|
|
8337
9057
|
stderr: (text) => void process.stderr.write(text)
|
|
8338
|
-
}),
|
|
9058
|
+
}), Effect27.provideService(ReleaseGit, { run: gitRun }), Effect27.provideService(ReleaseGitHub, { run: ghRun, withEnvironment: ghRunWith }), Effect27.provideService(ReleaseFetch, { fetch }), Effect27.provideService(ReleaseClock, {
|
|
8339
9059
|
sleep: (milliseconds) => Bun.sleep(milliseconds),
|
|
8340
9060
|
now: () => new Date().toISOString()
|
|
8341
|
-
}),
|
|
9061
|
+
}), Effect27.provideService(ReleaseFs, nodeFs), Effect27.provideService(ReleaseSigning, {
|
|
8342
9062
|
privateKey: environmentKey(process.env),
|
|
8343
9063
|
codesign: codesignRun
|
|
8344
9064
|
}));
|
|
8345
9065
|
|
|
8346
9066
|
// src/commands/prepare-stable-catalog.ts
|
|
8347
|
-
import { createHash as
|
|
8348
|
-
import { createReadStream } from "fs";
|
|
8349
|
-
import { lstat as
|
|
8350
|
-
import { basename as
|
|
9067
|
+
import { createHash as createHash18 } from "crypto";
|
|
9068
|
+
import { createReadStream as createReadStream2 } from "fs";
|
|
9069
|
+
import { lstat as lstat21, mkdir as mkdir13, readFile as readFile11, rm as rm12, writeFile as writeFile13 } from "fs/promises";
|
|
9070
|
+
import { basename as basename17, dirname as dirname16, join as join38 } from "path";
|
|
8351
9071
|
|
|
8352
9072
|
// src/library/stable-catalogs.ts
|
|
8353
9073
|
function object(value) {
|
|
@@ -8508,10 +9228,10 @@ ShortDescription: ${quoted(desc)}
|
|
|
8508
9228
|
|
|
8509
9229
|
// src/commands/prepare-stable-catalog.ts
|
|
8510
9230
|
var read2 = async (path) => {
|
|
8511
|
-
const stat = await
|
|
9231
|
+
const stat = await lstat21(path);
|
|
8512
9232
|
if (!stat.isFile() || stat.size > 1024 * 1024)
|
|
8513
9233
|
throw new Error("Expected bounded ordinary JSON file");
|
|
8514
|
-
return JSON.parse(await
|
|
9234
|
+
return JSON.parse(await readFile11(path, "utf8"));
|
|
8515
9235
|
};
|
|
8516
9236
|
async function prepareStableCatalogCommand(args) {
|
|
8517
9237
|
const [
|
|
@@ -8528,11 +9248,11 @@ async function prepareStableCatalogCommand(args) {
|
|
|
8528
9248
|
] = args;
|
|
8529
9249
|
if (channel !== "homebrew" && channel !== "winget" || phase !== "preflight" && phase !== "published-stable" || !expectedSourceSha || !configPath || !receiptPath || !manifestPath || !artifact || !out || extra.length || phase === "published-stable" !== Boolean(stablePointerPath))
|
|
8530
9250
|
throw new Error("Expected channel, phase, source SHA, config, receipt, manifest, archive, new output directory [stable pointer]");
|
|
8531
|
-
const st = await
|
|
9251
|
+
const st = await lstat21(artifact);
|
|
8532
9252
|
if (!st.isFile())
|
|
8533
9253
|
throw new Error("Expected ordinary installer file");
|
|
8534
|
-
const hash =
|
|
8535
|
-
for await (const chunk of
|
|
9254
|
+
const hash = createHash18("sha256");
|
|
9255
|
+
for await (const chunk of createReadStream2(artifact))
|
|
8536
9256
|
hash.update(chunk);
|
|
8537
9257
|
const files = prepareStableCatalog({
|
|
8538
9258
|
channel,
|
|
@@ -8542,31 +9262,31 @@ async function prepareStableCatalogCommand(args) {
|
|
|
8542
9262
|
receipt: await read2(receiptPath),
|
|
8543
9263
|
manifest: await read2(manifestPath),
|
|
8544
9264
|
stablePointer: stablePointerPath && await read2(stablePointerPath),
|
|
8545
|
-
measuredAsset: { name:
|
|
9265
|
+
measuredAsset: { name: basename17(artifact), size: st.size, sha256: hash.digest("hex") }
|
|
8546
9266
|
});
|
|
8547
|
-
await
|
|
9267
|
+
await mkdir13(out);
|
|
8548
9268
|
try {
|
|
8549
9269
|
for (const entry of files) {
|
|
8550
|
-
const target =
|
|
8551
|
-
await
|
|
8552
|
-
await
|
|
9270
|
+
const target = join38(out, entry.path);
|
|
9271
|
+
await mkdir13(dirname16(target), { recursive: true });
|
|
9272
|
+
await writeFile13(target, entry.contents, { flag: "wx" });
|
|
8553
9273
|
}
|
|
8554
9274
|
return { channel, phase, files: files.length };
|
|
8555
9275
|
} catch (error) {
|
|
8556
|
-
await
|
|
9276
|
+
await rm12(out, { recursive: true, force: true });
|
|
8557
9277
|
throw error;
|
|
8558
9278
|
}
|
|
8559
9279
|
}
|
|
8560
9280
|
|
|
8561
9281
|
// src/library/apt/stage-apt-repository.ts
|
|
8562
9282
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
8563
|
-
import { mkdir as
|
|
8564
|
-
import { dirname as
|
|
9283
|
+
import { mkdir as mkdir14, readFile as readFile12, rm as rm13, writeFile as writeFile14 } from "fs/promises";
|
|
9284
|
+
import { dirname as dirname17, isAbsolute as isAbsolute7, join as join39 } from "path";
|
|
8565
9285
|
|
|
8566
9286
|
// src/library/apt/apt-metadata.ts
|
|
8567
|
-
import { createHash as
|
|
9287
|
+
import { createHash as createHash19 } from "crypto";
|
|
8568
9288
|
import { gzipSync } from "zlib";
|
|
8569
|
-
var
|
|
9289
|
+
var sha2562 = (data) => createHash19("sha256").update(data).digest("hex");
|
|
8570
9290
|
function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
|
|
8571
9291
|
if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
|
|
8572
9292
|
throw new Error("Invalid release tag");
|
|
@@ -8577,7 +9297,7 @@ function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
|
|
|
8577
9297
|
if (matching.length !== 1)
|
|
8578
9298
|
throw new Error("Require one staged Debian artifact");
|
|
8579
9299
|
const asset = matching[0];
|
|
8580
|
-
if (!deb.length || asset.size !== deb.length || asset.sha256 !==
|
|
9300
|
+
if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha2562(deb))
|
|
8581
9301
|
throw new Error("Staged Debian bytes do not match the verified release inventory");
|
|
8582
9302
|
const fields = new Map;
|
|
8583
9303
|
let lines = control.replaceAll(`\r
|
|
@@ -8627,7 +9347,7 @@ SHA256: ${asset.sha256}
|
|
|
8627
9347
|
"Components: main",
|
|
8628
9348
|
"Acquire-By-Hash: yes",
|
|
8629
9349
|
"SHA256:",
|
|
8630
|
-
...members.map(([path, bytes]) => ` ${
|
|
9350
|
+
...members.map(([path, bytes]) => ` ${sha2562(bytes)} ${bytes.length} ${path}`),
|
|
8631
9351
|
""
|
|
8632
9352
|
].join(`
|
|
8633
9353
|
`);
|
|
@@ -8636,7 +9356,7 @@ SHA256: ${asset.sha256}
|
|
|
8636
9356
|
release,
|
|
8637
9357
|
files: new Map([
|
|
8638
9358
|
...members,
|
|
8639
|
-
...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${
|
|
9359
|
+
...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha2562(bytes)}`, bytes])
|
|
8640
9360
|
])
|
|
8641
9361
|
};
|
|
8642
9362
|
}
|
|
@@ -8649,22 +9369,22 @@ function cmd(program, options, label) {
|
|
|
8649
9369
|
return run.stdout;
|
|
8650
9370
|
}
|
|
8651
9371
|
async function add(path, bytes) {
|
|
8652
|
-
await
|
|
8653
|
-
await
|
|
9372
|
+
await mkdir14(dirname17(path), { recursive: true });
|
|
9373
|
+
await writeFile14(path, bytes, { flag: "wx" });
|
|
8654
9374
|
}
|
|
8655
9375
|
async function stageAptRepositoryCommand(args) {
|
|
8656
9376
|
const [tag, policyPath, inventoryPath, packagePath, output, signingHome, trustedFingerprint] = args;
|
|
8657
|
-
if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !
|
|
9377
|
+
if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !isAbsolute7(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
|
|
8658
9378
|
throw new Error("Expected TAG POLICY VERIFIED_INVENTORY DEB NEW_OUTPUT GPG_HOME PINNED_FINGERPRINT");
|
|
8659
|
-
const policy = JSON.parse(await
|
|
8660
|
-
const inventory = JSON.parse(await
|
|
9379
|
+
const policy = JSON.parse(await readFile12(policyPath, "utf8"));
|
|
9380
|
+
const inventory = JSON.parse(await readFile12(inventoryPath, "utf8"));
|
|
8661
9381
|
if (inventory.tag !== tag || !Array.isArray(inventory.assets))
|
|
8662
9382
|
throw new Error("Verified inventory does not name requested release");
|
|
8663
|
-
const deb = await
|
|
8664
|
-
await
|
|
9383
|
+
const deb = await readFile12(packagePath);
|
|
9384
|
+
await mkdir14(output, { mode: 448 });
|
|
8665
9385
|
try {
|
|
8666
|
-
const stagedInput =
|
|
8667
|
-
await
|
|
9386
|
+
const stagedInput = join39(output, ".input.deb");
|
|
9387
|
+
await writeFile14(stagedInput, deb, { mode: 384, flag: "wx" });
|
|
8668
9388
|
const control = cmd("dpkg-deb", ["--field", stagedInput], "Debian control inspection failed");
|
|
8669
9389
|
const staged = stageAptMetadata({
|
|
8670
9390
|
policy,
|
|
@@ -8674,11 +9394,11 @@ async function stageAptRepositoryCommand(args) {
|
|
|
8674
9394
|
control,
|
|
8675
9395
|
now: new Date
|
|
8676
9396
|
});
|
|
8677
|
-
const base =
|
|
8678
|
-
await add(
|
|
9397
|
+
const base = join39(output, "dists", policy.suite);
|
|
9398
|
+
await add(join39(output, staged.packagePath), deb);
|
|
8679
9399
|
for (const [path, contents] of staged.files)
|
|
8680
|
-
await add(
|
|
8681
|
-
await add(
|
|
9400
|
+
await add(join39(base, path), contents);
|
|
9401
|
+
await add(join39(base, "Release"), staged.release);
|
|
8682
9402
|
const flags = [
|
|
8683
9403
|
"--batch",
|
|
8684
9404
|
"--no-tty",
|
|
@@ -8695,34 +9415,34 @@ async function stageAptRepositoryCommand(args) {
|
|
|
8695
9415
|
["InRelease", "--clearsign"],
|
|
8696
9416
|
["Release.gpg", "--detach-sign"]
|
|
8697
9417
|
]) {
|
|
8698
|
-
cmd("gpg", [...flags, "--armor", "--output",
|
|
9418
|
+
cmd("gpg", [...flags, "--armor", "--output", join39(base, name), mode, join39(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
|
|
8699
9419
|
}
|
|
8700
9420
|
const { unlink } = await import("fs/promises");
|
|
8701
9421
|
await unlink(stagedInput);
|
|
8702
|
-
await add(
|
|
9422
|
+
await add(join39(output, "STAGED"), `${tag}
|
|
8703
9423
|
`);
|
|
8704
9424
|
return { tag, staged: true };
|
|
8705
9425
|
} catch (error) {
|
|
8706
|
-
await
|
|
9426
|
+
await rm13(output, { recursive: true, force: true });
|
|
8707
9427
|
throw error;
|
|
8708
9428
|
}
|
|
8709
9429
|
}
|
|
8710
9430
|
|
|
8711
9431
|
// src/linux-channel-proof-cli.ts
|
|
8712
9432
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
8713
|
-
import { createHash as
|
|
8714
|
-
import { createReadStream as
|
|
8715
|
-
import { lstat as
|
|
8716
|
-
import { join as
|
|
9433
|
+
import { createHash as createHash20 } from "crypto";
|
|
9434
|
+
import { createReadStream as createReadStream3 } from "fs";
|
|
9435
|
+
import { lstat as lstat22, readFile as readFile13, realpath as realpath12 } from "fs/promises";
|
|
9436
|
+
import { join as join40 } from "path";
|
|
8717
9437
|
import { pathToFileURL } from "url";
|
|
8718
|
-
function
|
|
9438
|
+
function check2(ok, message) {
|
|
8719
9439
|
if (!ok)
|
|
8720
9440
|
throw new Error(message);
|
|
8721
9441
|
}
|
|
8722
9442
|
async function hash(path) {
|
|
8723
|
-
|
|
8724
|
-
const digest =
|
|
8725
|
-
for await (const chunk of
|
|
9443
|
+
check2((await lstat22(path)).isFile(), "artifact must be a regular file");
|
|
9444
|
+
const digest = createHash20("sha256");
|
|
9445
|
+
for await (const chunk of createReadStream3(path))
|
|
8726
9446
|
digest.update(chunk);
|
|
8727
9447
|
return digest.digest("hex");
|
|
8728
9448
|
}
|
|
@@ -8738,56 +9458,56 @@ function options(text, section) {
|
|
|
8738
9458
|
continue;
|
|
8739
9459
|
}
|
|
8740
9460
|
const field = /^([a-z_]+)\s*=\s*(\S+)$/.exec(line);
|
|
8741
|
-
|
|
9461
|
+
check2(matched && field && !values.has(field[1]), "unexpected or duplicate repository option");
|
|
8742
9462
|
values.set(field[1], field[2]);
|
|
8743
9463
|
}
|
|
8744
|
-
|
|
9464
|
+
check2(matched, "expected exactly one repository section");
|
|
8745
9465
|
return values;
|
|
8746
9466
|
}
|
|
8747
9467
|
async function verifyRpmStage(stage) {
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
9468
|
+
check2(/^[0-9a-f]{40}$/.test(stage.sourceSha), "expected an exact source commit");
|
|
9469
|
+
check2(/^[a-z0-9][a-z0-9._+-]*$/.test(stage.packageName), "invalid RPM package name");
|
|
9470
|
+
check2(/^[a-zA-Z0-9][a-zA-Z0-9._+~^]*$/.test(stage.version), "invalid RPM version");
|
|
9471
|
+
check2(stage.architecture === "x86_64", "only x86_64 is supported");
|
|
9472
|
+
check2(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/.test(stage.repoId), "invalid repository ID");
|
|
8753
9473
|
for (const artifact of [stage.payload, stage.rpm]) {
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
}
|
|
8757
|
-
const repo = await
|
|
8758
|
-
const keyUrl = pathToFileURL(await
|
|
8759
|
-
const config = options(await
|
|
8760
|
-
|
|
8761
|
-
|
|
9474
|
+
check2(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
|
|
9475
|
+
check2(await hash(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
|
|
9476
|
+
}
|
|
9477
|
+
const repo = await realpath12(stage.repository);
|
|
9478
|
+
const keyUrl = pathToFileURL(await realpath12(stage.publicKey)).href;
|
|
9479
|
+
const config = options(await readFile13(stage.repoFile, "utf8"), stage.repoId);
|
|
9480
|
+
check2(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
|
|
9481
|
+
check2(config.get("gpgkey") === keyUrl, "expected the configured QA public key");
|
|
8762
9482
|
for (const flag of ["pkg_gpgcheck", "repo_gpgcheck"]) {
|
|
8763
|
-
|
|
9483
|
+
check2(config.get(flag) === "1", `${flag} must be enabled`);
|
|
8764
9484
|
}
|
|
8765
9485
|
const allowed = new Set(["name", "enabled", "baseurl", "gpgkey", "pkg_gpgcheck", "repo_gpgcheck"]);
|
|
8766
|
-
|
|
9486
|
+
check2([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
|
|
8767
9487
|
for (const path of [
|
|
8768
9488
|
stage.publicKey,
|
|
8769
|
-
|
|
8770
|
-
|
|
9489
|
+
join40(repo, "repodata/repomd.xml"),
|
|
9490
|
+
join40(repo, "repodata/repomd.xml.asc")
|
|
8771
9491
|
]) {
|
|
8772
|
-
|
|
9492
|
+
check2((await lstat22(path)).isFile(), "expected regular key and signed metadata files");
|
|
8773
9493
|
}
|
|
8774
|
-
const result = spawnSync3("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await
|
|
8775
|
-
|
|
8776
|
-
|
|
9494
|
+
const result = spawnSync3("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath12(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
|
|
9495
|
+
check2(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
|
|
9496
|
+
check2(result.status === 0 && result.stdout === `${stage.packageName}|${stage.version}|${stage.architecture}`, "RPM header does not match the requested package, version and architecture");
|
|
8777
9497
|
return { kind: "rpm-staging-inputs", sourceSha: stage.sourceSha };
|
|
8778
9498
|
}
|
|
8779
9499
|
var systemTalkDenied = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
|
|
8780
9500
|
function verifyFlatpakCapabilities(policy, result) {
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
9501
|
+
check2(/^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/.test(policy.applicationId) && result.applicationId === policy.applicationId, "unexpected Flatpak app identity");
|
|
9502
|
+
check2(/^[0-9a-f]{40}$/.test(policy.sourceSha) && result.sourceSha === policy.sourceSha && /^[0-9a-f]{64}$/.test(policy.artifactSha256) && result.artifactSha256 === policy.artifactSha256, "Flatpak evidence does not match the expected source and artifact");
|
|
9503
|
+
check2(result.architecture === "x86_64", "only x86_64 is supported");
|
|
8784
9504
|
const cap = policy.permissions;
|
|
8785
9505
|
const actual = result.effectivePermissions;
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
9506
|
+
check2(cap.sockets.every((name) => name === "wayland" || name === "pulseaudio"), "unsafe socket policy");
|
|
9507
|
+
check2(cap.devices.every((name) => name === "dri"), "unsafe device policy");
|
|
9508
|
+
check2(cap.sessionTalkNames.every((name) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(name) && !systemTalkDenied.test(name)), "unsafe session-bus policy");
|
|
9509
|
+
check2(typeof actual.network === "boolean" && typeof cap.network === "boolean" && (!actual.network || cap.network === true) && actual.sockets.every((name) => cap.sockets.some((allowed) => allowed === name)) && actual.devices.every((name) => cap.devices.some((allowed) => allowed === name)) && actual.sessionTalkNames.every((name) => cap.sessionTalkNames.includes(name)) && actual.filesystems.length === 0 && actual.systemTalkNames.length === 0, "effective Flatpak permissions exceed policy");
|
|
9510
|
+
check2([
|
|
8791
9511
|
result.localRepositoryInstall,
|
|
8792
9512
|
result.upgradedAndRetainedData,
|
|
8793
9513
|
result.sandboxedRenderer,
|
|
@@ -8801,10 +9521,10 @@ function verifyFlatpakCapabilities(policy, result) {
|
|
|
8801
9521
|
}
|
|
8802
9522
|
|
|
8803
9523
|
// src/library/arch-publish.ts
|
|
8804
|
-
import { createHash as
|
|
8805
|
-
import { join as
|
|
9524
|
+
import { createHash as createHash21 } from "crypto";
|
|
9525
|
+
import { join as join41 } from "path";
|
|
8806
9526
|
import { tmpdir as tmpdir5 } from "os";
|
|
8807
|
-
import { Effect as
|
|
9527
|
+
import { Effect as Effect28 } from "effect";
|
|
8808
9528
|
|
|
8809
9529
|
// ../../src/release/arch-package.ts
|
|
8810
9530
|
function archPkgver(tag) {
|
|
@@ -8985,7 +9705,7 @@ exec pacman -S --needed --noconfirm "$@"
|
|
|
8985
9705
|
// src/library/arch-publish.ts
|
|
8986
9706
|
var AUR_HOST_KEY = "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN";
|
|
8987
9707
|
var MAX_LICENSE_BYTES = 1024 * 1024;
|
|
8988
|
-
var feedBytes = (feed, path, maximum) =>
|
|
9708
|
+
var feedBytes = (feed, path, maximum) => Effect28.gen(function* () {
|
|
8989
9709
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
8990
9710
|
const scope = feedUrl(feed);
|
|
8991
9711
|
const response = yield* step(() => fetchReleaseLocation(`${scope}${path}`, scope, fetch2, AbortSignal.timeout(30000)));
|
|
@@ -8995,7 +9715,7 @@ var feedBytes = (feed, path, maximum) => Effect27.gen(function* () {
|
|
|
8995
9715
|
}
|
|
8996
9716
|
return yield* step(() => readReleaseBytes(response, maximum));
|
|
8997
9717
|
});
|
|
8998
|
-
var feedJson = (feed, path, maximum) =>
|
|
9718
|
+
var feedJson = (feed, path, maximum) => Effect28.gen(function* () {
|
|
8999
9719
|
const bytes = yield* feedBytes(feed, path, maximum);
|
|
9000
9720
|
if (!bytes)
|
|
9001
9721
|
return null;
|
|
@@ -9007,13 +9727,13 @@ var feedJson = (feed, path, maximum) => Effect27.gen(function* () {
|
|
|
9007
9727
|
}
|
|
9008
9728
|
});
|
|
9009
9729
|
});
|
|
9010
|
-
var readChannelTag = (feed, channel) =>
|
|
9730
|
+
var readChannelTag = (feed, channel) => Effect28.gen(function* () {
|
|
9011
9731
|
const parsed = yield* feedJson(feed, `channels/${channel}.json`, 262144);
|
|
9012
9732
|
if (parsed === null)
|
|
9013
9733
|
return null;
|
|
9014
9734
|
return yield* step(async () => parseFeedRelease(parsed).tag);
|
|
9015
9735
|
});
|
|
9016
|
-
var readLicense = (url) =>
|
|
9736
|
+
var readLicense = (url) => Effect28.gen(function* () {
|
|
9017
9737
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
9018
9738
|
const response = yield* step(() => fetch2(url, { redirect: "follow", signal: AbortSignal.timeout(30000) }));
|
|
9019
9739
|
if (response.status !== 200 || !response.body) {
|
|
@@ -9021,12 +9741,12 @@ var readLicense = (url) => Effect27.gen(function* () {
|
|
|
9021
9741
|
return yield* fail("Release license is unavailable");
|
|
9022
9742
|
}
|
|
9023
9743
|
const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
|
|
9024
|
-
const sha256 = yield* step(async () =>
|
|
9744
|
+
const sha256 = yield* step(async () => createHash21("sha256").update(bytes).digest("hex"));
|
|
9025
9745
|
return { url, sha256 };
|
|
9026
9746
|
});
|
|
9027
|
-
var git2 = (args) =>
|
|
9747
|
+
var git2 = (args) => Effect28.gen(function* () {
|
|
9028
9748
|
const { run } = yield* ReleaseGit;
|
|
9029
|
-
return yield*
|
|
9749
|
+
return yield* Effect28.tryPromise({
|
|
9030
9750
|
try: () => run(args),
|
|
9031
9751
|
catch: (error) => {
|
|
9032
9752
|
const stderr = String(error.stderr ?? "").trim().split(`
|
|
@@ -9039,11 +9759,11 @@ var git2 = (args) => Effect27.gen(function* () {
|
|
|
9039
9759
|
}
|
|
9040
9760
|
});
|
|
9041
9761
|
});
|
|
9042
|
-
var gitExit = (args) =>
|
|
9762
|
+
var gitExit = (args) => Effect28.gen(function* () {
|
|
9043
9763
|
const { run } = yield* ReleaseGit;
|
|
9044
|
-
return yield*
|
|
9764
|
+
return yield* Effect28.promise(() => run(args).then(() => 0, (error) => Number(error.code ?? 1) || 1));
|
|
9045
9765
|
});
|
|
9046
|
-
var verifyArchRelease = (options) =>
|
|
9766
|
+
var verifyArchRelease = (options) => Effect28.gen(function* () {
|
|
9047
9767
|
const parsed = parseReleaseConfig(options.config);
|
|
9048
9768
|
const { config } = options;
|
|
9049
9769
|
const repository = typeof config.repository === "string" && isRepositorySlug(config.repository) ? config.repository : null;
|
|
@@ -9063,7 +9783,7 @@ var verifyArchRelease = (options) => Effect27.gen(function* () {
|
|
|
9063
9783
|
if (!listed)
|
|
9064
9784
|
return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
|
|
9065
9785
|
const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
|
|
9066
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
9786
|
+
if (!bytes || bytes.length !== listed.size || createHash21("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
9067
9787
|
return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
|
|
9068
9788
|
const json = yield* step(async () => {
|
|
9069
9789
|
try {
|
|
@@ -9093,7 +9813,7 @@ var verifyArchRelease = (options) => Effect27.gen(function* () {
|
|
|
9093
9813
|
return yield* fail("Signed descriptor does not bind the published archive");
|
|
9094
9814
|
return descriptor.asset;
|
|
9095
9815
|
});
|
|
9096
|
-
var publishArchPackageEffect = (options) =>
|
|
9816
|
+
var publishArchPackageEffect = (options) => Effect28.gen(function* () {
|
|
9097
9817
|
const { archPackage: policy, feed } = parseReleaseConfig(options.config);
|
|
9098
9818
|
if (!policy)
|
|
9099
9819
|
return { status: "not-configured" };
|
|
@@ -9135,7 +9855,7 @@ var publishArchPackageEffect = (options) => Effect27.gen(function* () {
|
|
|
9135
9855
|
const directory = options.printDirectory;
|
|
9136
9856
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
9137
9857
|
for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
|
|
9138
|
-
yield* step(() => fs.writeFile(
|
|
9858
|
+
yield* step(() => fs.writeFile(join41(directory, name), contents, { mode: 420 }));
|
|
9139
9859
|
}
|
|
9140
9860
|
const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
|
|
9141
9861
|
if (options.dryRun)
|
|
@@ -9147,15 +9867,15 @@ var publishArchPackageEffect = (options) => Effect27.gen(function* () {
|
|
|
9147
9867
|
const key = Buffer.from(encodedKey, "base64").toString("utf8");
|
|
9148
9868
|
if (!key.includes("PRIVATE KEY"))
|
|
9149
9869
|
return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
|
|
9150
|
-
return yield*
|
|
9151
|
-
const work = yield* step(() => fs.mkdtemp(
|
|
9152
|
-
yield*
|
|
9870
|
+
return yield* Effect28.gen(function* () {
|
|
9871
|
+
const work = yield* step(() => fs.mkdtemp(join41(tmpdir5(), "arch-package-")));
|
|
9872
|
+
yield* Effect28.addFinalizer(() => Effect28.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
|
|
9153
9873
|
return;
|
|
9154
9874
|
}, () => {
|
|
9155
9875
|
return;
|
|
9156
9876
|
})));
|
|
9157
|
-
const keyFile =
|
|
9158
|
-
const knownHosts =
|
|
9877
|
+
const keyFile = join41(work, "aur_id_ed25519");
|
|
9878
|
+
const knownHosts = join41(work, "aur_known_hosts");
|
|
9159
9879
|
yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
|
|
9160
9880
|
yield* step(() => fs.writeFile(keyFile, key.endsWith(`
|
|
9161
9881
|
`) ? key : `${key}
|
|
@@ -9163,7 +9883,7 @@ var publishArchPackageEffect = (options) => Effect27.gen(function* () {
|
|
|
9163
9883
|
yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
|
|
9164
9884
|
`, { mode: 420 }));
|
|
9165
9885
|
const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
|
|
9166
|
-
const checkout =
|
|
9886
|
+
const checkout = join41(work, policy.pkgname);
|
|
9167
9887
|
yield* git2([
|
|
9168
9888
|
"-c",
|
|
9169
9889
|
`core.sshCommand=${ssh}`,
|
|
@@ -9176,7 +9896,7 @@ var publishArchPackageEffect = (options) => Effect27.gen(function* () {
|
|
|
9176
9896
|
checkout
|
|
9177
9897
|
]);
|
|
9178
9898
|
for (const [name, contents] of Object.entries(files))
|
|
9179
|
-
yield* step(() => fs.writeFile(
|
|
9899
|
+
yield* step(() => fs.writeFile(join41(checkout, name), contents, { mode: 420 }));
|
|
9180
9900
|
yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
|
|
9181
9901
|
const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
|
|
9182
9902
|
if (staged === 0)
|
|
@@ -9197,35 +9917,35 @@ var publishArchPackageEffect = (options) => Effect27.gen(function* () {
|
|
|
9197
9917
|
]);
|
|
9198
9918
|
yield* git2(["-C", checkout, "-c", `core.sshCommand=${ssh}`, "push", "origin", "HEAD:master"]);
|
|
9199
9919
|
return { status: "published", ...base };
|
|
9200
|
-
}).pipe(
|
|
9920
|
+
}).pipe(Effect28.scoped);
|
|
9201
9921
|
});
|
|
9202
9922
|
|
|
9203
9923
|
// src/cli-commands.ts
|
|
9204
|
-
var print = (value) =>
|
|
9924
|
+
var print = (value) => Effect29.gen(function* () {
|
|
9205
9925
|
const { stdout } = yield* ReleaseOutput;
|
|
9206
9926
|
stdout(JSON.stringify(value) + `
|
|
9207
9927
|
`);
|
|
9208
9928
|
});
|
|
9209
|
-
var say = (line) =>
|
|
9929
|
+
var say = (line) => Effect29.gen(function* () {
|
|
9210
9930
|
const { stdout } = yield* ReleaseOutput;
|
|
9211
9931
|
stdout(line + `
|
|
9212
9932
|
`);
|
|
9213
9933
|
});
|
|
9214
9934
|
var invalid = (message = "Invalid workflow invocation") => refuse("usage", message);
|
|
9215
9935
|
var localFlag = (args) => args[0] === "--local" ? [true, args.slice(1)] : [false, args];
|
|
9216
|
-
var hostPlatform =
|
|
9936
|
+
var hostPlatform = Effect29.gen(function* () {
|
|
9217
9937
|
const { platform, arch } = yield* ReleaseConfig;
|
|
9218
9938
|
return yield* step(async () => hostReleasePlatform(platform, arch));
|
|
9219
9939
|
});
|
|
9220
|
-
var withPlanGitHub = (env, effect) =>
|
|
9940
|
+
var withPlanGitHub = (env, effect) => Effect29.gen(function* () {
|
|
9221
9941
|
const github = yield* ReleaseGitHub;
|
|
9222
|
-
return yield* effect.pipe(
|
|
9942
|
+
return yield* effect.pipe(Effect29.provideService(ReleaseGitHub, {
|
|
9223
9943
|
run: github.withEnvironment ? github.withEnvironment(releasePlanGitHubEnvironment(env)) : github.run
|
|
9224
9944
|
}));
|
|
9225
9945
|
});
|
|
9226
9946
|
var publish = (argv) => {
|
|
9227
9947
|
const [local, args] = localFlag(argv);
|
|
9228
|
-
return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.",
|
|
9948
|
+
return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.", Effect29.gen(function* () {
|
|
9229
9949
|
const [directory, configPath, out, ...extra] = args;
|
|
9230
9950
|
if (!directory || !configPath || extra.length || !out !== !local)
|
|
9231
9951
|
return yield* invalid();
|
|
@@ -9238,7 +9958,7 @@ var publish = (argv) => {
|
|
|
9238
9958
|
const clock = yield* ReleaseClock;
|
|
9239
9959
|
const platform = yield* hostPlatform;
|
|
9240
9960
|
const { repository } = yield* localTagProvenanceEffect({ config, tag, sourceSha });
|
|
9241
|
-
const plan = yield*
|
|
9961
|
+
const plan = yield* Effect29.uninterruptible(stageLocalReleaseEffect({
|
|
9242
9962
|
config,
|
|
9243
9963
|
directory,
|
|
9244
9964
|
out,
|
|
@@ -9256,7 +9976,7 @@ var publish = (argv) => {
|
|
|
9256
9976
|
};
|
|
9257
9977
|
var cut = (argv) => {
|
|
9258
9978
|
const [local, args] = localFlag(argv);
|
|
9259
|
-
return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`,
|
|
9979
|
+
return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect29.gen(function* () {
|
|
9260
9980
|
const [kind, path, sourceSha, ...extra] = args;
|
|
9261
9981
|
if (kind !== "daily" || !path || extra.length || !sourceSha !== !local)
|
|
9262
9982
|
return yield* invalid();
|
|
@@ -9266,7 +9986,7 @@ var cut = (argv) => {
|
|
|
9266
9986
|
const { env } = yield* ReleaseConfig;
|
|
9267
9987
|
if (local) {
|
|
9268
9988
|
const platform = yield* hostPlatform;
|
|
9269
|
-
const result = yield*
|
|
9989
|
+
const result = yield* Effect29.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
|
|
9270
9990
|
return yield* print(result);
|
|
9271
9991
|
}
|
|
9272
9992
|
const result = yield* releaseCutCommand({
|
|
@@ -9280,7 +10000,7 @@ var cut = (argv) => {
|
|
|
9280
10000
|
};
|
|
9281
10001
|
var promote = (argv) => {
|
|
9282
10002
|
const [local, args] = localFlag(argv);
|
|
9283
|
-
return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.",
|
|
10003
|
+
return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.", Effect29.gen(function* () {
|
|
9284
10004
|
const [path, out, ...extra] = args;
|
|
9285
10005
|
const { env } = yield* ReleaseConfig;
|
|
9286
10006
|
const held = env.STABLE_PROMOTION_HELD;
|
|
@@ -9290,7 +10010,7 @@ var promote = (argv) => {
|
|
|
9290
10010
|
if (local) {
|
|
9291
10011
|
const clock = yield* ReleaseClock;
|
|
9292
10012
|
const repository = yield* originRepositoryEffect;
|
|
9293
|
-
const result = yield*
|
|
10013
|
+
const result = yield* Effect29.uninterruptible(runLocalPromotionEffect({
|
|
9294
10014
|
config,
|
|
9295
10015
|
out,
|
|
9296
10016
|
now: clock.now(),
|
|
@@ -9303,7 +10023,7 @@ var promote = (argv) => {
|
|
|
9303
10023
|
yield* print(yield* promotionCommand({ env, config }));
|
|
9304
10024
|
}), { requireGitHubActions: !local });
|
|
9305
10025
|
};
|
|
9306
|
-
var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`,
|
|
10026
|
+
var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9307
10027
|
const { env } = yield* ReleaseConfig;
|
|
9308
10028
|
if (argv[0] === "--local") {
|
|
9309
10029
|
const [configPath, tag, ...extra] = argv.slice(1);
|
|
@@ -9324,7 +10044,7 @@ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${r
|
|
|
9324
10044
|
yield* finalizeReleasePleaseDraftEffect({ env, config, ...identity });
|
|
9325
10045
|
yield* say("Qualified draft published as a prerelease");
|
|
9326
10046
|
}));
|
|
9327
|
-
var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.",
|
|
10047
|
+
var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.", Effect29.gen(function* () {
|
|
9328
10048
|
const [tag, path, ...extra] = args;
|
|
9329
10049
|
if (!tag || !path || extra.length)
|
|
9330
10050
|
return yield* invalid("Expected release tag and configuration file");
|
|
@@ -9332,7 +10052,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
|
|
|
9332
10052
|
const { env } = yield* ReleaseConfig;
|
|
9333
10053
|
yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
|
|
9334
10054
|
}));
|
|
9335
|
-
var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.",
|
|
10055
|
+
var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect29.gen(function* () {
|
|
9336
10056
|
const [identityPath, artifactPath, feed, ...extra] = args;
|
|
9337
10057
|
const { env } = yield* ReleaseConfig;
|
|
9338
10058
|
if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
|
|
@@ -9343,7 +10063,7 @@ var sign2 = (args) => runCommand("Unable to sign release artifact; check the ide
|
|
|
9343
10063
|
}));
|
|
9344
10064
|
var signDescriptors = (argv) => {
|
|
9345
10065
|
const [local, args] = localFlag(argv);
|
|
9346
|
-
return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.",
|
|
10066
|
+
return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.", Effect29.gen(function* () {
|
|
9347
10067
|
const [directory, configPath, ...extra] = args;
|
|
9348
10068
|
const { env } = yield* ReleaseConfig;
|
|
9349
10069
|
const {
|
|
@@ -9376,7 +10096,7 @@ var signDescriptors = (argv) => {
|
|
|
9376
10096
|
}));
|
|
9377
10097
|
}));
|
|
9378
10098
|
};
|
|
9379
|
-
var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`,
|
|
10099
|
+
var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`, Effect29.gen(function* () {
|
|
9380
10100
|
const args = [...argv];
|
|
9381
10101
|
const flag = args.indexOf("--artifacts");
|
|
9382
10102
|
const artifacts = flag === -1 ? undefined : args.splice(flag, 2)[1];
|
|
@@ -9428,9 +10148,9 @@ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.
|
|
|
9428
10148
|
return yield* invalid(`Unknown release step ${String(name)}`);
|
|
9429
10149
|
}
|
|
9430
10150
|
}));
|
|
9431
|
-
var verifyMacosSigning = (args) =>
|
|
10151
|
+
var verifyMacosSigning = (args) => Effect29.gen(function* () {
|
|
9432
10152
|
let problems = 0;
|
|
9433
|
-
const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.",
|
|
10153
|
+
const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.", Effect29.gen(function* () {
|
|
9434
10154
|
const [app, flag, ...extra] = args;
|
|
9435
10155
|
if (!app || extra.length || ![undefined, "--hardened"].includes(flag))
|
|
9436
10156
|
return yield* invalid("usage");
|
|
@@ -9443,14 +10163,14 @@ var verifyMacosSigning = (args) => Effect28.gen(function* () {
|
|
|
9443
10163
|
}));
|
|
9444
10164
|
return code || (problems ? 1 : 0);
|
|
9445
10165
|
});
|
|
9446
|
-
var publishFramework = (args) => runCommand((error) => error.message,
|
|
10166
|
+
var publishFramework = (args) => runCommand((error) => error.message, Effect29.gen(function* () {
|
|
9447
10167
|
const [archive, flag, ...extra] = args;
|
|
9448
10168
|
if (!archive || extra.length || flag !== undefined && flag !== "--dry-run")
|
|
9449
10169
|
return yield* invalid("Expected one framework package archive and an optional --dry-run");
|
|
9450
10170
|
const { env } = yield* ReleaseConfig;
|
|
9451
10171
|
yield* print(yield* step(() => publishFrameworkPackage({ env, archive, dryRun: flag === "--dry-run" })));
|
|
9452
10172
|
}));
|
|
9453
|
-
var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`,
|
|
10173
|
+
var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9454
10174
|
const args = [...argv];
|
|
9455
10175
|
const printIndex = args.indexOf("--print");
|
|
9456
10176
|
const printDirectory = printIndex === -1 ? undefined : args[printIndex + 1];
|
|
@@ -9485,7 +10205,7 @@ var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch pa
|
|
|
9485
10205
|
...printDirectory ? { printDirectory } : {}
|
|
9486
10206
|
}));
|
|
9487
10207
|
}));
|
|
9488
|
-
var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; check the command arguments and use matching exact staged artifacts and native receipts.",
|
|
10208
|
+
var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; check the command arguments and use matching exact staged artifacts and native receipts.", Effect29.gen(function* () {
|
|
9489
10209
|
const [action, configPath, ...operands] = args;
|
|
9490
10210
|
if (!configPath)
|
|
9491
10211
|
return yield* invalid();
|
|
@@ -9494,7 +10214,7 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
|
|
|
9494
10214
|
const matrix = yield* step(async () => planDailyReleaseMatrix(config, operands[0]));
|
|
9495
10215
|
return yield* print(matrix);
|
|
9496
10216
|
}
|
|
9497
|
-
if (!(action === "verify" && operands.length === 3 || action === "stage-local" && operands.length === 4 || action === "produce-native-receipt" && (operands.length === 4 || operands.length === 5)))
|
|
10217
|
+
if (!(action === "verify" && operands.length === 3 || action === "stage-local" && operands.length === 4 || action === "produce-native-receipt" && (operands.length === 4 || operands.length === 5) || action === "observe-native" && (operands.length === 4 || operands.length === 5)))
|
|
9498
10218
|
return yield* invalid();
|
|
9499
10219
|
const [identityPath, artifacts, receipts, parent, baselineArtifacts] = operands;
|
|
9500
10220
|
const raw = yield* readBoundedJson(identityPath, 4096, "Daily identity");
|
|
@@ -9503,6 +10223,17 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
|
|
|
9503
10223
|
const { tag, sourceSha, workflowSha, runId, runAttempt } = raw;
|
|
9504
10224
|
const config = yield* readReleaseConfig(configPath);
|
|
9505
10225
|
const identity = { tag, sourceSha, workflowSha, runId, runAttempt };
|
|
10226
|
+
if (action === "observe-native") {
|
|
10227
|
+
const baseline = baselineArtifacts ? yield* readBoundedJson(baselineArtifacts, 4096, "Daily baseline") : undefined;
|
|
10228
|
+
return yield* print(yield* observeDailyNativeEffect({
|
|
10229
|
+
config,
|
|
10230
|
+
identity,
|
|
10231
|
+
artifacts,
|
|
10232
|
+
checkName: receipts,
|
|
10233
|
+
driver: parent,
|
|
10234
|
+
baseline
|
|
10235
|
+
}, runDailyNativeDriver));
|
|
10236
|
+
}
|
|
9506
10237
|
if (action === "produce-native-receipt") {
|
|
9507
10238
|
const { env, platform: os, arch } = yield* ReleaseConfig;
|
|
9508
10239
|
yield* step(async () => assertHostedRunner(env, "Daily native receipt"));
|
|
@@ -9525,13 +10256,13 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
|
|
|
9525
10256
|
const result = action === "verify" ? yield* verifyDailyReleaseMatrixEffect(options) : yield* stageDailyBatchEffect({ ...options, parent });
|
|
9526
10257
|
return yield* print(result);
|
|
9527
10258
|
}));
|
|
9528
|
-
var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`,
|
|
10259
|
+
var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9529
10260
|
yield* print(yield* step(() => prepareStableCatalogCommand(args)));
|
|
9530
10261
|
}));
|
|
9531
|
-
var stageAptRepository = (args) => runCommand((error) => `Unable to stage Apt repository: ${redactedErrorMessage(error)}`,
|
|
10262
|
+
var stageAptRepository = (args) => runCommand((error) => `Unable to stage Apt repository: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9532
10263
|
yield* print(yield* step(() => stageAptRepositoryCommand(args)));
|
|
9533
10264
|
}));
|
|
9534
|
-
var linuxChannelProof = (args) => runCommand((error) => `Unable to check Linux package channel: ${redactedErrorMessage(error)}`,
|
|
10265
|
+
var linuxChannelProof = (args) => runCommand((error) => `Unable to check Linux package channel: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9535
10266
|
const [channel, input, ...extra] = args;
|
|
9536
10267
|
if (channel !== "rpm" && channel !== "flatpak" || !input || extra.length)
|
|
9537
10268
|
return yield* invalid("Expected <rpm|flatpak> <input.json>");
|
|
@@ -9565,7 +10296,7 @@ var releaseCli = (argv) => {
|
|
|
9565
10296
|
const command = name === undefined ? undefined : commands[name];
|
|
9566
10297
|
if (command)
|
|
9567
10298
|
return command(args);
|
|
9568
|
-
return
|
|
10299
|
+
return Effect29.gen(function* () {
|
|
9569
10300
|
const { stderr } = yield* ReleaseOutput;
|
|
9570
10301
|
stderr(`Usage: adea-release <${Object.keys(commands).join("|")}> [arguments]; unknown command ${String(name)}
|
|
9571
10302
|
`);
|
|
@@ -9574,4 +10305,4 @@ var releaseCli = (argv) => {
|
|
|
9574
10305
|
};
|
|
9575
10306
|
|
|
9576
10307
|
// src/cli.ts
|
|
9577
|
-
process.exitCode = await
|
|
10308
|
+
process.exitCode = await Effect30.runPromise(provideLivePorts(releaseCli(process.argv.slice(2))));
|