@adea-ai/app-framework-release-tools 0.2.0 → 0.4.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 +1585 -292
- package/dist/index.js +689 -212
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18,12 +18,15 @@ var __export = (target, all) => {
|
|
|
18
18
|
// src/index.ts
|
|
19
19
|
var exports_src = {};
|
|
20
20
|
__export(exports_src, {
|
|
21
|
+
createDailyNativeReceipt: () => createDailyNativeReceipt,
|
|
21
22
|
createGitHubPromotionProvider: () => createGitHubPromotionProvider,
|
|
22
23
|
createGitHubReleasePublisher: () => createGitHubReleasePublisher,
|
|
23
24
|
createMacosDmg: () => createMacosDmg,
|
|
25
|
+
desktopDailyProfile: () => desktopDailyProfile,
|
|
24
26
|
fileIdentity: () => fileIdentity2,
|
|
25
27
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
26
28
|
inspectStagedStep: () => inspectStagedStep,
|
|
29
|
+
planDailyReleaseMatrix: () => planDailyReleaseMatrix,
|
|
27
30
|
planQualificationRun: () => planQualificationRun2,
|
|
28
31
|
planReleaseAssets: () => planReleaseAssets2,
|
|
29
32
|
publishFrameworkPackage: () => publishFrameworkPackage,
|
|
@@ -38,17 +41,42 @@ __export(exports_src, {
|
|
|
38
41
|
selectRetainedStep: () => selectRetainedStep,
|
|
39
42
|
signReleaseArtifact: () => signReleaseArtifact,
|
|
40
43
|
stageBuildStep: () => stageBuildStep,
|
|
44
|
+
stageLinuxPackagePair: () => stageLinuxPackagePair,
|
|
41
45
|
stagePlatformArtifacts: () => stagePlatformArtifacts,
|
|
42
46
|
stageReleaseDescriptors: () => stageReleaseDescriptors,
|
|
47
|
+
verifyDailyReleaseMatrix: () => verifyDailyReleaseMatrix,
|
|
43
48
|
verifyImage: () => verifyImage,
|
|
44
49
|
writeDescriptors: () => writeDescriptors
|
|
45
50
|
});
|
|
46
51
|
|
|
47
52
|
// src/cli.ts
|
|
48
|
-
import { Effect as
|
|
53
|
+
import { Effect as Effect30 } from "effect";
|
|
49
54
|
|
|
50
55
|
// src/cli-commands.ts
|
|
51
|
-
import { Effect as
|
|
56
|
+
import { Effect as Effect29 } from "effect";
|
|
57
|
+
|
|
58
|
+
// ../../src/installer/hosted-runner.ts
|
|
59
|
+
import { isAbsolute } from "path";
|
|
60
|
+
var JOB_NUMBER = /^[1-9]\d{0,19}$/;
|
|
61
|
+
function isHostedRunner(env) {
|
|
62
|
+
if (env.CI !== "true")
|
|
63
|
+
return false;
|
|
64
|
+
if (env.GITHUB_ACTIONS === "true")
|
|
65
|
+
return env.RUNNER_ENVIRONMENT === "github-hosted";
|
|
66
|
+
if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
|
|
67
|
+
return false;
|
|
68
|
+
if (env.GITLAB_CI === "true")
|
|
69
|
+
return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
|
|
70
|
+
return env.CIRCLECI === "true" && JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "");
|
|
71
|
+
}
|
|
72
|
+
function assertHostedRunner(env, subject) {
|
|
73
|
+
if (!isHostedRunner(env))
|
|
74
|
+
throw new Error(`${subject} requires a disposable hosted runner`);
|
|
75
|
+
}
|
|
76
|
+
function runnerTemp(env) {
|
|
77
|
+
const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
|
|
78
|
+
return path && isAbsolute(path) ? path : undefined;
|
|
79
|
+
}
|
|
52
80
|
|
|
53
81
|
// ../../src/cli/cli-runner.ts
|
|
54
82
|
var MAX_ERROR_LENGTH = 400;
|
|
@@ -201,29 +229,6 @@ function sidecarBundlePath(name, platform) {
|
|
|
201
229
|
return `Resources/app/${SIDECAR_DIRECTORY}/${sidecarFileName(name, platform)}`;
|
|
202
230
|
}
|
|
203
231
|
|
|
204
|
-
// ../../src/installer/hosted-runner.ts
|
|
205
|
-
import { isAbsolute } from "path";
|
|
206
|
-
var JOB_NUMBER = /^[1-9]\d{0,19}$/;
|
|
207
|
-
function isHostedRunner(env) {
|
|
208
|
-
if (env.CI !== "true")
|
|
209
|
-
return false;
|
|
210
|
-
if (env.GITHUB_ACTIONS === "true")
|
|
211
|
-
return env.RUNNER_ENVIRONMENT === "github-hosted";
|
|
212
|
-
if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
|
|
213
|
-
return false;
|
|
214
|
-
if (env.GITLAB_CI === "true")
|
|
215
|
-
return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
|
|
216
|
-
return env.CIRCLECI === "true" && JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "");
|
|
217
|
-
}
|
|
218
|
-
function assertHostedRunner(env, subject) {
|
|
219
|
-
if (!isHostedRunner(env))
|
|
220
|
-
throw new Error(`${subject} requires a disposable hosted runner`);
|
|
221
|
-
}
|
|
222
|
-
function runnerTemp(env) {
|
|
223
|
-
const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
|
|
224
|
-
return path && isAbsolute(path) ? path : undefined;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
232
|
// ../../src/installer/installer-layout.ts
|
|
228
233
|
function assertInstallerContext(env, platform, host, arch) {
|
|
229
234
|
assertHostedRunner(env, "Installer execution");
|
|
@@ -1905,6 +1910,9 @@ var RELEASE_VERSION = /^\d+\.\d+\.\d+(?:-dev\.\d+)?$/;
|
|
|
1905
1910
|
function isReleaseVersion(value) {
|
|
1906
1911
|
return typeof value === "string" && value.length <= MAX_RELEASE_VERSION_LENGTH && RELEASE_VERSION.test(value);
|
|
1907
1912
|
}
|
|
1913
|
+
function isReleaseTag(value) {
|
|
1914
|
+
return typeof value === "string" && value.startsWith("v") && isReleaseVersion(value.slice(1));
|
|
1915
|
+
}
|
|
1908
1916
|
|
|
1909
1917
|
// ../../src/release/release-promotion.ts
|
|
1910
1918
|
function order(a, b) {
|
|
@@ -3278,6 +3286,264 @@ var stageReleaseDescriptorsEffect = (options) => Effect15.gen(function* () {
|
|
|
3278
3286
|
});
|
|
3279
3287
|
var writeDescriptors = (directory, signed) => runReleaseLibrary(provideLibraryPorts()(writeDescriptorsEffect(directory, signed)));
|
|
3280
3288
|
var stageReleaseDescriptors = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(stageReleaseDescriptorsEffect(options)));
|
|
3289
|
+
// src/library/daily-matrix.ts
|
|
3290
|
+
import { join as join8 } from "path";
|
|
3291
|
+
import { Effect as Effect16 } from "effect";
|
|
3292
|
+
|
|
3293
|
+
// src/library/daily-native-evidence.ts
|
|
3294
|
+
var digest = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
|
|
3295
|
+
var record = (value, keys) => isRecord(value) && hasExactOwnKeys(value, keys);
|
|
3296
|
+
function assertDailyIdentity(identity) {
|
|
3297
|
+
if (!isReleaseTag(identity.tag) || !isGitSha(identity.sourceSha) || identity.workflowSha !== identity.sourceSha || typeof identity.runId !== "string" || !/^[1-9]\d{0,19}$/.test(identity.runId) || !Number.isSafeInteger(identity.runAttempt) || identity.runAttempt <= 0)
|
|
3298
|
+
throw new Error("Invalid exact Daily identity");
|
|
3299
|
+
}
|
|
3300
|
+
function validArtifact(value) {
|
|
3301
|
+
return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 && digest(value.digest);
|
|
3302
|
+
}
|
|
3303
|
+
function originMatches(value, payloadName) {
|
|
3304
|
+
if (record(value, ["kind", "sourceSha"]))
|
|
3305
|
+
return value.kind === "published-installer" && isGitSha(value.sourceSha);
|
|
3306
|
+
return record(value, ["kind", "sourceSha", "payload"]) && value.kind === "private-from-verified-payload" && isGitSha(value.sourceSha) && validArtifact(value.payload) && value.payload.name === payloadName;
|
|
3307
|
+
}
|
|
3308
|
+
function observationsMatch(value, { identity, check, baselineNames }) {
|
|
3309
|
+
const version = identity.tag.slice(1);
|
|
3310
|
+
if (!record(value, check.format === "command" ? ["install", "command"] : ["install", "launch", "upgrade"]) || !record(value.install, ["version"]) || value.install.version !== version)
|
|
3311
|
+
return false;
|
|
3312
|
+
if (check.format === "command") {
|
|
3313
|
+
const cmd = value.command;
|
|
3314
|
+
return record(cmd, ["version", "probesPassed", "serviceStarted", "serviceStopped"]) && cmd.version === version && cmd.probesPassed === true && cmd.serviceStarted === true && cmd.serviceStopped === (check.platform === "windows-x64" ? "process-tree" : "sigterm");
|
|
3315
|
+
}
|
|
3316
|
+
const { launch, upgrade } = value;
|
|
3317
|
+
return record(launch, ["version", "ready"]) && launch.version === version && launch.ready === true && record(upgrade, [
|
|
3318
|
+
"baselineTag",
|
|
3319
|
+
"baselineAsset",
|
|
3320
|
+
"baselineOrigin",
|
|
3321
|
+
"baselineVersion",
|
|
3322
|
+
"upgradedVersion",
|
|
3323
|
+
"ready",
|
|
3324
|
+
"fixtureBefore",
|
|
3325
|
+
"fixtureAfter"
|
|
3326
|
+
]) && isReleaseTag(upgrade.baselineTag) && versionLessThan(upgrade.baselineTag, identity.tag) && validArtifact(upgrade.baselineAsset) && upgrade.baselineAsset.name === baselineNames(upgrade.baselineTag).installer && originMatches(upgrade.baselineOrigin, baselineNames(upgrade.baselineTag).payload) && upgrade.baselineVersion === upgrade.baselineTag.slice(1) && upgrade.upgradedVersion === version && upgrade.ready === true && digest(upgrade.fixtureBefore) && upgrade.fixtureAfter === upgrade.fixtureBefore;
|
|
3327
|
+
}
|
|
3328
|
+
function validateDailyNativeEvidence(input, schema, context) {
|
|
3329
|
+
const { appId, identity, check, assets } = context;
|
|
3330
|
+
const [os, arch] = platformTargets[check.platform];
|
|
3331
|
+
if (!record(input, [
|
|
3332
|
+
"schema",
|
|
3333
|
+
"appId",
|
|
3334
|
+
"profile",
|
|
3335
|
+
"tag",
|
|
3336
|
+
"sourceSha",
|
|
3337
|
+
"workflowSha",
|
|
3338
|
+
"runId",
|
|
3339
|
+
"runAttempt",
|
|
3340
|
+
"check",
|
|
3341
|
+
"platform",
|
|
3342
|
+
"format",
|
|
3343
|
+
"host",
|
|
3344
|
+
"assets",
|
|
3345
|
+
"observations"
|
|
3346
|
+
]) || input.schema !== schema || input.appId !== appId || input.profile !== "desktop-v1" || input.tag !== identity.tag || input.sourceSha !== identity.sourceSha || input.workflowSha !== identity.workflowSha || input.runId !== identity.runId || input.runAttempt !== identity.runAttempt || input.check !== check.name || input.platform !== check.platform || input.format !== check.format || !record(input.host, ["os", "arch"]) || input.host.os !== os || input.host.arch !== arch || !Array.isArray(input.assets) || input.assets.length !== assets.length)
|
|
3347
|
+
throw new Error(`Native receipt identity or result mismatch: ${check.name}`);
|
|
3348
|
+
for (const expected of assets) {
|
|
3349
|
+
const matches = input.assets.filter((item) => validArtifact(item) && item.name === expected.name);
|
|
3350
|
+
if (matches.length !== 1 || matches[0].size !== expected.size || matches[0].digest !== expected.digest)
|
|
3351
|
+
throw new Error(`Native receipt does not qualify staged bytes: ${check.name} / ${expected.name}`);
|
|
3352
|
+
}
|
|
3353
|
+
if (!observationsMatch(input.observations, context))
|
|
3354
|
+
throw new Error(`Missing or invalid native observations: ${check.name}`);
|
|
3355
|
+
return { host: { os, arch }, observations: input.observations };
|
|
3356
|
+
}
|
|
3357
|
+
|
|
3358
|
+
// src/library/daily-matrix.ts
|
|
3359
|
+
var desktopDailyProfile = "desktop-v1";
|
|
3360
|
+
var platforms = [
|
|
3361
|
+
"macos-arm64",
|
|
3362
|
+
"windows-x64",
|
|
3363
|
+
"linux-x64"
|
|
3364
|
+
];
|
|
3365
|
+
var receiptLimit = 64 * 1024;
|
|
3366
|
+
function requireThat(ok, message) {
|
|
3367
|
+
if (!ok)
|
|
3368
|
+
throw new Error(message);
|
|
3369
|
+
}
|
|
3370
|
+
function planDailyReleaseMatrix(config, tag) {
|
|
3371
|
+
requireThat(isRecord(config) && config.dailyReleaseProfile === desktopDailyProfile && typeof config.appId === "string", "Missing supported Daily release profile");
|
|
3372
|
+
const parsed = parseReleaseConfig(config);
|
|
3373
|
+
const requirements = parsed.requirements(tag);
|
|
3374
|
+
const checks = [];
|
|
3375
|
+
for (const platform of platforms) {
|
|
3376
|
+
const pair = requirements.platforms[platform];
|
|
3377
|
+
requireThat(pair?.length === 2, `Expected installer and updater archive for ${platform}`);
|
|
3378
|
+
const [installer, archive] = pair;
|
|
3379
|
+
const suffix = platform === "macos-arm64" ? ".dmg" : platform === "windows-x64" ? "-Setup.zip" : "-Setup.tar.gz";
|
|
3380
|
+
requireThat(installer.endsWith(suffix) && archive.endsWith(".tar.zst"), `Unexpected desktop installer or updater format for ${platform}`);
|
|
3381
|
+
const format = platform === "macos-arm64" ? "dmg" : platform === "windows-x64" ? "windows-setup" : "portable-linux";
|
|
3382
|
+
checks.push({ name: `installer-${platform}`, platform, format, assets: pair });
|
|
3383
|
+
for (const command of parsed.commandArtifacts) {
|
|
3384
|
+
const name = requirements.commandArtifacts?.[command.kind]?.[platform];
|
|
3385
|
+
requireThat(name, `Missing command archive for ${platform}`);
|
|
3386
|
+
checks.push({
|
|
3387
|
+
name: `command-${command.kind}-${platform}`,
|
|
3388
|
+
platform,
|
|
3389
|
+
format: "command",
|
|
3390
|
+
assets: [name]
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
const linux = "linux-x64";
|
|
3395
|
+
const base = requirements.platforms[linux][1].slice(0, -".tar.zst".length);
|
|
3396
|
+
checks.push({ name: "deb-linux-x64", platform: linux, format: "deb", assets: [base + ".deb"] }, {
|
|
3397
|
+
name: "appimage-linux-x64",
|
|
3398
|
+
platform: linux,
|
|
3399
|
+
format: "appimage",
|
|
3400
|
+
assets: [base + ".AppImage"]
|
|
3401
|
+
});
|
|
3402
|
+
const names = checks.flatMap((check) => check.assets);
|
|
3403
|
+
discoveryPolicies(config, tag);
|
|
3404
|
+
const all = [...names, ...requirements.releaseAssets];
|
|
3405
|
+
requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
|
|
3406
|
+
return { appId: config.appId, profile: desktopDailyProfile, assets: all, checks };
|
|
3407
|
+
}
|
|
3408
|
+
function priorDailyInstallerNames(config, tag, check) {
|
|
3409
|
+
const plan = planDailyReleaseMatrix(config, tag);
|
|
3410
|
+
return {
|
|
3411
|
+
installer: plan.checks.find((entry) => entry.name === check.name)?.assets[0],
|
|
3412
|
+
payload: plan.checks.find((entry) => entry.name === `installer-${check.platform}`)?.assets[1]
|
|
3413
|
+
};
|
|
3414
|
+
}
|
|
3415
|
+
function exactDirectory(root, names) {
|
|
3416
|
+
return Effect16.gen(function* () {
|
|
3417
|
+
const fs = yield* ReleaseFs;
|
|
3418
|
+
const stat = yield* step(() => fs.lstat(root));
|
|
3419
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
3420
|
+
return yield* fail("Expected real matrix input directory");
|
|
3421
|
+
const entries = yield* step(() => fs.readdir(root, { withFileTypes: true }));
|
|
3422
|
+
const expected = new Set(names);
|
|
3423
|
+
if (entries.length !== expected.size || entries.some((e) => !e.isFile() || !expected.has(e.name)))
|
|
3424
|
+
return yield* fail("Matrix directory must contain exactly the required regular files");
|
|
3425
|
+
});
|
|
3426
|
+
}
|
|
3427
|
+
function readNativeReceipt(path, label) {
|
|
3428
|
+
return Effect16.gen(function* () {
|
|
3429
|
+
const fs = yield* ReleaseFs;
|
|
3430
|
+
const stat = yield* step(() => fs.lstat(path));
|
|
3431
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size < 1 || stat.size > receiptLimit)
|
|
3432
|
+
return yield* fail(`Invalid native receipt size or type: ${label}`);
|
|
3433
|
+
const { file, before } = yield* Effect16.acquireRelease(step(() => openUnchangedFile(path, stat, "Native receipt changed before opening")), ({ file: opened }) => Effect16.promise(() => opened.close().catch(() => {
|
|
3434
|
+
return;
|
|
3435
|
+
})));
|
|
3436
|
+
const data = yield* step(async () => {
|
|
3437
|
+
const bytes = Buffer.alloc(before.size);
|
|
3438
|
+
let offset = 0;
|
|
3439
|
+
while (offset < bytes.length) {
|
|
3440
|
+
const { bytesRead } = await file.read(bytes, offset, bytes.length - offset, offset);
|
|
3441
|
+
if (!bytesRead)
|
|
3442
|
+
throw new Error("Native receipt changed during read");
|
|
3443
|
+
offset += bytesRead;
|
|
3444
|
+
}
|
|
3445
|
+
const after = await file.stat();
|
|
3446
|
+
if (!sameFile(before, after) || before.ctimeMs !== after.ctimeMs)
|
|
3447
|
+
throw new Error("Native receipt changed during read");
|
|
3448
|
+
return bytes.toString("utf8");
|
|
3449
|
+
});
|
|
3450
|
+
return yield* attempt(() => {
|
|
3451
|
+
try {
|
|
3452
|
+
return JSON.parse(data);
|
|
3453
|
+
} catch {
|
|
3454
|
+
throw new Error(`Invalid native receipt JSON: ${label}`);
|
|
3455
|
+
}
|
|
3456
|
+
});
|
|
3457
|
+
}).pipe(Effect16.scoped);
|
|
3458
|
+
}
|
|
3459
|
+
var verifyDailyReleaseMatrixEffect = (options) => Effect16.gen(function* () {
|
|
3460
|
+
const { config, identity, artifacts, receipts } = options;
|
|
3461
|
+
const { tag } = identity;
|
|
3462
|
+
yield* attempt(() => assertDailyIdentity(identity));
|
|
3463
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, tag));
|
|
3464
|
+
yield* exactDirectory(artifacts, matrix.assets);
|
|
3465
|
+
yield* exactDirectory(receipts, matrix.checks.map((c) => c.name + ".json"));
|
|
3466
|
+
const inventory = new Map;
|
|
3467
|
+
for (const name of matrix.assets)
|
|
3468
|
+
inventory.set(name, yield* fileIdentityEffect(join8(artifacts, name), name));
|
|
3469
|
+
for (const check of matrix.checks) {
|
|
3470
|
+
const r = yield* readNativeReceipt(join8(receipts, check.name + ".json"), check.name);
|
|
3471
|
+
yield* attempt(() => validateDailyNativeEvidence(r, "framework/daily-native-receipt/v2", {
|
|
3472
|
+
appId: matrix.appId,
|
|
3473
|
+
identity,
|
|
3474
|
+
check,
|
|
3475
|
+
assets: check.assets.map((name) => inventory.get(name)),
|
|
3476
|
+
baselineNames: (priorTag) => priorDailyInstallerNames(config, priorTag, check)
|
|
3477
|
+
}));
|
|
3478
|
+
}
|
|
3479
|
+
return {
|
|
3480
|
+
profile: matrix.profile,
|
|
3481
|
+
appId: matrix.appId,
|
|
3482
|
+
identity,
|
|
3483
|
+
assets: [...inventory.values()]
|
|
3484
|
+
};
|
|
3485
|
+
});
|
|
3486
|
+
function verifyDailyReleaseMatrix(options) {
|
|
3487
|
+
return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
|
|
3488
|
+
}
|
|
3489
|
+
// src/library/daily-native-receipt.ts
|
|
3490
|
+
import { join as join9 } from "path";
|
|
3491
|
+
import { Effect as Effect17 } from "effect";
|
|
3492
|
+
var createDailyNativeReceiptEffect = (options, worker) => Effect17.gen(function* () {
|
|
3493
|
+
const { config, identity, artifacts, checkName, report } = options;
|
|
3494
|
+
yield* attempt(() => assertDailyIdentity(identity));
|
|
3495
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
3496
|
+
const check = matrix.checks.find(({ name }) => name === checkName);
|
|
3497
|
+
if (!check)
|
|
3498
|
+
return yield* fail("Unknown Daily native check");
|
|
3499
|
+
const [os, arch] = platformTargets[check.platform];
|
|
3500
|
+
if (worker.os !== os || worker.arch !== arch)
|
|
3501
|
+
return yield* fail(`Daily native check requires ${check.platform}`);
|
|
3502
|
+
const fs = yield* ReleaseFs;
|
|
3503
|
+
const dir = yield* step(() => fs.lstat(artifacts));
|
|
3504
|
+
if (!dir.isDirectory() || dir.isSymbolicLink())
|
|
3505
|
+
return yield* fail("Expected real native artifact directory");
|
|
3506
|
+
const assets = yield* Effect17.forEach(check.assets, (name) => fileIdentityEffect(join9(artifacts, name), name));
|
|
3507
|
+
const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
|
|
3508
|
+
appId: matrix.appId,
|
|
3509
|
+
identity,
|
|
3510
|
+
check,
|
|
3511
|
+
assets,
|
|
3512
|
+
baselineNames: (tag) => priorDailyInstallerNames(config, tag, check)
|
|
3513
|
+
}));
|
|
3514
|
+
if ("upgrade" in evidence.observations) {
|
|
3515
|
+
if (!options.baselineArtifacts)
|
|
3516
|
+
return yield* fail("Daily desktop check requires the exact baseline installer");
|
|
3517
|
+
const baselineDirectory = options.baselineArtifacts;
|
|
3518
|
+
const info = yield* step(() => fs.lstat(baselineDirectory));
|
|
3519
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
3520
|
+
return yield* fail("Expected real native baseline directory");
|
|
3521
|
+
const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
|
|
3522
|
+
const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
|
|
3523
|
+
for (const expected of proofFiles) {
|
|
3524
|
+
const observed = yield* fileIdentityEffect(join9(baselineDirectory, expected.name), expected.name);
|
|
3525
|
+
if (observed.size !== expected.size || observed.digest !== expected.digest)
|
|
3526
|
+
return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
return {
|
|
3530
|
+
...identity,
|
|
3531
|
+
...evidence,
|
|
3532
|
+
schema: "framework/daily-native-receipt/v2",
|
|
3533
|
+
appId: matrix.appId,
|
|
3534
|
+
profile: matrix.profile,
|
|
3535
|
+
check: check.name,
|
|
3536
|
+
platform: check.platform,
|
|
3537
|
+
format: check.format,
|
|
3538
|
+
assets
|
|
3539
|
+
};
|
|
3540
|
+
});
|
|
3541
|
+
function createDailyNativeReceipt(options) {
|
|
3542
|
+
return runReleaseLibrary(provideLibraryPorts()(createDailyNativeReceiptEffect(options, {
|
|
3543
|
+
os: process.platform,
|
|
3544
|
+
arch: process.arch
|
|
3545
|
+
})));
|
|
3546
|
+
}
|
|
3281
3547
|
// src/library/macos-dmg.ts
|
|
3282
3548
|
import { execFileSync } from "child_process";
|
|
3283
3549
|
import {
|
|
@@ -3289,8 +3555,8 @@ import {
|
|
|
3289
3555
|
rmSync,
|
|
3290
3556
|
symlinkSync
|
|
3291
3557
|
} from "fs";
|
|
3292
|
-
import { basename as basename4, dirname, join as
|
|
3293
|
-
import { Context as Context2, Effect as
|
|
3558
|
+
import { basename as basename4, dirname, join as join10, resolve as resolve6 } from "path";
|
|
3559
|
+
import { Context as Context2, Effect as Effect18 } from "effect";
|
|
3294
3560
|
|
|
3295
3561
|
// ../../src/release/macos-dmg.ts
|
|
3296
3562
|
var MIB = 1024 * 1024;
|
|
@@ -3321,7 +3587,7 @@ function treeSize(root) {
|
|
|
3321
3587
|
logicalBytes += info.size;
|
|
3322
3588
|
else if (info.isDirectory())
|
|
3323
3589
|
for (const name of readdirSync(path))
|
|
3324
|
-
pending.push(
|
|
3590
|
+
pending.push(join10(path, name));
|
|
3325
3591
|
else if (!info.isSymbolicLink())
|
|
3326
3592
|
throw new Error("Unsupported disk image entry");
|
|
3327
3593
|
if (!Number.isSafeInteger(logicalBytes))
|
|
@@ -3329,16 +3595,16 @@ function treeSize(root) {
|
|
|
3329
3595
|
}
|
|
3330
3596
|
return { logicalBytes, entries };
|
|
3331
3597
|
}
|
|
3332
|
-
var verifyImageEffect = (image) =>
|
|
3598
|
+
var verifyImageEffect = (image) => Effect18.gen(function* () {
|
|
3333
3599
|
const host = yield* MacosHost;
|
|
3334
3600
|
for (let tries = 1;; tries++) {
|
|
3335
|
-
const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(
|
|
3601
|
+
const verified = yield* attempt(() => host.run("/usr/bin/hdiutil", ["verify", image])).pipe(Effect18.as(true), Effect18.catchIf(() => tries < 6, () => Effect18.succeed(false)));
|
|
3336
3602
|
if (verified)
|
|
3337
3603
|
return;
|
|
3338
3604
|
host.wait(5000 * 2 ** (tries - 1));
|
|
3339
3605
|
}
|
|
3340
3606
|
});
|
|
3341
|
-
var createMacosDmgEffect = (options) =>
|
|
3607
|
+
var createMacosDmgEffect = (options) => Effect18.gen(function* () {
|
|
3342
3608
|
const host = yield* MacosHost;
|
|
3343
3609
|
if (host.platform !== "darwin")
|
|
3344
3610
|
return yield* fail("Disk image creation requires macOS");
|
|
@@ -3347,11 +3613,11 @@ var createMacosDmgEffect = (options) => Effect16.gen(function* () {
|
|
|
3347
3613
|
const info = yield* attempt(() => lstatSync(app));
|
|
3348
3614
|
if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
|
|
3349
3615
|
return yield* fail("Invalid disk image paths");
|
|
3350
|
-
const staging = yield*
|
|
3351
|
-
const payload =
|
|
3616
|
+
const staging = yield* Effect18.acquireRelease(attempt(() => mkdtempSync(join10(dirname(output), ".framework-dmg-"))), (path) => Effect18.sync(() => rmSync(path, { recursive: true, force: true })));
|
|
3617
|
+
const payload = join10(staging, "payload"), image = join10(staging, "result.dmg");
|
|
3352
3618
|
yield* attempt(() => mkdirSync(payload));
|
|
3353
|
-
yield* attempt(() => host.run("/usr/bin/ditto", [app,
|
|
3354
|
-
yield* attempt(() => symlinkSync("/Applications",
|
|
3619
|
+
yield* attempt(() => host.run("/usr/bin/ditto", [app, join10(payload, basename4(app))]));
|
|
3620
|
+
yield* attempt(() => symlinkSync("/Applications", join10(payload, "Applications")));
|
|
3355
3621
|
const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
|
|
3356
3622
|
yield* attempt(() => host.run("/usr/bin/hdiutil", [
|
|
3357
3623
|
"create",
|
|
@@ -3368,31 +3634,31 @@ var createMacosDmgEffect = (options) => Effect16.gen(function* () {
|
|
|
3368
3634
|
yield* verifyImageEffect(image);
|
|
3369
3635
|
yield* attempt(() => linkSync(image, output));
|
|
3370
3636
|
return { capacityMiB };
|
|
3371
|
-
}).pipe(
|
|
3637
|
+
}).pipe(Effect18.scoped);
|
|
3372
3638
|
function verifyImage(image, io = liveHost) {
|
|
3373
|
-
runReleaseLibrarySync(verifyImageEffect(image).pipe(
|
|
3639
|
+
runReleaseLibrarySync(verifyImageEffect(image).pipe(Effect18.provideService(MacosHost, {
|
|
3374
3640
|
run: (command, args) => io.run(command, args),
|
|
3375
3641
|
wait: (milliseconds) => io.wait(milliseconds),
|
|
3376
3642
|
platform: process.platform
|
|
3377
3643
|
})));
|
|
3378
3644
|
}
|
|
3379
3645
|
function createMacosDmg(options) {
|
|
3380
|
-
return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(
|
|
3646
|
+
return runReleaseLibrarySync(createMacosDmgEffect(options).pipe(Effect18.provideService(MacosHost, liveHost)));
|
|
3381
3647
|
}
|
|
3382
3648
|
// src/library/qualification-run.ts
|
|
3383
|
-
import { Effect as
|
|
3649
|
+
import { Effect as Effect21 } from "effect";
|
|
3384
3650
|
|
|
3385
3651
|
// src/library/local-release.ts
|
|
3386
3652
|
import { createHash as createHash8 } from "crypto";
|
|
3387
3653
|
import { constants as constants3 } from "fs";
|
|
3388
|
-
import { dirname as dirname2, join as
|
|
3389
|
-
import { Cause as Cause2, Effect as
|
|
3654
|
+
import { dirname as dirname2, join as join12, resolve as resolve8 } from "path";
|
|
3655
|
+
import { Cause as Cause2, Effect as Effect20, Exit as Exit3 } from "effect";
|
|
3390
3656
|
|
|
3391
3657
|
// ../../src/native/native-rename.ts
|
|
3392
3658
|
import { randomUUID } from "crypto";
|
|
3393
3659
|
import { mkdir as mkdir3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
3394
3660
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
3395
|
-
import { join as
|
|
3661
|
+
import { join as join11 } from "path";
|
|
3396
3662
|
|
|
3397
3663
|
// ../../src/native/canonical-path.ts
|
|
3398
3664
|
import { isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
|
|
@@ -3471,8 +3737,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
3471
3737
|
if (!isCanonicalPath(parent))
|
|
3472
3738
|
throw new Error("Invalid directory exchange probe parent");
|
|
3473
3739
|
const id = randomUUID();
|
|
3474
|
-
const first =
|
|
3475
|
-
const second =
|
|
3740
|
+
const first = join11(parent, `.framework-exchange-probe-${id}-a`);
|
|
3741
|
+
const second = join11(parent, `.framework-exchange-probe-${id}-b`);
|
|
3476
3742
|
const marker = "exchange-probe";
|
|
3477
3743
|
const firstValue = `${id}:first`;
|
|
3478
3744
|
const secondValue = `${id}:second`;
|
|
@@ -3483,12 +3749,12 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
3483
3749
|
firstCreated = true;
|
|
3484
3750
|
await mkdir3(second, { mode: 448 });
|
|
3485
3751
|
secondCreated = true;
|
|
3486
|
-
await writeFile3(
|
|
3487
|
-
await writeFile3(
|
|
3752
|
+
await writeFile3(join11(first, marker), firstValue, { flag: "wx", mode: 384 });
|
|
3753
|
+
await writeFile3(join11(second, marker), secondValue, { flag: "wx", mode: 384 });
|
|
3488
3754
|
exchange(first, second);
|
|
3489
3755
|
const [firstAfter, secondAfter] = await Promise.all([
|
|
3490
|
-
readFile5(
|
|
3491
|
-
readFile5(
|
|
3756
|
+
readFile5(join11(first, marker), "utf8"),
|
|
3757
|
+
readFile5(join11(second, marker), "utf8")
|
|
3492
3758
|
]);
|
|
3493
3759
|
if (firstAfter !== secondValue || secondAfter !== firstValue)
|
|
3494
3760
|
throw new Error("Directory exchange did not exchange both probe trees");
|
|
@@ -3554,7 +3820,7 @@ function createFeedReleaseCutProvider(options) {
|
|
|
3554
3820
|
|
|
3555
3821
|
// src/library/feed-state.ts
|
|
3556
3822
|
import { createHash as createHash7 } from "crypto";
|
|
3557
|
-
import { Effect as
|
|
3823
|
+
import { Effect as Effect19 } from "effect";
|
|
3558
3824
|
|
|
3559
3825
|
// ../../src/shared/discard-stream.ts
|
|
3560
3826
|
function discardStream(stream) {
|
|
@@ -3714,11 +3980,11 @@ var json = (bytes) => {
|
|
|
3714
3980
|
throw new Error("Invalid release feed response");
|
|
3715
3981
|
}
|
|
3716
3982
|
};
|
|
3717
|
-
var feedObject = (feed, path, maximum) =>
|
|
3983
|
+
var feedObject = (feed, path, maximum) => Effect19.gen(function* () {
|
|
3718
3984
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
3719
3985
|
return yield* step(() => readFeedObject(feed, path, fetch2, maximum));
|
|
3720
3986
|
});
|
|
3721
|
-
var readFeedLedgerEffect = (feed) =>
|
|
3987
|
+
var readFeedLedgerEffect = (feed) => Effect19.gen(function* () {
|
|
3722
3988
|
const bytes = yield* feedObject(feed, "index.json", MAX_LEDGER_BYTES);
|
|
3723
3989
|
const ledger = bytes ? yield* attempt(() => parseReleaseLedger(json(bytes), feed.app)) : null;
|
|
3724
3990
|
if (ledger && ledger.releases.length > 0)
|
|
@@ -3730,7 +3996,7 @@ var readFeedLedgerEffect = (feed) => Effect17.gen(function* () {
|
|
|
3730
3996
|
}
|
|
3731
3997
|
return ledger ?? { schema: 1, app: feed.app, releases: [] };
|
|
3732
3998
|
});
|
|
3733
|
-
var readFeedReleaseEffect = (feed, tag) =>
|
|
3999
|
+
var readFeedReleaseEffect = (feed, tag) => Effect19.gen(function* () {
|
|
3734
4000
|
const bytes = yield* feedObject(feed, `${tag}/release.json`, MAX_RELEASE_BYTES);
|
|
3735
4001
|
if (!bytes)
|
|
3736
4002
|
return null;
|
|
@@ -3780,10 +4046,10 @@ class ReleaseFeedSnapshotChanged extends Error {
|
|
|
3780
4046
|
var snapshotChanged = step(async () => {
|
|
3781
4047
|
throw new ReleaseFeedSnapshotChanged;
|
|
3782
4048
|
});
|
|
3783
|
-
var verifyFeedReleaseEffect = (options) =>
|
|
4049
|
+
var verifyFeedReleaseEffect = (options) => Effect19.gen(function* () {
|
|
3784
4050
|
const { config, feed, tag } = options;
|
|
3785
4051
|
const { fetch: fetcher } = yield* ReleaseFetch;
|
|
3786
|
-
const ledger = yield* readFeedLedgerEffect(feed).pipe(
|
|
4052
|
+
const ledger = yield* readFeedLedgerEffect(feed).pipe(Effect19.catchIf(() => options.expectedLedger !== undefined, () => snapshotChanged));
|
|
3787
4053
|
if (options.expectedLedger && JSON.stringify(ledger) !== JSON.stringify(options.expectedLedger))
|
|
3788
4054
|
return yield* snapshotChanged;
|
|
3789
4055
|
const release = yield* readFeedReleaseEffect(feed, tag);
|
|
@@ -3846,13 +4112,13 @@ var timestamp2 = (value) => {
|
|
|
3846
4112
|
throw new Error("Invalid release clock");
|
|
3847
4113
|
return new Date(value).toISOString();
|
|
3848
4114
|
};
|
|
3849
|
-
var exactFiles = (directory, names) =>
|
|
4115
|
+
var exactFiles = (directory, names) => Effect20.gen(function* () {
|
|
3850
4116
|
const fs = yield* ReleaseFs;
|
|
3851
4117
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
3852
4118
|
if (entries.length !== names.length || entries.some((entry) => !entry.isFile() || !names.includes(entry.name)))
|
|
3853
4119
|
return yield* fail("Staged directory does not hold exactly the platform release files");
|
|
3854
4120
|
});
|
|
3855
|
-
var promised2 =
|
|
4121
|
+
var promised2 = Effect20.gen(function* () {
|
|
3856
4122
|
const fs = yield* ReleaseFs;
|
|
3857
4123
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
3858
4124
|
const { run: git } = yield* ReleaseGit;
|
|
@@ -3862,7 +4128,7 @@ var promised2 = Effect18.gen(function* () {
|
|
|
3862
4128
|
run: (effect) => runReleaseLibrary(provideLibraryPorts({ fs, fetch: fetch2, git })(effect))
|
|
3863
4129
|
};
|
|
3864
4130
|
});
|
|
3865
|
-
var runLocalReleaseCutEffect = (options) =>
|
|
4131
|
+
var runLocalReleaseCutEffect = (options) => Effect20.gen(function* () {
|
|
3866
4132
|
const { kind, platform } = options;
|
|
3867
4133
|
const parsed = parseReleaseConfig(options.config);
|
|
3868
4134
|
const provenance = yield* resolveLocalProvenanceEffect({
|
|
@@ -3887,7 +4153,7 @@ var runLocalReleaseCutEffect = (options) => Effect18.gen(function* () {
|
|
|
3887
4153
|
}));
|
|
3888
4154
|
return { ...result, version: result.tag.slice(1), platform };
|
|
3889
4155
|
});
|
|
3890
|
-
var localTagProvenanceEffect = (options) =>
|
|
4156
|
+
var localTagProvenanceEffect = (options) => Effect20.gen(function* () {
|
|
3891
4157
|
const parsed = parseReleaseConfig(options.config);
|
|
3892
4158
|
parsed.requirements(options.tag);
|
|
3893
4159
|
const provenance = yield* resolveLocalProvenanceEffect({
|
|
@@ -3898,7 +4164,7 @@ var localTagProvenanceEffect = (options) => Effect18.gen(function* () {
|
|
|
3898
4164
|
return yield* fail("Release tag does not belong to the source version");
|
|
3899
4165
|
return { repository: provenance.repository };
|
|
3900
4166
|
});
|
|
3901
|
-
var stageLocalDescriptorsEffect = (options) =>
|
|
4167
|
+
var stageLocalDescriptorsEffect = (options) => Effect20.gen(function* () {
|
|
3902
4168
|
const { tag, platform } = options;
|
|
3903
4169
|
const local = localConfig(options.config);
|
|
3904
4170
|
if (!/^[1-9]\d{0,19}$/.test(options.runId) || !isGitSha(options.sourceSha))
|
|
@@ -3907,7 +4173,7 @@ var stageLocalDescriptorsEffect = (options) => Effect18.gen(function* () {
|
|
|
3907
4173
|
const payloads = platformPayloads(local.requirements(tag), platform);
|
|
3908
4174
|
const directory = resolve8(options.directory);
|
|
3909
4175
|
yield* exactFiles(directory, payloads);
|
|
3910
|
-
const assets = yield*
|
|
4176
|
+
const assets = yield* Effect20.forEach(payloads, (name) => fileIdentityEffect(join12(directory, name), name), { concurrency: "unbounded" });
|
|
3911
4177
|
const signed = signDiscoveryDescriptors({
|
|
3912
4178
|
policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
|
|
3913
4179
|
assets,
|
|
@@ -3925,7 +4191,7 @@ var stageLocalDescriptorsEffect = (options) => Effect18.gen(function* () {
|
|
|
3925
4191
|
privateKey: options.privateKey
|
|
3926
4192
|
});
|
|
3927
4193
|
for (const asset of assets)
|
|
3928
|
-
if (JSON.stringify(yield* fileIdentityEffect(
|
|
4194
|
+
if (JSON.stringify(yield* fileIdentityEffect(join12(directory, asset.name), asset.name)) !== JSON.stringify(asset))
|
|
3929
4195
|
return yield* fail("Staged payload changed before signing");
|
|
3930
4196
|
yield* writeDescriptorsEffect(directory, signed);
|
|
3931
4197
|
return signed.map((value) => value.name);
|
|
@@ -3949,18 +4215,18 @@ var describe = (key, bytes, cacheControl) => ({
|
|
|
3949
4215
|
contentType: "application/json",
|
|
3950
4216
|
cacheControl
|
|
3951
4217
|
});
|
|
3952
|
-
var writeStagedTree = (out, feed, assets, documents) =>
|
|
4218
|
+
var writeStagedTree = (out, feed, assets, documents) => Effect20.gen(function* () {
|
|
3953
4219
|
const fs = yield* ReleaseFs;
|
|
3954
4220
|
const root = resolve8(out);
|
|
3955
|
-
const exists = yield* step(() => fs.lstat(root)).pipe(
|
|
4221
|
+
const exists = yield* step(() => fs.lstat(root)).pipe(Effect20.as(true), Effect20.catchIf((failure) => errorCode(failure.original) === "ENOENT", () => Effect20.succeed(false)));
|
|
3956
4222
|
if (exists)
|
|
3957
4223
|
return yield* fail("Release output directory already exists");
|
|
3958
4224
|
yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
|
|
3959
|
-
const staging = yield* step(() => fs.mkdtemp(
|
|
3960
|
-
const exit = yield*
|
|
4225
|
+
const staging = yield* step(() => fs.mkdtemp(join12(dirname2(root), ".release-staging-")));
|
|
4226
|
+
const exit = yield* Effect20.exit(Effect20.gen(function* () {
|
|
3961
4227
|
const objects = [];
|
|
3962
4228
|
for (const { key, path, artifact } of assets) {
|
|
3963
|
-
const target =
|
|
4229
|
+
const target = join12(staging, key);
|
|
3964
4230
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
3965
4231
|
yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
|
|
3966
4232
|
if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
|
|
@@ -3974,13 +4240,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect18.gen(function* (
|
|
|
3974
4240
|
});
|
|
3975
4241
|
}
|
|
3976
4242
|
for (const { key, bytes } of documents) {
|
|
3977
|
-
const target =
|
|
4243
|
+
const target = join12(staging, key);
|
|
3978
4244
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
3979
4245
|
yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
|
|
3980
4246
|
objects.push(describe(key, bytes, MUTABLE));
|
|
3981
4247
|
}
|
|
3982
4248
|
const plan = { schema: 1, base: feed.base, objects };
|
|
3983
|
-
yield* step(() => fs.writeFile(
|
|
4249
|
+
yield* step(() => fs.writeFile(join12(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
|
|
3984
4250
|
yield* attempt(() => renameExclusive(staging, root));
|
|
3985
4251
|
return plan;
|
|
3986
4252
|
}));
|
|
@@ -3988,10 +4254,10 @@ var writeStagedTree = (out, feed, assets, documents) => Effect18.gen(function* (
|
|
|
3988
4254
|
return exit.value;
|
|
3989
4255
|
const error = Cause2.squash(exit.cause);
|
|
3990
4256
|
const original = error instanceof ReleaseFailure ? error.original ?? error : error;
|
|
3991
|
-
const cleanup = yield*
|
|
4257
|
+
const cleanup = yield* Effect20.exit(step(() => fs.rm(staging, { recursive: true, force: true })));
|
|
3992
4258
|
if (Exit3.isFailure(cleanup)) {
|
|
3993
4259
|
const cleanupError = Cause2.squash(cleanup.cause);
|
|
3994
|
-
return yield*
|
|
4260
|
+
return yield* Effect20.fail(new ReleaseFailure({
|
|
3995
4261
|
reason: "cleanup",
|
|
3996
4262
|
message: "Release staging failed and its private temporary tree could not be removed",
|
|
3997
4263
|
original: new AggregateError([
|
|
@@ -4000,8 +4266,8 @@ var writeStagedTree = (out, feed, assets, documents) => Effect18.gen(function* (
|
|
|
4000
4266
|
], "Release staging failed and its private temporary tree could not be removed", { cause: original })
|
|
4001
4267
|
}));
|
|
4002
4268
|
}
|
|
4003
|
-
return yield*
|
|
4004
|
-
}).pipe(
|
|
4269
|
+
return yield* Effect20.failCause(exit.cause);
|
|
4270
|
+
}).pipe(Effect20.uninterruptible);
|
|
4005
4271
|
function releaseDocuments(feed, ledger, release) {
|
|
4006
4272
|
return [
|
|
4007
4273
|
{ key: feedReleaseKey(feed, release.tag), bytes: jsonBytes(release) },
|
|
@@ -4018,7 +4284,7 @@ function releaseDocuments(feed, ledger, release) {
|
|
|
4018
4284
|
}))
|
|
4019
4285
|
];
|
|
4020
4286
|
}
|
|
4021
|
-
var stageLocalReleaseEffect = (options) =>
|
|
4287
|
+
var stageLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
4022
4288
|
const fs = yield* ReleaseFs;
|
|
4023
4289
|
const { tag, sourceSha, platform } = options;
|
|
4024
4290
|
const local = localConfig(options.config);
|
|
@@ -4028,12 +4294,12 @@ var stageLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
4028
4294
|
const directory = resolve8(options.directory);
|
|
4029
4295
|
const names = [...payloads, ...policies.map((policy) => policy.name)];
|
|
4030
4296
|
yield* exactFiles(directory, names);
|
|
4031
|
-
const staged = yield*
|
|
4297
|
+
const staged = yield* Effect20.forEach(names, (name) => fileIdentityEffect(join12(directory, name), name), { concurrency: "unbounded" });
|
|
4032
4298
|
for (const policy of policies) {
|
|
4033
4299
|
const artifact = staged.find((asset) => asset.name === policy.name);
|
|
4034
4300
|
if (artifact.size > 65536)
|
|
4035
4301
|
return yield* fail("Signed descriptor is too large");
|
|
4036
|
-
const bytes = yield* step(() => fs.readFile(
|
|
4302
|
+
const bytes = yield* step(() => fs.readFile(join12(directory, policy.name)));
|
|
4037
4303
|
if ("sha256:" + createHash8("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
4038
4304
|
return yield* fail("Signed descriptor changed");
|
|
4039
4305
|
let parsed;
|
|
@@ -4055,7 +4321,7 @@ var stageLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
4055
4321
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.sourceSha !== sourceSha || verified.descriptor.workflowSha !== sourceSha || verified.descriptor.asset.name !== payload.name || verified.descriptor.asset.size !== payload.size || "sha256:" + verified.descriptor.asset.sha256 !== payload.digest)
|
|
4056
4322
|
return yield* fail(`Untrusted signed descriptor: ${policy.name}`);
|
|
4057
4323
|
}
|
|
4058
|
-
const [ledger, remote] = yield*
|
|
4324
|
+
const [ledger, remote] = yield* Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
|
|
4059
4325
|
const entry = ledger.releases.find((item) => item.tag === tag);
|
|
4060
4326
|
if (Boolean(entry) !== Boolean(remote) || entry && remote && (entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt)))
|
|
4061
4327
|
return yield* fail("Inconsistent feed release; reconcile publication before retrying");
|
|
@@ -4073,7 +4339,7 @@ var stageLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
4073
4339
|
merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
|
|
4074
4340
|
uploads.push({
|
|
4075
4341
|
key: feedAssetKey(feed, tag, artifact.name),
|
|
4076
|
-
path:
|
|
4342
|
+
path: join12(directory, artifact.name),
|
|
4077
4343
|
artifact
|
|
4078
4344
|
});
|
|
4079
4345
|
}
|
|
@@ -4106,7 +4372,7 @@ function stablePlatforms(config) {
|
|
|
4106
4372
|
throw new Error("Invalid stablePlatforms in the release configuration");
|
|
4107
4373
|
return value;
|
|
4108
4374
|
}
|
|
4109
|
-
var verifyLocalReleaseEffect = (options) =>
|
|
4375
|
+
var verifyLocalReleaseEffect = (options) => Effect20.gen(function* () {
|
|
4110
4376
|
const local = localConfig(options.config);
|
|
4111
4377
|
const { release, platforms } = yield* verifyFeedReleaseEffect({
|
|
4112
4378
|
config: local.config,
|
|
@@ -4122,7 +4388,7 @@ var verifyLocalReleaseEffect = (options) => Effect18.gen(function* () {
|
|
|
4122
4388
|
missing: Object.keys(platformTargets).filter((platform) => !platforms.includes(platform))
|
|
4123
4389
|
};
|
|
4124
4390
|
});
|
|
4125
|
-
var runLocalPromotionEffect = (options) =>
|
|
4391
|
+
var runLocalPromotionEffect = (options) => Effect20.gen(function* () {
|
|
4126
4392
|
const local = localConfig(options.config);
|
|
4127
4393
|
const feed = local.feed;
|
|
4128
4394
|
const required = stablePlatforms(local.config);
|
|
@@ -4180,7 +4446,7 @@ var runLocalPromotionEffect = (options) => Effect18.gen(function* () {
|
|
|
4180
4446
|
const verification = qualified.get(selected.tag);
|
|
4181
4447
|
const absent = Object.keys(platformTargets).filter((name) => !verification?.platforms.includes(name));
|
|
4182
4448
|
const entry = ledger.releases.find((item) => item.tag === selected.tag);
|
|
4183
|
-
const [currentLedger, remote] = await run(
|
|
4449
|
+
const [currentLedger, remote] = await run(Effect20.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, selected.tag)], {
|
|
4184
4450
|
concurrency: "unbounded"
|
|
4185
4451
|
}));
|
|
4186
4452
|
if (!entry || !remote || !verification || entry.kind === "dev" || JSON.stringify(currentLedger) !== JSON.stringify(ledger) || JSON.stringify(remote) !== JSON.stringify(verification.release))
|
|
@@ -4219,7 +4485,7 @@ var runLocalPromotionEffect = (options) => Effect18.gen(function* () {
|
|
|
4219
4485
|
|
|
4220
4486
|
// src/library/qualification-run.ts
|
|
4221
4487
|
var REFUSAL = "Qualification requires a GitHub release-assets run, a GitLab tag pipeline or a CircleCI tag workflow";
|
|
4222
|
-
var tagRun = (options) =>
|
|
4488
|
+
var tagRun = (options) => Effect21.gen(function* () {
|
|
4223
4489
|
const { tag, sha, runId } = options;
|
|
4224
4490
|
if (options.tagName !== tag || !isGitSha(sha) || !/^[1-9]\d{0,19}$/.test(runId ?? "") || !/^v\d+\.\d+\.\d+$/.test(tag) || tag.length > 65)
|
|
4225
4491
|
return yield* fail(REFUSAL);
|
|
@@ -4233,7 +4499,7 @@ var tagRun = (options) => Effect19.gen(function* () {
|
|
|
4233
4499
|
runAttempt: 1
|
|
4234
4500
|
};
|
|
4235
4501
|
});
|
|
4236
|
-
var planQualificationRunEffect = (options) =>
|
|
4502
|
+
var planQualificationRunEffect = (options) => Effect21.gen(function* () {
|
|
4237
4503
|
const { env, config, tag } = options;
|
|
4238
4504
|
if (env.GITHUB_ACTIONS === "true") {
|
|
4239
4505
|
const plan = yield* planReleaseAssetsEffect({ env, config, tag });
|
|
@@ -4266,8 +4532,8 @@ var planQualificationRun2 = (options) => runReleaseLibrary(provideLibraryPorts({
|
|
|
4266
4532
|
...options.git ? { git: options.git } : {}
|
|
4267
4533
|
})(planQualificationRunEffect(options)));
|
|
4268
4534
|
// src/library/retained-build.ts
|
|
4269
|
-
import { Effect as
|
|
4270
|
-
var id = (value) =>
|
|
4535
|
+
import { Effect as Effect22 } from "effect";
|
|
4536
|
+
var id = (value) => Effect22.gen(function* () {
|
|
4271
4537
|
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
4272
4538
|
return yield* fail("Invalid GitHub identity");
|
|
4273
4539
|
const text = String(value);
|
|
@@ -4275,7 +4541,7 @@ var id = (value) => Effect20.gen(function* () {
|
|
|
4275
4541
|
return yield* fail("Invalid GitHub identity");
|
|
4276
4542
|
return text;
|
|
4277
4543
|
});
|
|
4278
|
-
var selectRetainedReleaseBuildEffect = (options) =>
|
|
4544
|
+
var selectRetainedReleaseBuildEffect = (options) => Effect22.gen(function* () {
|
|
4279
4545
|
const { env, config, tag, platform } = options;
|
|
4280
4546
|
if (!["macos-arm64", "windows-x64", "linux-x64"].includes(platform) || !isRecord(config) || typeof config.appName !== "string" || env.RELEASE_TAG !== tag)
|
|
4281
4547
|
return yield* fail("Invalid retained build context");
|
|
@@ -4394,9 +4660,9 @@ var selectRetainedReleaseBuildEffect = (options) => Effect20.gen(function* () {
|
|
|
4394
4660
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
4395
4661
|
// src/library/staging.ts
|
|
4396
4662
|
import { createHash as createHash9 } from "crypto";
|
|
4397
|
-
import { join as
|
|
4398
|
-
import { Effect as
|
|
4399
|
-
var copyHashed = (input, output, size) =>
|
|
4663
|
+
import { join as join13, resolve as resolve9 } from "path";
|
|
4664
|
+
import { Effect as Effect23 } from "effect";
|
|
4665
|
+
var copyHashed = (input, output, size) => Effect23.tryPromise({
|
|
4400
4666
|
try: async (signal) => {
|
|
4401
4667
|
const hash = createHash9("sha256");
|
|
4402
4668
|
let copied = 0;
|
|
@@ -4425,15 +4691,14 @@ var copyHashed = (input, output, size) => Effect21.tryPromise({
|
|
|
4425
4691
|
original: error
|
|
4426
4692
|
})
|
|
4427
4693
|
});
|
|
4428
|
-
var
|
|
4694
|
+
var stageExpectedFilesEffect = (options) => Effect23.gen(function* () {
|
|
4429
4695
|
const fs = yield* ReleaseFs;
|
|
4430
|
-
const
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
return yield* fail("Platform staging sources do not match release configuration");
|
|
4696
|
+
const { expected } = options;
|
|
4697
|
+
if (!expected.length || new Set(expected).size !== expected.length || expected.some((name) => !/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/.test(name)) || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
|
|
4698
|
+
return yield* fail("Staging sources do not match expected filenames");
|
|
4434
4699
|
const directory = resolve9(options.directory);
|
|
4435
4700
|
const created = [];
|
|
4436
|
-
const stage =
|
|
4701
|
+
const stage = Effect23.forEach(expected, (name) => Effect23.gen(function* () {
|
|
4437
4702
|
const sourcePath = options.sources[name];
|
|
4438
4703
|
if (typeof sourcePath !== "string" || !sourcePath)
|
|
4439
4704
|
return yield* fail("Invalid staging source");
|
|
@@ -4444,7 +4709,7 @@ var stagePlatformArtifactsEffect = (options) => Effect21.gen(function* () {
|
|
|
4444
4709
|
const before = yield* step(() => input.stat());
|
|
4445
4710
|
if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
|
|
4446
4711
|
return yield* fail("Staging source changed");
|
|
4447
|
-
const target =
|
|
4712
|
+
const target = join13(directory, name);
|
|
4448
4713
|
const output = yield* scopedHandle(() => fs.open(target, "wx"));
|
|
4449
4714
|
created.push(target);
|
|
4450
4715
|
const copied = yield* copyHashed(input, output, before.size);
|
|
@@ -4453,13 +4718,20 @@ var stagePlatformArtifactsEffect = (options) => Effect21.gen(function* () {
|
|
|
4453
4718
|
if (copied.size !== before.size || after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.dev !== before.dev || after.ino !== before.ino)
|
|
4454
4719
|
return yield* fail("Staging source changed");
|
|
4455
4720
|
return { name, size: copied.size, digest: copied.digest };
|
|
4456
|
-
}).pipe(
|
|
4457
|
-
return yield* stage.pipe(
|
|
4721
|
+
}).pipe(Effect23.scoped), { concurrency: 1 });
|
|
4722
|
+
return yield* stage.pipe(Effect23.onError(() => Effect23.promise(() => Promise.all(created.map((path) => fs.rm(path, { force: true }).catch(() => {}))))));
|
|
4723
|
+
});
|
|
4724
|
+
var stagePlatformArtifactsEffect = (options) => Effect23.gen(function* () {
|
|
4725
|
+
const requirements = parseReleaseConfig(options.config).requirements(options.tag);
|
|
4726
|
+
const expected = platformPayloads(requirements, options.platform);
|
|
4727
|
+
if (!expected.length || Object.keys(options.sources).length !== expected.length || expected.some((name) => !Object.hasOwn(options.sources, name)))
|
|
4728
|
+
return yield* fail("Platform staging sources do not match release configuration");
|
|
4729
|
+
return yield* stageExpectedFilesEffect({ ...options, expected });
|
|
4458
4730
|
});
|
|
4459
4731
|
var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
|
|
4460
4732
|
// src/library/steps.ts
|
|
4461
|
-
import { join as
|
|
4462
|
-
import { Effect as
|
|
4733
|
+
import { join as join33 } from "path";
|
|
4734
|
+
import { Effect as Effect24 } from "effect";
|
|
4463
4735
|
|
|
4464
4736
|
// ../../src/installer/installer-archive-members.ts
|
|
4465
4737
|
import { createHash as createHash10 } from "crypto";
|
|
@@ -4588,11 +4860,11 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
4588
4860
|
// ../../src/installer/installer-identity.ts
|
|
4589
4861
|
import { lstat as lstat8, mkdtemp as mkdtemp4, readdir as readdir6, realpath } from "fs/promises";
|
|
4590
4862
|
import { tmpdir as tmpdir4 } from "os";
|
|
4591
|
-
import { basename as basename5, join as
|
|
4863
|
+
import { basename as basename5, join as join15, resolve as resolve10, win32 } from "path";
|
|
4592
4864
|
|
|
4593
4865
|
// ../../src/installer/installer-image-mount.ts
|
|
4594
4866
|
import { lstat as lstat7, mkdir as mkdir4, mkdtemp as mkdtemp3, readdir as readdir5, rm as rm4, stat } from "fs/promises";
|
|
4595
|
-
import { dirname as dirname3, join as
|
|
4867
|
+
import { dirname as dirname3, join as join14 } from "path";
|
|
4596
4868
|
var FAILED_ATTACH_PROBES = 5;
|
|
4597
4869
|
var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
|
|
4598
4870
|
async function containsMountAt(path, expectedDevice) {
|
|
@@ -4602,7 +4874,7 @@ async function containsMountAt(path, expectedDevice) {
|
|
|
4602
4874
|
if (info.dev !== expectedDevice)
|
|
4603
4875
|
return true;
|
|
4604
4876
|
for (const name of await readdir5(path)) {
|
|
4605
|
-
const child =
|
|
4877
|
+
const child = join14(path, name), childInfo = await lstat7(child);
|
|
4606
4878
|
if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
|
|
4607
4879
|
continue;
|
|
4608
4880
|
if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
|
|
@@ -4796,8 +5068,8 @@ async function withInstallerImageRetries(options) {
|
|
|
4796
5068
|
};
|
|
4797
5069
|
const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
|
|
4798
5070
|
for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
|
|
4799
|
-
const directory = await mkdtemp3(
|
|
4800
|
-
const mount =
|
|
5071
|
+
const directory = await mkdtemp3(join14(options.parent, options.prefix));
|
|
5072
|
+
const mount = join14(directory, "mount");
|
|
4801
5073
|
const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
|
|
4802
5074
|
let lifecycleStarted = false;
|
|
4803
5075
|
try {
|
|
@@ -4997,7 +5269,7 @@ async function verifyInstallerPayload(options) {
|
|
|
4997
5269
|
if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
|
|
4998
5270
|
throw new Error("Installer archive exceeds bound");
|
|
4999
5271
|
const env = environment(parent);
|
|
5000
|
-
const temporary = await mkdtemp4(
|
|
5272
|
+
const temporary = await mkdtemp4(join15(tmpdir4(), "framework-installer-inspect-"));
|
|
5001
5273
|
const cleanupIo = defaultInstallerImageMountIo(command);
|
|
5002
5274
|
try {
|
|
5003
5275
|
if (options.platform === "macos-arm64") {
|
|
@@ -5011,21 +5283,21 @@ async function verifyInstallerPayload(options) {
|
|
|
5011
5283
|
const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
|
|
5012
5284
|
if (apps.length !== 1)
|
|
5013
5285
|
throw new Error("Installer application is missing or ambiguous");
|
|
5014
|
-
const resources =
|
|
5015
|
-
const actualRoot = await realpath(mount), actualApp = await realpath(
|
|
5286
|
+
const resources = join15(mount, apps[0], "Contents", "Resources");
|
|
5287
|
+
const actualRoot = await realpath(mount), actualApp = await realpath(join15(mount, apps[0])), actualResources = await realpath(resources);
|
|
5016
5288
|
if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
|
|
5017
5289
|
throw new Error("Installer resources escape mounted image");
|
|
5018
|
-
const plist =
|
|
5290
|
+
const plist = join15(actualApp, "Contents", "Info.plist"), plistInfo = await lstat8(plist);
|
|
5019
5291
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
5020
5292
|
throw new Error("Invalid installer property list");
|
|
5021
5293
|
const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
|
|
5022
5294
|
if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
|
|
5023
5295
|
throw new Error("Invalid installer executable name");
|
|
5024
|
-
await assertInstallerExecutable(
|
|
5296
|
+
await assertInstallerExecutable(join15(actualApp, "Contents", "MacOS", executable), options.platform);
|
|
5025
5297
|
const archives = (await readdir6(actualResources)).filter((name) => name.endsWith(".tar.zst"));
|
|
5026
5298
|
if (archives.length !== 1)
|
|
5027
5299
|
throw new Error("Installer archive is missing or ambiguous");
|
|
5028
|
-
const embedded = await identity(
|
|
5300
|
+
const embedded = await identity(join15(actualResources, archives[0]));
|
|
5029
5301
|
if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
|
|
5030
5302
|
throw new Error("Installer archive differs from release archive");
|
|
5031
5303
|
}
|
|
@@ -5043,7 +5315,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5043
5315
|
const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
|
|
5044
5316
|
if (matches.length !== 1)
|
|
5045
5317
|
throw new Error("Installer archive is missing or ambiguous");
|
|
5046
|
-
const extracted =
|
|
5318
|
+
const extracted = join15(temporary, "member");
|
|
5047
5319
|
const count = await extractArchiveMember({
|
|
5048
5320
|
tar,
|
|
5049
5321
|
archive: installerPath,
|
|
@@ -5054,7 +5326,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5054
5326
|
});
|
|
5055
5327
|
if (options.platform === "windows-x64") {
|
|
5056
5328
|
const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
|
|
5057
|
-
const executable =
|
|
5329
|
+
const executable = join15(temporary, "setup.exe");
|
|
5058
5330
|
await extractArchiveMember({
|
|
5059
5331
|
tar,
|
|
5060
5332
|
archive: installerPath,
|
|
@@ -5091,18 +5363,18 @@ async function verifyInstallerPayload(options) {
|
|
|
5091
5363
|
|
|
5092
5364
|
// ../../src/installer/installer-qualification-command.ts
|
|
5093
5365
|
import { lstat as lstat18, writeFile as writeFile9 } from "fs/promises";
|
|
5094
|
-
import { join as
|
|
5366
|
+
import { join as join30, resolve as resolve13 } from "path";
|
|
5095
5367
|
|
|
5096
5368
|
// ../../src/installer/installer-observation.ts
|
|
5097
5369
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
5098
5370
|
import { chmod as chmod2, mkdir as mkdir9, readFile as readFile9, realpath as realpath8, writeFile as writeFile8 } from "fs/promises";
|
|
5099
5371
|
import { createServer } from "net";
|
|
5100
|
-
import { delimiter, dirname as dirname12, join as
|
|
5372
|
+
import { delimiter, dirname as dirname12, join as join29 } from "path";
|
|
5101
5373
|
|
|
5102
5374
|
// ../../src/installer/installer-ci-bootstrap.ts
|
|
5103
5375
|
import { randomBytes } from "crypto";
|
|
5104
5376
|
import { lstat as lstat9, mkdir as mkdir5, mkdtemp as mkdtemp5, realpath as realpath2, rm as rm5, writeFile as writeFile4 } from "fs/promises";
|
|
5105
|
-
import { dirname as dirname4, isAbsolute as isAbsolute4, join as
|
|
5377
|
+
import { dirname as dirname4, isAbsolute as isAbsolute4, join as join16, relative as relative5, sep as sep3 } from "path";
|
|
5106
5378
|
import { fileURLToPath } from "url";
|
|
5107
5379
|
var bootstrapModules = [
|
|
5108
5380
|
"app/value-guards.js",
|
|
@@ -5129,23 +5401,23 @@ async function prepareInstallerCiBootstrap(env = process.env) {
|
|
|
5129
5401
|
if (/\s/.test(parent) || !(await lstat9(parent)).isDirectory())
|
|
5130
5402
|
throw new Error("Runner temp cannot represent a Bun preload path");
|
|
5131
5403
|
const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
|
|
5132
|
-
const directory = await mkdtemp5(
|
|
5404
|
+
const directory = await mkdtemp5(join16(parent, "framework-ci-"));
|
|
5133
5405
|
try {
|
|
5134
5406
|
for (const name of bootstrapModules) {
|
|
5135
|
-
const contents = await readBoundedFile(
|
|
5136
|
-
await mkdir5(dirname4(
|
|
5137
|
-
await writeFile4(
|
|
5407
|
+
const contents = await readBoundedFile(join16(source, name), 2 * 1024 * 1024, "installer bootstrap module");
|
|
5408
|
+
await mkdir5(dirname4(join16(directory, name)), { recursive: true, mode: 448 });
|
|
5409
|
+
await writeFile4(join16(directory, name), contents, { flag: "wx", mode: 384 });
|
|
5138
5410
|
}
|
|
5139
|
-
await writeFile4(
|
|
5411
|
+
await writeFile4(join16(directory, "package.json"), `{"type":"module"}
|
|
5140
5412
|
`, {
|
|
5141
5413
|
flag: "wx",
|
|
5142
5414
|
mode: 384
|
|
5143
5415
|
});
|
|
5144
|
-
const worker =
|
|
5416
|
+
const worker = join16(directory, "installer/installer-ci-worker.js");
|
|
5145
5417
|
return {
|
|
5146
5418
|
directory,
|
|
5147
5419
|
worker,
|
|
5148
|
-
preflight:
|
|
5420
|
+
preflight: join16(directory, "installer/installer-ci-preflight.js"),
|
|
5149
5421
|
bunOptions: `--preload=${worker}`
|
|
5150
5422
|
};
|
|
5151
5423
|
} catch (error) {
|
|
@@ -5160,7 +5432,7 @@ async function preflightInstallerRuntime(options) {
|
|
|
5160
5432
|
throw new Error("Runtime preflight requires a disposable hosted runner");
|
|
5161
5433
|
const tempRoot = await realpath2(temp), bootstrapRoot = await realpath2(bootstrap.directory);
|
|
5162
5434
|
const relativeBootstrap = relative5(tempRoot, bootstrapRoot);
|
|
5163
|
-
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !==
|
|
5435
|
+
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute4(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join16(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join16(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
|
|
5164
5436
|
throw new Error("Invalid installer bootstrap location");
|
|
5165
5437
|
await runInstallerPreflight({
|
|
5166
5438
|
env,
|
|
@@ -5180,7 +5452,7 @@ async function runInstallerPreflight(options) {
|
|
|
5180
5452
|
const info = await lstat9(runtime);
|
|
5181
5453
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
|
|
5182
5454
|
throw new Error("Invalid candidate Bun runtime");
|
|
5183
|
-
const temporary = await mkdtemp5(
|
|
5455
|
+
const temporary = await mkdtemp5(join16(options.parent, "framework-preflight-"));
|
|
5184
5456
|
try {
|
|
5185
5457
|
const clean = {};
|
|
5186
5458
|
for (const key of [
|
|
@@ -5205,11 +5477,11 @@ async function runInstallerPreflight(options) {
|
|
|
5205
5477
|
BUN_OPTIONS: `--preload=${worker}`,
|
|
5206
5478
|
FRAMEWORK_CI_WORKER_ENTRY: preflight,
|
|
5207
5479
|
FRAMEWORK_CI_NONCE: nonce,
|
|
5208
|
-
FRAMEWORK_CI_ACK:
|
|
5209
|
-
FRAMEWORK_CI_PERMIT:
|
|
5480
|
+
FRAMEWORK_CI_ACK: join16(temporary, "ack"),
|
|
5481
|
+
FRAMEWORK_CI_PERMIT: join16(temporary, "permit"),
|
|
5210
5482
|
FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
|
|
5211
|
-
FRAMEWORK_CI_OBSERVATION:
|
|
5212
|
-
FRAMEWORK_CI_UNEXPECTED:
|
|
5483
|
+
FRAMEWORK_CI_OBSERVATION: join16(temporary, "observation"),
|
|
5484
|
+
FRAMEWORK_CI_UNEXPECTED: join16(temporary, "unexpected"),
|
|
5213
5485
|
FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
|
|
5214
5486
|
"https://example.invalid/framework-ci-sentinel"
|
|
5215
5487
|
])
|
|
@@ -5244,7 +5516,7 @@ async function runInstallerPreflight(options) {
|
|
|
5244
5516
|
if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
|
|
5245
5517
|
throw new Error("Candidate Bun runtime failed installer preflight");
|
|
5246
5518
|
try {
|
|
5247
|
-
await lstat9(
|
|
5519
|
+
await lstat9(join16(temporary, "unexpected"));
|
|
5248
5520
|
throw new Error("Runtime preflight recorded unexpected activity");
|
|
5249
5521
|
} catch (error) {
|
|
5250
5522
|
if (errorCode(error) !== "ENOENT")
|
|
@@ -5257,7 +5529,7 @@ async function runInstallerPreflight(options) {
|
|
|
5257
5529
|
|
|
5258
5530
|
// ../../src/installer/installer-extraction.ts
|
|
5259
5531
|
import { chmod, lstat as lstat10, mkdir as mkdir6, mkdtemp as mkdtemp6, readdir as readdir7, realpath as realpath3 } from "fs/promises";
|
|
5260
|
-
import { join as
|
|
5532
|
+
import { join as join17, resolve as resolve11, win32 as win322 } from "path";
|
|
5261
5533
|
async function run(cmd, env) {
|
|
5262
5534
|
return runInstallerCommand(cmd, env, {
|
|
5263
5535
|
outputLimit: 8 * 1024 * 1024,
|
|
@@ -5265,7 +5537,7 @@ async function run(cmd, env) {
|
|
|
5265
5537
|
failureMessage: "Installer preparation command failed"
|
|
5266
5538
|
});
|
|
5267
5539
|
}
|
|
5268
|
-
async function
|
|
5540
|
+
async function digest2(path) {
|
|
5269
5541
|
const info = await lstat10(path);
|
|
5270
5542
|
if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
|
|
5271
5543
|
throw new Error("Invalid extracted file");
|
|
@@ -5309,10 +5581,10 @@ async function prepareInstallerExecution(options) {
|
|
|
5309
5581
|
archive: sourceArchive,
|
|
5310
5582
|
env
|
|
5311
5583
|
});
|
|
5312
|
-
const directory = await mkdtemp6(
|
|
5584
|
+
const directory = await mkdtemp6(join17(parent, "framework-installer-"));
|
|
5313
5585
|
const imageIo = defaultInstallerImageMountIo(run);
|
|
5314
5586
|
try {
|
|
5315
|
-
const profile =
|
|
5587
|
+
const profile = join17(directory, "profile"), incoming = join17(directory, "incoming");
|
|
5316
5588
|
await mkdir6(profile, { mode: 448 });
|
|
5317
5589
|
await mkdir6(incoming, { mode: 448 });
|
|
5318
5590
|
const clean = cleanEnv(env);
|
|
@@ -5328,31 +5600,31 @@ async function prepareInstallerExecution(options) {
|
|
|
5328
5600
|
const appName = `${options.appName}.app`, apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
|
|
5329
5601
|
if (apps.length !== 1 || apps[0] !== appName)
|
|
5330
5602
|
throw new Error("Unexpected installer application");
|
|
5331
|
-
const sourceApp = await realpath3(
|
|
5603
|
+
const sourceApp = await realpath3(join17(mount, appName)), mountRoot = await realpath3(mount);
|
|
5332
5604
|
if (!isWithin(mountRoot, sourceApp))
|
|
5333
5605
|
throw new Error("Installer application escapes image");
|
|
5334
|
-
const app =
|
|
5606
|
+
const app = join17(incoming, appName);
|
|
5335
5607
|
await run(["/usr/bin/ditto", sourceApp, app], clean);
|
|
5336
|
-
const actualApp = await realpath3(app), resources = await realpath3(
|
|
5608
|
+
const actualApp = await realpath3(app), resources = await realpath3(join17(actualApp, "Contents", "Resources"));
|
|
5337
5609
|
if (!isWithin(await realpath3(incoming), actualApp) || !isWithin(actualApp, resources))
|
|
5338
5610
|
throw new Error("Copied installer escapes profile");
|
|
5339
|
-
const plist =
|
|
5611
|
+
const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat10(plist);
|
|
5340
5612
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
5341
5613
|
throw new Error("Invalid installer property list");
|
|
5342
5614
|
const name = (await run(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
|
|
5343
5615
|
if (!name || name === "." || name === ".." || /[\\/]/.test(name))
|
|
5344
5616
|
throw new Error("Invalid installer executable");
|
|
5345
|
-
const appExecutable =
|
|
5346
|
-
const sourceExecutable =
|
|
5617
|
+
const appExecutable = join17(actualApp, "Contents", "MacOS", name);
|
|
5618
|
+
const sourceExecutable = join17(sourceApp, "Contents", "MacOS", name);
|
|
5347
5619
|
if (!isWithin(actualApp, await realpath3(appExecutable)) || !isWithin(sourceApp, await realpath3(sourceExecutable)))
|
|
5348
5620
|
throw new Error("Installer executable escapes application");
|
|
5349
5621
|
await assertInstallerExecutable(appExecutable, options.platform);
|
|
5350
|
-
if (JSON.stringify(await
|
|
5622
|
+
if (JSON.stringify(await digest2(sourceExecutable)) !== JSON.stringify(await digest2(appExecutable)))
|
|
5351
5623
|
throw new Error("Copied installer executable differs");
|
|
5352
5624
|
const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
|
|
5353
5625
|
if (archives.length !== 1)
|
|
5354
5626
|
throw new Error("Missing installer archive");
|
|
5355
|
-
const embedded = await
|
|
5627
|
+
const embedded = await digest2(join17(resources, archives[0]));
|
|
5356
5628
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
5357
5629
|
throw new Error("Copied installer archive differs");
|
|
5358
5630
|
return executable;
|
|
@@ -5367,9 +5639,9 @@ async function prepareInstallerExecution(options) {
|
|
|
5367
5639
|
assertInstallerLayout(options.platform, options.appName, names);
|
|
5368
5640
|
const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
|
|
5369
5641
|
if (options.platform === "windows-x64") {
|
|
5370
|
-
const subdirectory =
|
|
5642
|
+
const subdirectory = join17(incoming, ".installer");
|
|
5371
5643
|
await mkdir6(subdirectory);
|
|
5372
|
-
executable =
|
|
5644
|
+
executable = join17(incoming, `${options.appName}-Setup.exe`);
|
|
5373
5645
|
await extractArchiveMember({
|
|
5374
5646
|
tar,
|
|
5375
5647
|
archive: sourceInstaller,
|
|
@@ -5383,11 +5655,11 @@ async function prepareInstallerExecution(options) {
|
|
|
5383
5655
|
tar,
|
|
5384
5656
|
archive: sourceInstaller,
|
|
5385
5657
|
member: find(`.installer/${options.appName}-Setup.metadata.json`),
|
|
5386
|
-
destination:
|
|
5658
|
+
destination: join17(subdirectory, `${options.appName}-Setup.metadata.json`),
|
|
5387
5659
|
maximum: 1024 * 1024,
|
|
5388
5660
|
env: clean
|
|
5389
5661
|
});
|
|
5390
|
-
const embeddedPath =
|
|
5662
|
+
const embeddedPath = join17(subdirectory, `${options.appName}-Setup.tar.zst`);
|
|
5391
5663
|
await extractArchiveMember({
|
|
5392
5664
|
tar,
|
|
5393
5665
|
archive: sourceInstaller,
|
|
@@ -5396,11 +5668,11 @@ async function prepareInstallerExecution(options) {
|
|
|
5396
5668
|
maximum: verified.archive.size,
|
|
5397
5669
|
env: clean
|
|
5398
5670
|
});
|
|
5399
|
-
const embedded = await
|
|
5671
|
+
const embedded = await digest2(embeddedPath);
|
|
5400
5672
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
5401
5673
|
throw new Error("Copied installer archive differs");
|
|
5402
5674
|
} else {
|
|
5403
|
-
executable =
|
|
5675
|
+
executable = join17(incoming, "installer");
|
|
5404
5676
|
await extractArchiveMember({
|
|
5405
5677
|
tar,
|
|
5406
5678
|
archive: sourceInstaller,
|
|
@@ -5459,7 +5731,7 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
5459
5731
|
import { createHash as createHash11 } from "crypto";
|
|
5460
5732
|
import { lstat as lstat11, open as open6, realpath as realpath4, rm as rm6 } from "fs/promises";
|
|
5461
5733
|
import { once } from "events";
|
|
5462
|
-
import { join as
|
|
5734
|
+
import { join as join18, resolve as resolve12 } from "path";
|
|
5463
5735
|
import { createZstdDecompress } from "zlib";
|
|
5464
5736
|
import { Parser } from "tar";
|
|
5465
5737
|
function cleanEnv2(parent, forceLocal) {
|
|
@@ -5630,7 +5902,7 @@ async function verifyInstalledPayload(options) {
|
|
|
5630
5902
|
const member = members.get(path);
|
|
5631
5903
|
if (!member || member.count !== 1)
|
|
5632
5904
|
throw new Error("Archive member missing or ambiguous");
|
|
5633
|
-
const current = await installed(
|
|
5905
|
+
const current = await installed(join18(root, name), root, limit);
|
|
5634
5906
|
if (member.size !== current.size || member.digest !== current.digest)
|
|
5635
5907
|
throw new Error(`Installed file differs from archive: ${name}`);
|
|
5636
5908
|
if (name === "Resources/version.json") {
|
|
@@ -5665,7 +5937,7 @@ async function extractCandidateRuntime(options) {
|
|
|
5665
5937
|
const prefix = options.platform === "macos-arm64" ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
|
|
5666
5938
|
const expected = `${prefix}/bun${suffix}`;
|
|
5667
5939
|
const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
|
|
5668
|
-
const destination =
|
|
5940
|
+
const destination = join18(profile, `candidate-bun${suffix}`), output = await open6(destination, "wx", 448);
|
|
5669
5941
|
const spawn = () => Bun.spawn({
|
|
5670
5942
|
cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
|
|
5671
5943
|
env: tarEnv,
|
|
@@ -5872,7 +6144,7 @@ async function windowsRunningExecutable(pid) {
|
|
|
5872
6144
|
|
|
5873
6145
|
// ../../src/updates/install/update-swap-stage.ts
|
|
5874
6146
|
import { lstat as lstat17, mkdtemp as mkdtemp8, readFile as readFile8, realpath as realpath7, rm as rm8 } from "fs/promises";
|
|
5875
|
-
import { join as
|
|
6147
|
+
import { join as join28 } from "path";
|
|
5876
6148
|
|
|
5877
6149
|
// ../../src/updates/install/update-handoff-plan.ts
|
|
5878
6150
|
import { basename as basename6 } from "path";
|
|
@@ -5914,7 +6186,7 @@ function planUpdateHandoff(options) {
|
|
|
5914
6186
|
import { createHash as createHash12 } from "crypto";
|
|
5915
6187
|
import { constants as constants4 } from "fs";
|
|
5916
6188
|
import { lstat as lstat12, mkdir as mkdir7, mkdtemp as mkdtemp7, open as open7, readFile as readFile6, realpath as realpath6, rm as rm7, symlink } from "fs/promises";
|
|
5917
|
-
import { isAbsolute as isAbsolute5, join as
|
|
6189
|
+
import { isAbsolute as isAbsolute5, join as join19 } from "path";
|
|
5918
6190
|
import { Transform } from "stream";
|
|
5919
6191
|
import { pipeline } from "stream/promises";
|
|
5920
6192
|
import { createZstdDecompress as createZstdDecompress2 } from "zlib";
|
|
@@ -5960,8 +6232,8 @@ async function extractVerifiedUpdate(options) {
|
|
|
5960
6232
|
const parent = await realpath6(options.directory);
|
|
5961
6233
|
if (!(await lstat12(parent)).isDirectory())
|
|
5962
6234
|
throw new Error("Invalid update staging directory");
|
|
5963
|
-
directory = await mkdtemp7(
|
|
5964
|
-
const payloadRoot =
|
|
6235
|
+
directory = await mkdtemp7(join19(parent, "framework-update-extract-"));
|
|
6236
|
+
const payloadRoot = join19(directory, "payload"), decompressed = join19(directory, "payload.tar");
|
|
5965
6237
|
await mkdir7(payloadRoot, { mode: 448 });
|
|
5966
6238
|
const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
|
|
5967
6239
|
let invalid = false;
|
|
@@ -6079,14 +6351,14 @@ async function extractVerifiedUpdate(options) {
|
|
|
6079
6351
|
if (invalid)
|
|
6080
6352
|
throw new Error("Unsafe or unsupported update archive entry");
|
|
6081
6353
|
if (links.length) {
|
|
6082
|
-
const bin =
|
|
6083
|
-
for (const path of [
|
|
6354
|
+
const bin = join19(payloadRoot, archiveRoot, "bin"), cef = join19(bin, "cef");
|
|
6355
|
+
for (const path of [join19(payloadRoot, archiveRoot), bin, cef]) {
|
|
6084
6356
|
const value = await lstat12(path);
|
|
6085
6357
|
if (!value.isDirectory() || value.isSymbolicLink())
|
|
6086
6358
|
throw new Error("Invalid CEF link directory");
|
|
6087
6359
|
}
|
|
6088
6360
|
for (const link of links) {
|
|
6089
|
-
const destination =
|
|
6361
|
+
const destination = join19(payloadRoot, link.path), target = join19(bin, link.target), value = await lstat12(target);
|
|
6090
6362
|
if (!value.isFile() || value.isSymbolicLink())
|
|
6091
6363
|
throw new Error("Invalid CEF link target");
|
|
6092
6364
|
await symlink(link.target, destination);
|
|
@@ -6094,12 +6366,12 @@ async function extractVerifiedUpdate(options) {
|
|
|
6094
6366
|
}
|
|
6095
6367
|
await rm7(decompressed);
|
|
6096
6368
|
assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
|
|
6097
|
-
const prefix = platform === "macos-arm64" ?
|
|
6098
|
-
const resources =
|
|
6369
|
+
const prefix = platform === "macos-arm64" ? join19(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
|
|
6370
|
+
const resources = join19(payloadRoot, prefix, "Resources");
|
|
6099
6371
|
const bin = platform === "macos-arm64" ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
|
|
6100
6372
|
const executables = [
|
|
6101
|
-
|
|
6102
|
-
|
|
6373
|
+
join19(bin, `launcher${suffix}`),
|
|
6374
|
+
join19(bin, `bun${suffix}`),
|
|
6103
6375
|
...sidecars.map((name) => sidecarBundlePath(name, platform))
|
|
6104
6376
|
];
|
|
6105
6377
|
const critical = [
|
|
@@ -6109,21 +6381,21 @@ async function extractVerifiedUpdate(options) {
|
|
|
6109
6381
|
"Resources/app/client/index.html"
|
|
6110
6382
|
];
|
|
6111
6383
|
for (const path of critical) {
|
|
6112
|
-
const item = await lstat12(
|
|
6384
|
+
const item = await lstat12(join19(payloadRoot, prefix, path));
|
|
6113
6385
|
if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
|
|
6114
6386
|
throw new Error("Invalid critical update file");
|
|
6115
6387
|
}
|
|
6116
6388
|
for (const name of ["version.json", "build.json"]) {
|
|
6117
|
-
const metadata = await lstat12(
|
|
6389
|
+
const metadata = await lstat12(join19(resources, name));
|
|
6118
6390
|
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
|
|
6119
6391
|
throw new Error("Invalid update metadata");
|
|
6120
6392
|
}
|
|
6121
|
-
if (JSON.parse(await readFile6(
|
|
6393
|
+
if (JSON.parse(await readFile6(join19(resources, "version.json"), "utf8")).version !== descriptor.version)
|
|
6122
6394
|
throw new Error("Update version mismatch");
|
|
6123
|
-
assertBuildMetadata(JSON.parse(await readFile6(
|
|
6395
|
+
assertBuildMetadata(JSON.parse(await readFile6(join19(resources, "build.json"), "utf8")), renderer);
|
|
6124
6396
|
return {
|
|
6125
6397
|
directory,
|
|
6126
|
-
payload:
|
|
6398
|
+
payload: join19(payloadRoot, platform === "macos-arm64" ? `${appName}.app` : prefix)
|
|
6127
6399
|
};
|
|
6128
6400
|
} catch (error) {
|
|
6129
6401
|
if (directory)
|
|
@@ -6138,16 +6410,16 @@ async function extractVerifiedUpdate(options) {
|
|
|
6138
6410
|
import { createHash as createHash13 } from "crypto";
|
|
6139
6411
|
import { constants as constants7 } from "fs";
|
|
6140
6412
|
import { lstat as lstat13, open as open10, readdir as readdir8, readFile as readFile7, readlink as readlink2 } from "fs/promises";
|
|
6141
|
-
import { basename as basename8, dirname as dirname6, join as
|
|
6413
|
+
import { basename as basename8, dirname as dirname6, join as join22 } from "path";
|
|
6142
6414
|
|
|
6143
6415
|
// ../../src/updates/update-state-store.ts
|
|
6144
6416
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
6145
6417
|
import { constants as constants6 } from "fs";
|
|
6146
6418
|
import { open as open9, rename, unlink, writeFile as writeFile5 } from "fs/promises";
|
|
6147
|
-
import { join as
|
|
6419
|
+
import { join as join21 } from "path";
|
|
6148
6420
|
|
|
6149
6421
|
// ../../src/updates/locks/update-lock.ts
|
|
6150
|
-
import { basename as basename7, dirname as dirname5, join as
|
|
6422
|
+
import { basename as basename7, dirname as dirname5, join as join20 } from "path";
|
|
6151
6423
|
|
|
6152
6424
|
// ../../src/updates/locks/native-file-lock.ts
|
|
6153
6425
|
import { constants as constants5 } from "fs";
|
|
@@ -6315,7 +6587,7 @@ async function tryAcquireWindows(path, mode) {
|
|
|
6315
6587
|
function updateLockPath(target) {
|
|
6316
6588
|
if (!isCanonicalPath(target))
|
|
6317
6589
|
throw new Error("Invalid update lock target");
|
|
6318
|
-
return
|
|
6590
|
+
return join20(dirname5(target), `.${basename7(target)}.framework-update.lock`);
|
|
6319
6591
|
}
|
|
6320
6592
|
async function tryAcquireUpdateLock(target) {
|
|
6321
6593
|
return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
|
|
@@ -6380,7 +6652,7 @@ function parseState(value) {
|
|
|
6380
6652
|
return Object.freeze(record);
|
|
6381
6653
|
}
|
|
6382
6654
|
async function readUpdateStageState(staging) {
|
|
6383
|
-
const text = await readSmallStateFile(
|
|
6655
|
+
const text = await readSmallStateFile(join21(staging, "state.json"), 4096, "Invalid update staging state");
|
|
6384
6656
|
return text === undefined ? undefined : parseState(JSON.parse(text));
|
|
6385
6657
|
}
|
|
6386
6658
|
async function writeUpdateStageState(staging, state) {
|
|
@@ -6389,8 +6661,8 @@ async function writeUpdateStageState(staging, state) {
|
|
|
6389
6661
|
async function replaceUpdateStageState(staging, state, durable) {
|
|
6390
6662
|
if (typeof state.generation !== "string" || !isUuid(state.generation))
|
|
6391
6663
|
throw new Error("Invalid update staging state");
|
|
6392
|
-
const path =
|
|
6393
|
-
const temporary =
|
|
6664
|
+
const path = join21(staging, "state.json");
|
|
6665
|
+
const temporary = join21(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
|
|
6394
6666
|
const contents = JSON.stringify(state) + `
|
|
6395
6667
|
`;
|
|
6396
6668
|
let renamed = false;
|
|
@@ -6428,10 +6700,10 @@ async function withUpdateLock(target, operation) {
|
|
|
6428
6700
|
function updateStagingFor(target) {
|
|
6429
6701
|
if (!isCanonicalPath(target))
|
|
6430
6702
|
throw new Error("Invalid update target");
|
|
6431
|
-
return
|
|
6703
|
+
return join22(dirname6(target), `.${basename8(target)}.framework-update`);
|
|
6432
6704
|
}
|
|
6433
6705
|
async function readUpdateTreeVersion(tree) {
|
|
6434
|
-
const versionPath =
|
|
6706
|
+
const versionPath = join22(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
6435
6707
|
try {
|
|
6436
6708
|
const value = JSON.parse(await readFile7(versionPath, "utf8"));
|
|
6437
6709
|
if (typeof value !== "object" || value === null || typeof value.version !== "string")
|
|
@@ -6525,7 +6797,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
6525
6797
|
if (before.isDirectory()) {
|
|
6526
6798
|
const names = (await limit(() => readdir8(path))).map((name) => ({ name, bytes: Buffer.from(name, "utf8") })).toSorted((left, right) => Buffer.compare(left.bytes, right.bytes)).map(({ name }) => name);
|
|
6527
6799
|
const children = await Promise.all(names.map(async (name) => {
|
|
6528
|
-
const childPath =
|
|
6800
|
+
const childPath = join22(path, name);
|
|
6529
6801
|
return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat13(childPath, { bigint: true })));
|
|
6530
6802
|
}));
|
|
6531
6803
|
return [{ kind: "directory", path, relative, before }, ...children.flat()];
|
|
@@ -6668,8 +6940,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
6668
6940
|
const { target, staging } = options;
|
|
6669
6941
|
if (dirname6(staging) !== dirname6(target) || staging === target)
|
|
6670
6942
|
throw new Error("Invalid update swap context");
|
|
6671
|
-
const candidate =
|
|
6672
|
-
const legacyOld =
|
|
6943
|
+
const candidate = join22(staging, "candidate");
|
|
6944
|
+
const legacyOld = join22(staging, "old");
|
|
6673
6945
|
if (await pathExists(legacyOld))
|
|
6674
6946
|
throw new Error("A legacy update tree requires recovery before another swap");
|
|
6675
6947
|
await assertDirectory(target);
|
|
@@ -6699,10 +6971,10 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
6699
6971
|
|
|
6700
6972
|
// ../../src/updates/retention/retirement-inventory.ts
|
|
6701
6973
|
import { lstat as lstat15, readdir as readdir10 } from "fs/promises";
|
|
6702
|
-
import { basename as basename12, dirname as dirname10, join as
|
|
6974
|
+
import { basename as basename12, dirname as dirname10, join as join26 } from "path";
|
|
6703
6975
|
|
|
6704
6976
|
// ../../src/updates/retention/update-retention-marker.ts
|
|
6705
|
-
import { basename as basename9, dirname as dirname7, join as
|
|
6977
|
+
import { basename as basename9, dirname as dirname7, join as join23 } from "path";
|
|
6706
6978
|
var LOWERCASE_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6707
6979
|
var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
|
|
6708
6980
|
function assertCanonicalTarget(target) {
|
|
@@ -6721,28 +6993,28 @@ function isTreeIdentity(value) {
|
|
|
6721
6993
|
function updateRetentionIntentPath(target, generation) {
|
|
6722
6994
|
assertCanonicalTarget(target);
|
|
6723
6995
|
assertGeneration(generation);
|
|
6724
|
-
return
|
|
6996
|
+
return join23(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
|
|
6725
6997
|
}
|
|
6726
6998
|
|
|
6727
6999
|
// ../../src/updates/retention/retention-prune-progress.ts
|
|
6728
|
-
import { basename as basename11, dirname as dirname9, join as
|
|
7000
|
+
import { basename as basename11, dirname as dirname9, join as join25 } from "path";
|
|
6729
7001
|
|
|
6730
7002
|
// ../../src/updates/retention/retirement-records.ts
|
|
6731
7003
|
import { lstat as lstat14, readdir as readdir9, writeFile as writeFile6 } from "fs/promises";
|
|
6732
|
-
import { basename as basename10, dirname as dirname8, join as
|
|
7004
|
+
import { basename as basename10, dirname as dirname8, join as join24 } from "path";
|
|
6733
7005
|
function updateRetirementPaths(target, generation) {
|
|
6734
7006
|
if (!isCanonicalPath(target) || !isUuid(generation))
|
|
6735
7007
|
throw new Error("Invalid update retirement identity");
|
|
6736
7008
|
const prefix = `.${basename10(target)}.framework-retired-${generation}`;
|
|
6737
|
-
const container =
|
|
7009
|
+
const container = join24(dirname8(target), prefix);
|
|
6738
7010
|
return Object.freeze({
|
|
6739
7011
|
container,
|
|
6740
|
-
tree:
|
|
6741
|
-
healthReceipt:
|
|
7012
|
+
tree: join24(container, "tree"),
|
|
7013
|
+
healthReceipt: join24(container, "healthy.json"),
|
|
6742
7014
|
healthTemporaryPrefix: ".healthy-",
|
|
6743
|
-
claim:
|
|
7015
|
+
claim: join24(dirname8(target), `${prefix}.claim.json`),
|
|
6744
7016
|
claimTemporaryPrefix: `${prefix}.claim-`,
|
|
6745
|
-
cleanupMarker:
|
|
7017
|
+
cleanupMarker: join24(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
|
|
6746
7018
|
cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
|
|
6747
7019
|
});
|
|
6748
7020
|
}
|
|
@@ -6846,10 +7118,10 @@ async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
|
|
|
6846
7118
|
|
|
6847
7119
|
// ../../src/updates/retention/update-retirement.ts
|
|
6848
7120
|
import { lstat as lstat16, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile7 } from "fs/promises";
|
|
6849
|
-
import { basename as basename13, dirname as dirname11, join as
|
|
7121
|
+
import { basename as basename13, dirname as dirname11, join as join27 } from "path";
|
|
6850
7122
|
async function reconcileRetirementCleanupMarkerWhileLocked(options) {
|
|
6851
7123
|
const { target, staging, currentVersion } = options;
|
|
6852
|
-
const markerPath =
|
|
7124
|
+
const markerPath = join27(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
|
|
6853
7125
|
const markerInfo = await pathInfo(markerPath);
|
|
6854
7126
|
if (!markerInfo)
|
|
6855
7127
|
return "none";
|
|
@@ -6890,7 +7162,7 @@ async function assertInstalledVersion(options) {
|
|
|
6890
7162
|
const info = await lstat17(options.target);
|
|
6891
7163
|
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(options.target) !== options.target)
|
|
6892
7164
|
throw new Error("Invalid update install target");
|
|
6893
|
-
const versionFile =
|
|
7165
|
+
const versionFile = join28(options.target, ...options.platform === "macos-arm64" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
6894
7166
|
const versionInfo = await lstat17(versionFile);
|
|
6895
7167
|
if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
|
|
6896
7168
|
throw new Error("Installed update version mismatch");
|
|
@@ -6914,7 +7186,7 @@ async function stageUpdateSwap(options) {
|
|
|
6914
7186
|
});
|
|
6915
7187
|
const staging = updateStagingFor(plan.target);
|
|
6916
7188
|
const preparing = await mkdtemp8(`${staging}.preparing-`);
|
|
6917
|
-
const candidate =
|
|
7189
|
+
const candidate = join28(staging, "candidate");
|
|
6918
7190
|
let published = false;
|
|
6919
7191
|
try {
|
|
6920
7192
|
const extracted = await extractVerifiedUpdate({
|
|
@@ -6928,12 +7200,12 @@ async function stageUpdateSwap(options) {
|
|
|
6928
7200
|
maxExpandedBytes: options.maxExpandedBytes,
|
|
6929
7201
|
...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
|
|
6930
7202
|
});
|
|
6931
|
-
renameExclusive(extracted.payload,
|
|
7203
|
+
renameExclusive(extracted.payload, join28(preparing, "candidate"));
|
|
6932
7204
|
await rm8(extracted.directory, { recursive: true, force: true });
|
|
6933
|
-
const candidateTreeIdentity = await readUpdateTreeIdentity(
|
|
7205
|
+
const candidateTreeIdentity = await readUpdateTreeIdentity(join28(preparing, "candidate"));
|
|
6934
7206
|
if (!candidateTreeIdentity)
|
|
6935
7207
|
throw new Error("Update candidate tree identity could not be read");
|
|
6936
|
-
const candidateTreeDigest = await readUpdateTreeDigest(
|
|
7208
|
+
const candidateTreeDigest = await readUpdateTreeDigest(join28(preparing, "candidate"));
|
|
6937
7209
|
await writeUpdateStageState(preparing, newUpdateStageState({
|
|
6938
7210
|
version: plan.version,
|
|
6939
7211
|
previousVersion: options.currentVersion,
|
|
@@ -7018,11 +7290,11 @@ function isolatedEnv(parent, profile, platform) {
|
|
|
7018
7290
|
RUNNER_ENVIRONMENT: "github-hosted",
|
|
7019
7291
|
HOME: profile,
|
|
7020
7292
|
USERPROFILE: profile,
|
|
7021
|
-
LOCALAPPDATA:
|
|
7022
|
-
XDG_DATA_HOME:
|
|
7023
|
-
TMP:
|
|
7024
|
-
TEMP:
|
|
7025
|
-
TMPDIR:
|
|
7293
|
+
LOCALAPPDATA: join29(profile, "LocalAppData"),
|
|
7294
|
+
XDG_DATA_HOME: join29(profile, ".local", "share"),
|
|
7295
|
+
TMP: join29(profile, "tmp"),
|
|
7296
|
+
TEMP: join29(profile, "tmp"),
|
|
7297
|
+
TMPDIR: join29(profile, "tmp"),
|
|
7026
7298
|
ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
|
|
7027
7299
|
});
|
|
7028
7300
|
if (platform === "windows-x64")
|
|
@@ -7117,15 +7389,15 @@ async function observeInstalledApp(options) {
|
|
|
7117
7389
|
await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
|
|
7118
7390
|
stage("runtime-preflight-passed");
|
|
7119
7391
|
for (const path of [
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7392
|
+
join29(prepared.profile, "LocalAppData"),
|
|
7393
|
+
join29(prepared.profile, ".local", "share"),
|
|
7394
|
+
join29(prepared.profile, "tmp")
|
|
7123
7395
|
])
|
|
7124
7396
|
await mkdir9(path, { recursive: true, mode: 448 });
|
|
7125
7397
|
const mac = options.platform === "macos-arm64", windows = options.platform === "windows-x64";
|
|
7126
|
-
const installedRoot = mac ?
|
|
7127
|
-
const resources =
|
|
7128
|
-
const worker =
|
|
7398
|
+
const installedRoot = mac ? join29(prepared.incoming, `${options.appName}.app`, "Contents") : join29(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
|
|
7399
|
+
const resources = join29(installedRoot, "Resources"), binary = join29(installedRoot, mac ? "MacOS" : "bin"), launcher = join29(binary, windows ? "launcher.exe" : "launcher"), runtime = join29(binary, windows ? "bun.exe" : "bun");
|
|
7400
|
+
const worker = join29(resources, "app", "bun", "index.js");
|
|
7129
7401
|
const sidecars = options.sidecars ?? [];
|
|
7130
7402
|
let foreignHits = 0;
|
|
7131
7403
|
const sentinel = policy ? Bun.serve({
|
|
@@ -7176,7 +7448,7 @@ async function observeInstalledApp(options) {
|
|
|
7176
7448
|
throw new Error("Foreign network sentinel unavailable");
|
|
7177
7449
|
foreignHits = 0;
|
|
7178
7450
|
const nonce = randomBytes2(24).toString("hex");
|
|
7179
|
-
const ack =
|
|
7451
|
+
const ack = join29(run.directory, "ack"), permit = join29(run.directory, "permit"), observation = join29(run.directory, "observation"), unexpected = join29(run.directory, "unexpected"), pidRecord = join29(run.directory, "worker-pid");
|
|
7180
7452
|
const env = {
|
|
7181
7453
|
...baseEnv,
|
|
7182
7454
|
FRAMEWORK_CI_NONCE: nonce,
|
|
@@ -7189,13 +7461,13 @@ async function observeInstalledApp(options) {
|
|
|
7189
7461
|
};
|
|
7190
7462
|
let launchRecord, expectedApp;
|
|
7191
7463
|
if (mac && viaInstaller) {
|
|
7192
|
-
const shimDir =
|
|
7464
|
+
const shimDir = join29(run.directory, "launch-shim");
|
|
7193
7465
|
await mkdir9(shimDir, { mode: 448 });
|
|
7194
|
-
const path =
|
|
7466
|
+
const path = join29(shimDir, "open");
|
|
7195
7467
|
await writeFile8(path, shim, { flag: "wx", mode: 448 });
|
|
7196
7468
|
await chmod2(path, 448);
|
|
7197
|
-
expectedApp =
|
|
7198
|
-
launchRecord =
|
|
7469
|
+
expectedApp = join29(await realpath8(prepared.incoming), `${options.appName}.app`);
|
|
7470
|
+
launchRecord = join29(run.directory, "launch-record");
|
|
7199
7471
|
Object.assign(env, {
|
|
7200
7472
|
PATH: shimDir + delimiter + (env.PATH ?? ""),
|
|
7201
7473
|
FRAMEWORK_CI_EXPECTED_APP: expectedApp,
|
|
@@ -7231,7 +7503,7 @@ async function observeInstalledApp(options) {
|
|
|
7231
7503
|
const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
|
|
7232
7504
|
throw new Error(`Installer exited unsuccessfully (exit=${installer.exitCode}, signal=${installer.signalCode ?? "none"}, ` + `ready=${await pathExists(worker) && await pathExists(launcher)}, acknowledged=${await pathExists(ack)}, ` + `error=${error ?? "none"})`);
|
|
7233
7505
|
}
|
|
7234
|
-
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(
|
|
7506
|
+
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join29(resources, "version.json"));
|
|
7235
7507
|
if (installer && shouldLaunchInstalledApp({
|
|
7236
7508
|
platform: options.platform,
|
|
7237
7509
|
ready,
|
|
@@ -7407,7 +7679,7 @@ async function observeInstalledApp(options) {
|
|
|
7407
7679
|
await swapAfterExit(target, staged.staging);
|
|
7408
7680
|
stage("update-swapped");
|
|
7409
7681
|
await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
|
|
7410
|
-
const directory =
|
|
7682
|
+
const directory = join29(prepared.directory, "update");
|
|
7411
7683
|
await mkdir9(directory, { mode: 448 });
|
|
7412
7684
|
const updated = await observeRun({
|
|
7413
7685
|
directory,
|
|
@@ -7456,7 +7728,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
7456
7728
|
const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
|
|
7457
7729
|
if (!policy || !names || names.length !== 2)
|
|
7458
7730
|
throw new Error("Installer qualification requires an explicit offline policy and payloads");
|
|
7459
|
-
const directory = resolve13(options.directory), destination =
|
|
7731
|
+
const directory = resolve13(options.directory), destination = join30(directory, `installer-test-${platform}.json`);
|
|
7460
7732
|
try {
|
|
7461
7733
|
await lstat18(destination);
|
|
7462
7734
|
throw new Error("Installer receipt already exists");
|
|
@@ -7472,8 +7744,8 @@ async function qualifyInstallerCommand(options) {
|
|
|
7472
7744
|
appName: app.appName,
|
|
7473
7745
|
appId: app.appId,
|
|
7474
7746
|
version: plan.version,
|
|
7475
|
-
installer:
|
|
7476
|
-
archive:
|
|
7747
|
+
installer: join30(directory, names[0]),
|
|
7748
|
+
archive: join30(directory, names[1]),
|
|
7477
7749
|
expectedReads: parsed.expectedReads,
|
|
7478
7750
|
offlinePolicy: policy,
|
|
7479
7751
|
sidecars: parsed.sidecars
|
|
@@ -7505,7 +7777,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
7505
7777
|
|
|
7506
7778
|
// ../../src/installer/installer-upgrade-command.ts
|
|
7507
7779
|
import { lstat as lstat19, mkdir as mkdir10, rename as rename2, writeFile as writeFile10 } from "fs/promises";
|
|
7508
|
-
import { join as
|
|
7780
|
+
import { join as join32, resolve as resolve15 } from "path";
|
|
7509
7781
|
|
|
7510
7782
|
// ../../src/installer/upgrade-asset-download.ts
|
|
7511
7783
|
import { createHash as createHash14 } from "crypto";
|
|
@@ -7641,7 +7913,7 @@ async function discoverSignedRelease(options) {
|
|
|
7641
7913
|
|
|
7642
7914
|
// ../../src/updates/install/update-download.ts
|
|
7643
7915
|
import { mkdtemp as mkdtemp9, open as open12, realpath as realpath9, rm as rm9 } from "fs/promises";
|
|
7644
|
-
import { basename as basename14, dirname as dirname13, join as
|
|
7916
|
+
import { basename as basename14, dirname as dirname13, join as join31, resolve as resolve14 } from "path";
|
|
7645
7917
|
async function downloadVerifiedRelease(options) {
|
|
7646
7918
|
const { descriptor, maxBytes } = options;
|
|
7647
7919
|
const timeout = options.timeoutMs ?? 120000;
|
|
@@ -7674,12 +7946,12 @@ async function downloadVerifiedRelease(options) {
|
|
|
7674
7946
|
throw new Error("Release download size mismatch");
|
|
7675
7947
|
}
|
|
7676
7948
|
const root = options.createTemporaryDirectory ? await realpath9(resolve14(options.directory)) : resolve14(options.directory);
|
|
7677
|
-
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(
|
|
7949
|
+
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp9(join31(root, "framework-update-"));
|
|
7678
7950
|
const temporaryDirectory = resolve14(allocated);
|
|
7679
7951
|
if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
|
|
7680
7952
|
throw new Error("Invalid update download directory");
|
|
7681
7953
|
temporary = temporaryDirectory;
|
|
7682
|
-
const path =
|
|
7954
|
+
const path = join31(temporary, "archive");
|
|
7683
7955
|
const file = await open12(path, "wx", 384);
|
|
7684
7956
|
try {
|
|
7685
7957
|
async function* writeChunks() {
|
|
@@ -7782,7 +8054,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7782
8054
|
const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
|
|
7783
8055
|
if (!requirements.offlinePolicy || !names || names.length !== 2)
|
|
7784
8056
|
throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
|
|
7785
|
-
const directory = resolve15(options.directory), destination =
|
|
8057
|
+
const directory = resolve15(options.directory), destination = join32(directory, `upgrade-test-${platform}.json`);
|
|
7786
8058
|
try {
|
|
7787
8059
|
await lstat19(destination);
|
|
7788
8060
|
throw new Error("Upgrade receipt already exists");
|
|
@@ -7805,7 +8077,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7805
8077
|
const channel = "daily";
|
|
7806
8078
|
const trust = { ...base, channel };
|
|
7807
8079
|
const discovery = discoveryName(config, channel, platform);
|
|
7808
|
-
const signed = await readJsonFile(
|
|
8080
|
+
const signed = await readJsonFile(join32(directory, discovery), 65536, "staged descriptor");
|
|
7809
8081
|
const verified = verifyReleaseDescriptor(signed, trust);
|
|
7810
8082
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
|
|
7811
8083
|
throw new Error("Untrusted staged descriptor");
|
|
@@ -7828,7 +8100,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7828
8100
|
return null;
|
|
7829
8101
|
if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
|
|
7830
8102
|
throw new Error("Previous release is not older than this release");
|
|
7831
|
-
const work =
|
|
8103
|
+
const work = join32(directory, `upgrade-${platform}`);
|
|
7832
8104
|
await mkdir10(work, { mode: 448 });
|
|
7833
8105
|
const downloaded = await downloadVerifiedRelease({
|
|
7834
8106
|
descriptor: previous,
|
|
@@ -7837,12 +8109,12 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7837
8109
|
timeoutMs: 600000,
|
|
7838
8110
|
fetch: fetcher
|
|
7839
8111
|
});
|
|
7840
|
-
const previousArchive =
|
|
8112
|
+
const previousArchive = join32(work, previous.asset.name);
|
|
7841
8113
|
await rename2(downloaded.path, previousArchive);
|
|
7842
8114
|
const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
|
|
7843
8115
|
if (!installerName)
|
|
7844
8116
|
throw new Error("Previous release has no installer for this platform");
|
|
7845
|
-
const previousInstaller =
|
|
8117
|
+
const previousInstaller = join32(work, installerName);
|
|
7846
8118
|
await downloadAsset({
|
|
7847
8119
|
feed,
|
|
7848
8120
|
tag: previous.tag,
|
|
@@ -7866,7 +8138,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7866
8138
|
update: {
|
|
7867
8139
|
descriptor,
|
|
7868
8140
|
trust,
|
|
7869
|
-
archive:
|
|
8141
|
+
archive: join32(directory, names[1]),
|
|
7870
8142
|
maxCompressedBytes: MAX_COMPRESSED_BYTES2,
|
|
7871
8143
|
maxExpandedBytes: MAX_EXPANDED_BYTES2
|
|
7872
8144
|
}
|
|
@@ -7889,7 +8161,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
7889
8161
|
}
|
|
7890
8162
|
|
|
7891
8163
|
// src/library/steps.ts
|
|
7892
|
-
var selectRetainedStepEffect = (context) =>
|
|
8164
|
+
var selectRetainedStepEffect = (context) => Effect24.gen(function* () {
|
|
7893
8165
|
const output = context.env.GITHUB_OUTPUT;
|
|
7894
8166
|
if (!output)
|
|
7895
8167
|
return yield* fail("Expected GITHUB_OUTPUT");
|
|
@@ -7901,7 +8173,7 @@ runId=${result.runId}
|
|
|
7901
8173
|
` : `reuse=false
|
|
7902
8174
|
`));
|
|
7903
8175
|
});
|
|
7904
|
-
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") =>
|
|
8176
|
+
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect24.gen(function* () {
|
|
7905
8177
|
const fs = yield* ReleaseFs;
|
|
7906
8178
|
const [installerAsset, archiveAsset] = platformAssets(context);
|
|
7907
8179
|
const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
|
|
@@ -7910,12 +8182,12 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
|
|
|
7910
8182
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
7911
8183
|
const packed = yield* scopedTempDirectory("framework-command-pack-");
|
|
7912
8184
|
const sources = {
|
|
7913
|
-
[installerAsset]:
|
|
7914
|
-
[archiveAsset]:
|
|
8185
|
+
[installerAsset]: join33(artifacts, installer),
|
|
8186
|
+
[archiveAsset]: join33(artifacts, archive)
|
|
7915
8187
|
};
|
|
7916
8188
|
for (const policy of parsed.commandArtifacts) {
|
|
7917
8189
|
const name = requirements.commandArtifacts[policy.kind][context.platform];
|
|
7918
|
-
sources[name] =
|
|
8190
|
+
sources[name] = join33(packed, name);
|
|
7919
8191
|
yield* step(() => packCommandArtifact({
|
|
7920
8192
|
source: policy.build,
|
|
7921
8193
|
archive: sources[name],
|
|
@@ -7924,8 +8196,8 @@ var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effe
|
|
|
7924
8196
|
}));
|
|
7925
8197
|
}
|
|
7926
8198
|
return yield* stagePlatformArtifactsEffect({ ...context, directory, sources });
|
|
7927
|
-
}).pipe(
|
|
7928
|
-
var inspectStagedStepEffect = (context, directory) =>
|
|
8199
|
+
}).pipe(Effect24.scoped);
|
|
8200
|
+
var inspectStagedStepEffect = (context, directory) => Effect24.gen(function* () {
|
|
7929
8201
|
const fs = yield* ReleaseFs;
|
|
7930
8202
|
const parsed = parseReleaseConfig(context.config);
|
|
7931
8203
|
const requirements = parsed.requirements(context.tag);
|
|
@@ -7933,10 +8205,10 @@ var inspectStagedStepEffect = (context, directory) => Effect22.gen(function* ()
|
|
|
7933
8205
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
7934
8206
|
if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
|
|
7935
8207
|
return yield* fail("Staged platform directory contains unexpected files");
|
|
7936
|
-
const [installer, archive] = platformAssets(context).map((name) =>
|
|
8208
|
+
const [installer, archive] = platformAssets(context).map((name) => join33(directory, name));
|
|
7937
8209
|
for (const policy of parsed.commandArtifacts)
|
|
7938
8210
|
yield* step(() => readCommandArtifact({
|
|
7939
|
-
archive:
|
|
8211
|
+
archive: join33(directory, requirements.commandArtifacts[policy.kind][context.platform]),
|
|
7940
8212
|
executable: policy.executable,
|
|
7941
8213
|
platform: context.platform
|
|
7942
8214
|
}));
|
|
@@ -7952,12 +8224,12 @@ var inspectStagedStepEffect = (context, directory) => Effect22.gen(function* ()
|
|
|
7952
8224
|
}))
|
|
7953
8225
|
};
|
|
7954
8226
|
});
|
|
7955
|
-
var qualifyStepEffect = (context, directory) =>
|
|
8227
|
+
var qualifyStepEffect = (context, directory) => Effect24.gen(function* () {
|
|
7956
8228
|
const mode = stepRenderer(context.env);
|
|
7957
8229
|
yield* step(() => qualifyCommandArtifactsCommand({ ...context, directory }));
|
|
7958
8230
|
yield* step(() => qualifyInstallerCommand({ ...context, renderer: mode, directory }));
|
|
7959
8231
|
});
|
|
7960
|
-
var qualifyUpgradeStepEffect = (context, directory, onStage) =>
|
|
8232
|
+
var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect24.suspend(() => {
|
|
7961
8233
|
const renderer = stepRenderer(context.env);
|
|
7962
8234
|
return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
|
|
7963
8235
|
});
|
|
@@ -7967,6 +8239,206 @@ var stageBuildStep = (context, directory, artifacts) => run2(context, stageBuild
|
|
|
7967
8239
|
var inspectStagedStep = (context, directory) => run2(context, inspectStagedStepEffect(context, directory));
|
|
7968
8240
|
var qualifyStep = (context, directory) => run2(context, qualifyStepEffect(context, directory));
|
|
7969
8241
|
var qualifyUpgradeStep = (context, directory, onStage) => run2(context, qualifyUpgradeStepEffect(context, directory, onStage));
|
|
8242
|
+
// src/library/linux-package-pair.ts
|
|
8243
|
+
import { execFile as execFile3 } from "child_process";
|
|
8244
|
+
import {
|
|
8245
|
+
chmod as chmod3,
|
|
8246
|
+
link,
|
|
8247
|
+
mkdir as mkdir11,
|
|
8248
|
+
mkdtemp as mkdtemp10,
|
|
8249
|
+
open as open13,
|
|
8250
|
+
readFile as readFile10,
|
|
8251
|
+
realpath as realpath10,
|
|
8252
|
+
rm as rm10,
|
|
8253
|
+
writeFile as writeFile11
|
|
8254
|
+
} from "fs/promises";
|
|
8255
|
+
import { dirname as dirname14, join as join34, resolve as resolve16 } from "path";
|
|
8256
|
+
import { promisify as promisify2 } from "util";
|
|
8257
|
+
var shasum = /^[a-f0-9]{64}$/;
|
|
8258
|
+
var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
8259
|
+
var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
8260
|
+
var exec = promisify2(execFile3);
|
|
8261
|
+
function requireThat2(condition, message) {
|
|
8262
|
+
if (!condition)
|
|
8263
|
+
throw new Error(message);
|
|
8264
|
+
}
|
|
8265
|
+
function record2(value) {
|
|
8266
|
+
requireThat2(typeof value === "object" && value !== null && !Array.isArray(value), "Invalid producer receipt");
|
|
8267
|
+
return value;
|
|
8268
|
+
}
|
|
8269
|
+
function validIdentity(value) {
|
|
8270
|
+
const { name, size, sha256 } = record2(value);
|
|
8271
|
+
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");
|
|
8272
|
+
return { name, size, sha256 };
|
|
8273
|
+
}
|
|
8274
|
+
var inspectWithNativeTools = async (tool, args) => {
|
|
8275
|
+
try {
|
|
8276
|
+
const { stdout } = await exec(tool, [...args], {
|
|
8277
|
+
encoding: "utf8",
|
|
8278
|
+
maxBuffer: 128 * 1024,
|
|
8279
|
+
timeout: 30000,
|
|
8280
|
+
env: { PATH: process.env.PATH, LC_ALL: "C" }
|
|
8281
|
+
});
|
|
8282
|
+
return stdout;
|
|
8283
|
+
} catch (error) {
|
|
8284
|
+
if (error.code === "ENOENT")
|
|
8285
|
+
throw new Error(`${tool} is required to inspect Linux package candidates`, { cause: error });
|
|
8286
|
+
throw new Error(`${tool} could not inspect Linux package candidate`, { cause: error });
|
|
8287
|
+
}
|
|
8288
|
+
};
|
|
8289
|
+
function parseDebianIdentity(text, packageName, version) {
|
|
8290
|
+
const fields = text.trimEnd().split(/\r?\n/);
|
|
8291
|
+
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");
|
|
8292
|
+
}
|
|
8293
|
+
function requireRegularDesktopEntry(listing, id) {
|
|
8294
|
+
const lines = listing.trimEnd().split(/\r?\n/);
|
|
8295
|
+
const fields = /^[d-][-rwxstST]{9} +\d+\/\d+ +\d+ +\d{4}-\d{2}-\d{2} \d{2}:\d{2} (.+)$/;
|
|
8296
|
+
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");
|
|
8297
|
+
}
|
|
8298
|
+
function requireDesktopIdentity(text, name, version) {
|
|
8299
|
+
let inDesktop = false;
|
|
8300
|
+
let foundGroup = false;
|
|
8301
|
+
const fields = new Map;
|
|
8302
|
+
for (const line of text.split(/\r?\n/)) {
|
|
8303
|
+
if (/^\[.*\]$/.test(line)) {
|
|
8304
|
+
inDesktop = line === "[Desktop Entry]";
|
|
8305
|
+
if (inDesktop) {
|
|
8306
|
+
requireThat2(!foundGroup, "Duplicate AppImage desktop entry");
|
|
8307
|
+
foundGroup = true;
|
|
8308
|
+
}
|
|
8309
|
+
continue;
|
|
8310
|
+
}
|
|
8311
|
+
if (!inDesktop || !line || line.startsWith("#"))
|
|
8312
|
+
continue;
|
|
8313
|
+
const match = /^([^=]+)=(.*)$/.exec(line);
|
|
8314
|
+
requireThat2(match && !fields.has(match[1]), "Malformed or duplicate AppImage desktop fields");
|
|
8315
|
+
fields.set(match[1], match[2]);
|
|
8316
|
+
}
|
|
8317
|
+
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");
|
|
8318
|
+
}
|
|
8319
|
+
function digestWindow(runtime) {
|
|
8320
|
+
const sectionStart = Number(runtime.readBigUInt64LE(40));
|
|
8321
|
+
const sectionSize = runtime.readUInt16LE(58);
|
|
8322
|
+
const count = runtime.readUInt16LE(60);
|
|
8323
|
+
const namesIndex = runtime.readUInt16LE(62);
|
|
8324
|
+
requireThat2(Number.isSafeInteger(sectionStart) && sectionStart >= 64 && sectionSize === 64 && namesIndex < count && sectionStart + count * sectionSize <= runtime.length, "Invalid pinned AppImage runtime ELF section table");
|
|
8325
|
+
const namesHeader = sectionStart + sectionSize * namesIndex;
|
|
8326
|
+
const namesStart = Number(runtime.readBigUInt64LE(namesHeader + 24));
|
|
8327
|
+
const namesSize = Number(runtime.readBigUInt64LE(namesHeader + 32));
|
|
8328
|
+
requireThat2(Number.isSafeInteger(namesStart) && Number.isSafeInteger(namesSize) && namesStart >= 64 && namesStart + namesSize <= runtime.length, "Invalid pinned AppImage runtime ELF section names");
|
|
8329
|
+
const names = runtime.subarray(namesStart, namesStart + namesSize);
|
|
8330
|
+
const matches = [];
|
|
8331
|
+
for (let i = 0;i < count; i++) {
|
|
8332
|
+
const section = sectionStart + sectionSize * i;
|
|
8333
|
+
const nameAt = runtime.readUInt32LE(section);
|
|
8334
|
+
const end = names.indexOf(0, nameAt);
|
|
8335
|
+
if (end < 0 || names.toString("ascii", nameAt, end) !== ".digest_md5")
|
|
8336
|
+
continue;
|
|
8337
|
+
const dataAt = Number(runtime.readBigUInt64LE(section + 24));
|
|
8338
|
+
const dataSize = Number(runtime.readBigUInt64LE(section + 32));
|
|
8339
|
+
requireThat2(Number.isSafeInteger(dataAt) && Number.isSafeInteger(dataSize) && dataAt >= 64 && dataSize >= 16 && dataAt + dataSize <= runtime.length, "Invalid pinned AppImage runtime digest section");
|
|
8340
|
+
matches.push(dataAt);
|
|
8341
|
+
}
|
|
8342
|
+
requireThat2(matches.length === 1, "Expected one pinned AppImage runtime digest section");
|
|
8343
|
+
return matches[0];
|
|
8344
|
+
}
|
|
8345
|
+
function type2X64(bytes) {
|
|
8346
|
+
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) === 62;
|
|
8347
|
+
}
|
|
8348
|
+
async function verifyEmbeddedRuntime(path, runtime) {
|
|
8349
|
+
requireThat2(type2X64(runtime), "Expected a pinned Type 2 x86_64 AppImage runtime");
|
|
8350
|
+
const ignored = digestWindow(runtime);
|
|
8351
|
+
const fd = await open13(path, "r");
|
|
8352
|
+
try {
|
|
8353
|
+
const prefix = Buffer.alloc(runtime.length + 4);
|
|
8354
|
+
let filled = 0;
|
|
8355
|
+
while (filled < prefix.length) {
|
|
8356
|
+
const { bytesRead } = await fd.read(prefix, filled, prefix.length - filled, filled);
|
|
8357
|
+
if (!bytesRead)
|
|
8358
|
+
throw new Error("Incomplete embedded AppImage runtime or SquashFS header");
|
|
8359
|
+
filled += bytesRead;
|
|
8360
|
+
}
|
|
8361
|
+
requireThat2(type2X64(prefix), "Expected a Type 2 x86_64 AppImage");
|
|
8362
|
+
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");
|
|
8363
|
+
requireThat2(prefix.toString("ascii", runtime.length) === "hsqs", "Missing embedded SquashFS at the pinned runtime offset");
|
|
8364
|
+
} finally {
|
|
8365
|
+
await fd.close();
|
|
8366
|
+
}
|
|
8367
|
+
}
|
|
8368
|
+
async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
8369
|
+
const { expected, sources } = options;
|
|
8370
|
+
const receipt = record2(options.producer);
|
|
8371
|
+
const archive = validIdentity(expected.archive);
|
|
8372
|
+
const runtime = validIdentity(expected.runtime);
|
|
8373
|
+
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");
|
|
8374
|
+
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");
|
|
8375
|
+
const names = [expected.debName, expected.appImageName];
|
|
8376
|
+
const artifacts = receipt.artifacts.map(validIdentity);
|
|
8377
|
+
const trustedArtifacts = expected.artifacts.map(validIdentity);
|
|
8378
|
+
requireThat2(trustedArtifacts.length === 2 && names.every((name) => {
|
|
8379
|
+
const fromProducer = artifacts.find((file) => file.name === name);
|
|
8380
|
+
const trusted = trustedArtifacts.find((file) => file.name === name);
|
|
8381
|
+
return fromProducer && trusted && trusted.size === fromProducer.size && trusted.sha256 === fromProducer.sha256;
|
|
8382
|
+
}), "Package producer receipt must describe exactly the protected DEB and AppImage");
|
|
8383
|
+
const destination = resolve16(options.output);
|
|
8384
|
+
const parent = await realpath10(dirname14(destination));
|
|
8385
|
+
const work = await mkdtemp10(join34(parent, ".linux-package-pair-"));
|
|
8386
|
+
try {
|
|
8387
|
+
const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
|
|
8388
|
+
directory: work,
|
|
8389
|
+
expected: [...names, archive.name, runtime.name],
|
|
8390
|
+
sources
|
|
8391
|
+
})));
|
|
8392
|
+
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");
|
|
8393
|
+
const deb = join34(work, expected.debName);
|
|
8394
|
+
const image = join34(work, expected.appImageName);
|
|
8395
|
+
const version = expected.tag.slice(1);
|
|
8396
|
+
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
|
|
8397
|
+
await verifyEmbeddedRuntime(image, await readFile10(join34(work, runtime.name)));
|
|
8398
|
+
const offset = String(runtime.size);
|
|
8399
|
+
requireRegularDesktopEntry(await inspect("unsquashfs", [
|
|
8400
|
+
"-offset",
|
|
8401
|
+
offset,
|
|
8402
|
+
"-lln",
|
|
8403
|
+
"-no-wildcards",
|
|
8404
|
+
image,
|
|
8405
|
+
expected.desktopId
|
|
8406
|
+
]), expected.desktopId);
|
|
8407
|
+
requireDesktopIdentity(await inspect("unsquashfs", [
|
|
8408
|
+
"-offset",
|
|
8409
|
+
offset,
|
|
8410
|
+
"-cat",
|
|
8411
|
+
"-no-wildcards",
|
|
8412
|
+
image,
|
|
8413
|
+
expected.desktopId
|
|
8414
|
+
]), expected.desktopName, version);
|
|
8415
|
+
await chmod3(image, 493);
|
|
8416
|
+
const staged = {
|
|
8417
|
+
schema: "linux-package-pair/v1",
|
|
8418
|
+
tag: expected.tag,
|
|
8419
|
+
sourceSha: expected.sourceSha,
|
|
8420
|
+
platform: "linux-x64",
|
|
8421
|
+
updateArchiveSha256: archive.sha256,
|
|
8422
|
+
artifacts: names.map((name) => artifacts.find((file) => file.name === name))
|
|
8423
|
+
};
|
|
8424
|
+
await mkdir11(destination);
|
|
8425
|
+
try {
|
|
8426
|
+
for (const name of names)
|
|
8427
|
+
await link(join34(work, name), join34(destination, name));
|
|
8428
|
+
await writeFile11(join34(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
|
|
8429
|
+
`, {
|
|
8430
|
+
flag: "wx"
|
|
8431
|
+
});
|
|
8432
|
+
} catch (error) {
|
|
8433
|
+
await rm10(destination, { recursive: true, force: true });
|
|
8434
|
+
throw error;
|
|
8435
|
+
}
|
|
8436
|
+
return staged;
|
|
8437
|
+
} finally {
|
|
8438
|
+
await rm10(work, { recursive: true, force: true });
|
|
8439
|
+
}
|
|
8440
|
+
}
|
|
8441
|
+
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
7970
8442
|
// src/framework-loader.ts
|
|
7971
8443
|
var releaseTools = async () => exports_src;
|
|
7972
8444
|
|
|
@@ -7988,19 +8460,310 @@ function electrobunArtifacts(appName, platform) {
|
|
|
7988
8460
|
}[platform];
|
|
7989
8461
|
}
|
|
7990
8462
|
|
|
8463
|
+
// src/library/daily-native-observer.ts
|
|
8464
|
+
import { execFile as execFile4 } from "child_process";
|
|
8465
|
+
import { createHash as createHash16, randomBytes as randomBytes3 } from "crypto";
|
|
8466
|
+
import { join as join35, resolve as resolve17 } from "path";
|
|
8467
|
+
import { Effect as Effect25 } from "effect";
|
|
8468
|
+
var runDailyNativeDriver = (script, input, env) => new Promise((finish, reject) => {
|
|
8469
|
+
const child = execFile4(process.execPath, ["--no-env-file", script], {
|
|
8470
|
+
cwd: input.profile,
|
|
8471
|
+
env,
|
|
8472
|
+
maxBuffer: 16 * 1024,
|
|
8473
|
+
timeout: 120000,
|
|
8474
|
+
killSignal: "SIGKILL",
|
|
8475
|
+
windowsHide: true
|
|
8476
|
+
}, (error, stdout) => {
|
|
8477
|
+
if (error)
|
|
8478
|
+
return reject(new Error("Native observer driver failed"));
|
|
8479
|
+
try {
|
|
8480
|
+
finish(JSON.parse(stdout));
|
|
8481
|
+
} catch {
|
|
8482
|
+
reject(new Error("Native observer driver did not emit one JSON result"));
|
|
8483
|
+
}
|
|
8484
|
+
});
|
|
8485
|
+
child.stdin?.on("error", () => {
|
|
8486
|
+
return;
|
|
8487
|
+
});
|
|
8488
|
+
child.stdin?.end(JSON.stringify(input) + `
|
|
8489
|
+
`);
|
|
8490
|
+
});
|
|
8491
|
+
function phaseEnvironment(env, profile) {
|
|
8492
|
+
const clean = {};
|
|
8493
|
+
for (const key of [
|
|
8494
|
+
"PATH",
|
|
8495
|
+
"SystemRoot",
|
|
8496
|
+
"WINDIR",
|
|
8497
|
+
"COMSPEC",
|
|
8498
|
+
"PATHEXT",
|
|
8499
|
+
"LANG",
|
|
8500
|
+
"LC_ALL",
|
|
8501
|
+
"DISPLAY",
|
|
8502
|
+
"XAUTHORITY",
|
|
8503
|
+
"DBUS_SESSION_BUS_ADDRESS",
|
|
8504
|
+
"CI",
|
|
8505
|
+
"GITHUB_ACTIONS",
|
|
8506
|
+
"RUNNER_ENVIRONMENT",
|
|
8507
|
+
"GITLAB_CI",
|
|
8508
|
+
"CI_JOB_ID",
|
|
8509
|
+
"CIRCLECI",
|
|
8510
|
+
"CIRCLE_BUILD_NUM",
|
|
8511
|
+
"FRAMEWORK_DISPOSABLE_RUNNER"
|
|
8512
|
+
]) {
|
|
8513
|
+
if (env[key])
|
|
8514
|
+
clean[key] = env[key];
|
|
8515
|
+
}
|
|
8516
|
+
return {
|
|
8517
|
+
...clean,
|
|
8518
|
+
HOME: profile,
|
|
8519
|
+
USERPROFILE: profile,
|
|
8520
|
+
LOCALAPPDATA: join35(profile, "LocalAppData"),
|
|
8521
|
+
XDG_CONFIG_HOME: join35(profile, ".config"),
|
|
8522
|
+
XDG_DATA_HOME: join35(profile, ".local", "share"),
|
|
8523
|
+
TEMP: join35(profile, "tmp"),
|
|
8524
|
+
TMP: join35(profile, "tmp"),
|
|
8525
|
+
TMPDIR: join35(profile, "tmp")
|
|
8526
|
+
};
|
|
8527
|
+
}
|
|
8528
|
+
function parseBaseline(value, target) {
|
|
8529
|
+
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)
|
|
8530
|
+
throw new Error("Native observation needs declared exact older installer provenance");
|
|
8531
|
+
return {
|
|
8532
|
+
kind: value.kind,
|
|
8533
|
+
tag: value.tag,
|
|
8534
|
+
sourceSha: value.sourceSha,
|
|
8535
|
+
directory: value.directory
|
|
8536
|
+
};
|
|
8537
|
+
}
|
|
8538
|
+
function driverPath(value) {
|
|
8539
|
+
if (value.length > 240 || !/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*\.(?:ts|mjs)$/.test(value) || value.split("/").some((part) => part === "." || part === ".."))
|
|
8540
|
+
throw new Error("Invalid native observer path");
|
|
8541
|
+
return value;
|
|
8542
|
+
}
|
|
8543
|
+
var fixtureDigest = (nonce) => "sha256:" + createHash16("sha256").update(nonce).digest("hex");
|
|
8544
|
+
var confirmFixture = (value, nonce) => isRecord(value) && hasExactOwnKeys(value, ["digest"]) && value.digest === fixtureDigest(nonce);
|
|
8545
|
+
var observeDailyNativeEffect = (options, run) => Effect25.gen(function* () {
|
|
8546
|
+
const { env, platform: os, arch, cwd } = yield* ReleaseConfig;
|
|
8547
|
+
const fs = yield* ReleaseFs;
|
|
8548
|
+
const git = yield* ReleaseGit;
|
|
8549
|
+
const { identity, config, checkName } = options;
|
|
8550
|
+
yield* attempt(() => {
|
|
8551
|
+
assertHostedRunner(env, "Daily native observation");
|
|
8552
|
+
if (env.FRAMEWORK_DAILY_NATIVE_OBSERVER !== "test-only")
|
|
8553
|
+
throw new Error("Daily native observer is disabled without explicit test-only opt-in");
|
|
8554
|
+
assertDailyIdentity(identity);
|
|
8555
|
+
});
|
|
8556
|
+
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
8557
|
+
const check = matrix.checks.find((value) => value.name === checkName);
|
|
8558
|
+
if (!check)
|
|
8559
|
+
return yield* fail("Unknown Daily native check");
|
|
8560
|
+
const host = platformTargets[check.platform];
|
|
8561
|
+
if (os !== host[0] || arch !== host[1])
|
|
8562
|
+
return yield* fail(`Daily native check requires ${check.platform}`);
|
|
8563
|
+
if (os === "linux" && !env.DISPLAY)
|
|
8564
|
+
return yield* fail("Daily Linux native observer requires a display");
|
|
8565
|
+
const previous = check.format === "command" ? undefined : yield* attempt(() => parseBaseline(options.baseline, identity.tag));
|
|
8566
|
+
if (check.format === "command" && options.baseline !== undefined)
|
|
8567
|
+
return yield* fail("Command observation does not take an installer baseline");
|
|
8568
|
+
const prior = previous ? yield* attempt(() => priorDailyInstallerNames(config, previous.tag, check)) : undefined;
|
|
8569
|
+
if (previous && (!prior?.installer || previous.kind === "private-from-verified-payload" && !prior.payload))
|
|
8570
|
+
return yield* fail("Missing same-format baseline names");
|
|
8571
|
+
const path = yield* attempt(() => driverPath(options.driver));
|
|
8572
|
+
const revision = yield* step(() => git.run(["rev-parse", "HEAD"]));
|
|
8573
|
+
if (revision !== identity.sourceSha)
|
|
8574
|
+
return yield* fail("Native observer checkout does not match release source");
|
|
8575
|
+
const tree = yield* step(() => git.run(["ls-tree", revision, "--", path]));
|
|
8576
|
+
const blob = /^100(?:644|755) blob ([a-f0-9]{40})\t/.exec(tree)?.[1];
|
|
8577
|
+
if (!blob || tree.slice(tree.indexOf("\t") + 1) !== path)
|
|
8578
|
+
return yield* fail("Native observer is not a regular file of the pinned source");
|
|
8579
|
+
const temp = runnerTemp(env);
|
|
8580
|
+
if (!temp)
|
|
8581
|
+
return yield* fail("Daily native observation needs the runner temp directory");
|
|
8582
|
+
const tempStat = yield* step(() => fs.lstat(temp));
|
|
8583
|
+
if (!tempStat.isDirectory() || tempStat.isSymbolicLink())
|
|
8584
|
+
return yield* fail("Expected real runner temp directory");
|
|
8585
|
+
const root = yield* Effect25.acquireRelease(step(() => fs.mkdtemp(join35(temp, "daily-native-"))), (dir) => Effect25.promise(() => fs.rm(dir, { recursive: true, force: true })));
|
|
8586
|
+
const make = (name) => Effect25.gen(function* () {
|
|
8587
|
+
const dir = join35(root, name);
|
|
8588
|
+
yield* step(() => fs.mkdir(dir, { mode: 448 }));
|
|
8589
|
+
return dir;
|
|
8590
|
+
});
|
|
8591
|
+
const snapshot = (source, target, names) => Effect25.gen(function* () {
|
|
8592
|
+
const directory = resolve17(source);
|
|
8593
|
+
const info = yield* step(() => fs.lstat(directory));
|
|
8594
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
8595
|
+
return yield* fail("Expected real native input directory");
|
|
8596
|
+
return yield* stageExpectedFilesEffect({
|
|
8597
|
+
expected: names,
|
|
8598
|
+
directory: target,
|
|
8599
|
+
sources: Object.fromEntries(names.map((name) => [name, join35(directory, name)]))
|
|
8600
|
+
});
|
|
8601
|
+
});
|
|
8602
|
+
const scriptName = path.endsWith(".mjs") ? "observer.mjs" : "observer.ts";
|
|
8603
|
+
const script = join35(root, scriptName);
|
|
8604
|
+
yield* stageExpectedFilesEffect({
|
|
8605
|
+
directory: root,
|
|
8606
|
+
expected: [scriptName],
|
|
8607
|
+
sources: { [scriptName]: join35(cwd, path) }
|
|
8608
|
+
});
|
|
8609
|
+
const hash = yield* step(() => git.run(["hash-object", "--no-filters", "--", script]));
|
|
8610
|
+
if (hash !== blob)
|
|
8611
|
+
return yield* fail("Native observer file does not match its trusted source blob");
|
|
8612
|
+
const candidate = yield* make("candidate");
|
|
8613
|
+
const assets = yield* snapshot(options.artifacts, candidate, check.assets);
|
|
8614
|
+
const baseline = previous ? yield* make("baseline") : undefined;
|
|
8615
|
+
const baselineFiles = previous ? [
|
|
8616
|
+
prior.installer,
|
|
8617
|
+
...previous.kind === "private-from-verified-payload" ? [prior.payload] : []
|
|
8618
|
+
] : undefined;
|
|
8619
|
+
const earlier = previous && baseline ? yield* snapshot(previous.directory, baseline, baselineFiles) : undefined;
|
|
8620
|
+
const freshProfile = (name) => Effect25.gen(function* () {
|
|
8621
|
+
const dir = yield* make(name);
|
|
8622
|
+
yield* step(() => fs.mkdir(join35(dir, "tmp"), { mode: 448 }));
|
|
8623
|
+
return dir;
|
|
8624
|
+
});
|
|
8625
|
+
const fresh = yield* freshProfile("fresh");
|
|
8626
|
+
const call = (phase, profile, fixture) => step(async () => {
|
|
8627
|
+
if (await git.run(["hash-object", "--no-filters", "--", script]) !== blob)
|
|
8628
|
+
throw new Error("Native observer changed during qualification");
|
|
8629
|
+
const output = await run(script, {
|
|
8630
|
+
phase,
|
|
8631
|
+
tag: identity.tag,
|
|
8632
|
+
check: check.name,
|
|
8633
|
+
format: check.format,
|
|
8634
|
+
candidate,
|
|
8635
|
+
candidateFiles: check.assets,
|
|
8636
|
+
baseline,
|
|
8637
|
+
baselineFiles,
|
|
8638
|
+
baselineTag: previous?.tag,
|
|
8639
|
+
profile,
|
|
8640
|
+
fixture
|
|
8641
|
+
}, phaseEnvironment(env, profile));
|
|
8642
|
+
if (await git.run(["hash-object", "--no-filters", "--", script]) !== blob)
|
|
8643
|
+
throw new Error("Native observer changed during qualification");
|
|
8644
|
+
return output;
|
|
8645
|
+
}).pipe(Effect25.mapError(() => new Error(`Native observer phase failed: ${phase}`)));
|
|
8646
|
+
const installVersion = (phase, version, where) => Effect25.gen(function* () {
|
|
8647
|
+
const result = yield* call(phase, where);
|
|
8648
|
+
if (!isRecord(result) || !hasExactOwnKeys(result, ["version"]) || result.version !== version)
|
|
8649
|
+
return yield* fail(`Native observer did not observe the expected version: ${phase}`);
|
|
8650
|
+
return { version };
|
|
8651
|
+
});
|
|
8652
|
+
const launch = (phase, version, where) => Effect25.gen(function* () {
|
|
8653
|
+
const result = yield* call(phase, where);
|
|
8654
|
+
if (!isRecord(result) || !hasExactOwnKeys(result, ["version", "ready", "stopped"]) || result.version !== version || result.ready !== true || result.stopped !== true)
|
|
8655
|
+
return yield* fail(`Native observer did not observe a ready renderer: ${phase}`);
|
|
8656
|
+
return { version, ready: true };
|
|
8657
|
+
});
|
|
8658
|
+
const version = identity.tag.slice(1);
|
|
8659
|
+
let observations;
|
|
8660
|
+
if (previous && baseline && earlier) {
|
|
8661
|
+
const upgrade = yield* freshProfile("upgrade");
|
|
8662
|
+
const install = yield* installVersion("fresh-install", version, fresh);
|
|
8663
|
+
const launchedFresh = yield* launch("fresh-launch", version, fresh);
|
|
8664
|
+
const installedBefore = yield* installVersion("baseline-install", previous.tag.slice(1), upgrade);
|
|
8665
|
+
const nonce = randomBytes3(24).toString("hex");
|
|
8666
|
+
const before = yield* call("fixture-write", upgrade, nonce);
|
|
8667
|
+
if (!confirmFixture(before, nonce))
|
|
8668
|
+
return yield* fail("Native baseline did not observe synthetic fixture");
|
|
8669
|
+
const upgraded = yield* installVersion("upgrade-install", version, upgrade);
|
|
8670
|
+
const launched = yield* launch("upgrade-launch", version, upgrade);
|
|
8671
|
+
const after = yield* call("fixture-read", upgrade);
|
|
8672
|
+
if (!confirmFixture(after, nonce))
|
|
8673
|
+
return yield* fail("Native upgrade did not retain synthetic fixture");
|
|
8674
|
+
observations = {
|
|
8675
|
+
install,
|
|
8676
|
+
launch: launchedFresh,
|
|
8677
|
+
upgrade: {
|
|
8678
|
+
baselineTag: previous.tag,
|
|
8679
|
+
baselineAsset: earlier[0],
|
|
8680
|
+
baselineOrigin: {
|
|
8681
|
+
kind: previous.kind,
|
|
8682
|
+
sourceSha: previous.sourceSha,
|
|
8683
|
+
...earlier[1] ? { payload: earlier[1] } : {}
|
|
8684
|
+
},
|
|
8685
|
+
baselineVersion: installedBefore.version,
|
|
8686
|
+
upgradedVersion: upgraded.version,
|
|
8687
|
+
ready: launched.ready,
|
|
8688
|
+
fixtureBefore: fixtureDigest(nonce),
|
|
8689
|
+
fixtureAfter: fixtureDigest(nonce)
|
|
8690
|
+
}
|
|
8691
|
+
};
|
|
8692
|
+
} else {
|
|
8693
|
+
const install = yield* installVersion("command-install", version, fresh);
|
|
8694
|
+
const command = yield* call("command-probe", fresh);
|
|
8695
|
+
observations = { install, command };
|
|
8696
|
+
}
|
|
8697
|
+
return yield* createDailyNativeReceiptEffect({
|
|
8698
|
+
config,
|
|
8699
|
+
identity,
|
|
8700
|
+
checkName,
|
|
8701
|
+
artifacts: candidate,
|
|
8702
|
+
baselineArtifacts: baseline,
|
|
8703
|
+
report: {
|
|
8704
|
+
schema: "framework/daily-native-job/v1",
|
|
8705
|
+
...identity,
|
|
8706
|
+
appId: matrix.appId,
|
|
8707
|
+
profile: matrix.profile,
|
|
8708
|
+
check: check.name,
|
|
8709
|
+
platform: check.platform,
|
|
8710
|
+
format: check.format,
|
|
8711
|
+
host: { os, arch },
|
|
8712
|
+
assets,
|
|
8713
|
+
observations
|
|
8714
|
+
}
|
|
8715
|
+
}, { os, arch });
|
|
8716
|
+
}).pipe(Effect25.scoped);
|
|
8717
|
+
|
|
8718
|
+
// src/library/daily-batch.ts
|
|
8719
|
+
import { join as join36, resolve as resolve18 } from "path";
|
|
8720
|
+
import { Effect as Effect26, Exit as Exit4 } from "effect";
|
|
8721
|
+
var stageDailyBatchEffect = (options) => Effect26.gen(function* () {
|
|
8722
|
+
const fs = yield* ReleaseFs;
|
|
8723
|
+
const parent = resolve18(options.parent);
|
|
8724
|
+
const root = yield* step(() => fs.lstat(parent));
|
|
8725
|
+
if (!root.isDirectory() || root.isSymbolicLink())
|
|
8726
|
+
return yield* fail("Daily staging needs an existing real scratch parent");
|
|
8727
|
+
const original = yield* verifyDailyReleaseMatrixEffect(options);
|
|
8728
|
+
const plan = yield* attempt(() => planDailyReleaseMatrix(options.config, options.identity.tag));
|
|
8729
|
+
const directory = yield* Effect26.acquireRelease(step(() => fs.mkdtemp(join36(parent, "daily-candidate-"))), (path, exit) => Exit4.isSuccess(exit) ? Effect26.void : Effect26.promise(() => fs.rm(path, { recursive: true, force: true })));
|
|
8730
|
+
const copy = (source, name, expected) => Effect26.gen(function* () {
|
|
8731
|
+
const target = join36(directory, name);
|
|
8732
|
+
yield* step(() => fs.mkdir(target, { mode: 448 }));
|
|
8733
|
+
yield* stageExpectedFilesEffect({
|
|
8734
|
+
expected,
|
|
8735
|
+
directory: target,
|
|
8736
|
+
sources: Object.fromEntries(expected.map((file) => [file, join36(source, file)]))
|
|
8737
|
+
});
|
|
8738
|
+
return target;
|
|
8739
|
+
});
|
|
8740
|
+
const artifacts = yield* copy(options.artifacts, "artifacts", plan.assets);
|
|
8741
|
+
const receipts = yield* copy(options.receipts, "receipts", plan.checks.map((check) => check.name + ".json"));
|
|
8742
|
+
const staged = yield* verifyDailyReleaseMatrixEffect({ ...options, artifacts, receipts });
|
|
8743
|
+
if (original.assets.some((a, index) => a.name !== staged.assets[index]?.name || a.size !== staged.assets[index]?.size || a.digest !== staged.assets[index]?.digest))
|
|
8744
|
+
return yield* fail("Daily inputs changed between inspection and local staging");
|
|
8745
|
+
const manifest = { schema: "framework/daily-staged-batch/v1", ...staged };
|
|
8746
|
+
yield* step(() => fs.writeFile(join36(directory, "candidate.json"), JSON.stringify(manifest) + `
|
|
8747
|
+
`, {
|
|
8748
|
+
flag: "wx",
|
|
8749
|
+
mode: 384
|
|
8750
|
+
}));
|
|
8751
|
+
return { directory, ...manifest };
|
|
8752
|
+
}).pipe(Effect26.scoped);
|
|
8753
|
+
|
|
7991
8754
|
// src/cli-runner.ts
|
|
7992
|
-
import { Cause as Cause3, Effect as
|
|
8755
|
+
import { Cause as Cause3, Effect as Effect27, Exit as Exit5 } from "effect";
|
|
7993
8756
|
function failureError(cause) {
|
|
7994
8757
|
const error = Cause3.squash(cause);
|
|
7995
8758
|
if (error instanceof ReleaseFailure)
|
|
7996
8759
|
return new Error(error.message);
|
|
7997
8760
|
return error instanceof Error ? error : new Error(String(error));
|
|
7998
8761
|
}
|
|
7999
|
-
var runCommand = (failure, program, options = {}) =>
|
|
8762
|
+
var runCommand = (failure, program, options = {}) => Effect27.gen(function* () {
|
|
8000
8763
|
const { env } = yield* ReleaseConfig;
|
|
8001
8764
|
const output = yield* ReleaseOutput;
|
|
8002
|
-
const exit = yield*
|
|
8003
|
-
if (
|
|
8765
|
+
const exit = yield* Effect27.exit(options.requireGitHubActions && env.GITHUB_ACTIONS !== "true" ? refuse("untrusted", "Invalid workflow invocation") : program);
|
|
8766
|
+
if (Exit5.isSuccess(exit))
|
|
8004
8767
|
return 0;
|
|
8005
8768
|
if (Cause3.hasInterruptsOnly(exit.cause))
|
|
8006
8769
|
return 130;
|
|
@@ -8010,7 +8773,7 @@ var runCommand = (failure, program, options = {}) => Effect23.gen(function* () {
|
|
|
8010
8773
|
return 1;
|
|
8011
8774
|
});
|
|
8012
8775
|
var readReleaseConfig = (path) => readBoundedJson(path, 262144);
|
|
8013
|
-
var readBoundedJson = (path, maxBytes, name = "configuration file") =>
|
|
8776
|
+
var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect27.gen(function* () {
|
|
8014
8777
|
const fs = yield* ReleaseFs;
|
|
8015
8778
|
const info = yield* step(() => fs.lstat(path));
|
|
8016
8779
|
if (!info.isFile() || info.size < 1 || info.size > maxBytes)
|
|
@@ -8020,27 +8783,484 @@ var readBoundedJson = (path, maxBytes, name = "configuration file") => Effect23.
|
|
|
8020
8783
|
return yield* refuse("file-changed", `${name[0].toUpperCase()}${name.slice(1)} changed`);
|
|
8021
8784
|
return yield* step(async () => JSON.parse(bytes.toString("utf8")));
|
|
8022
8785
|
});
|
|
8023
|
-
var provideLivePorts = (program) => program.pipe(
|
|
8786
|
+
var provideLivePorts = (program) => program.pipe(Effect27.provideService(ReleaseConfig, {
|
|
8024
8787
|
env: process.env,
|
|
8025
8788
|
platform: process.platform,
|
|
8026
8789
|
arch: process.arch,
|
|
8027
8790
|
cwd: process.cwd()
|
|
8028
|
-
}),
|
|
8791
|
+
}), Effect27.provideService(ReleaseOutput, {
|
|
8029
8792
|
stdout: (text) => void process.stdout.write(text),
|
|
8030
8793
|
stderr: (text) => void process.stderr.write(text)
|
|
8031
|
-
}),
|
|
8794
|
+
}), Effect27.provideService(ReleaseGit, { run: gitRun }), Effect27.provideService(ReleaseGitHub, { run: ghRun, withEnvironment: ghRunWith }), Effect27.provideService(ReleaseFetch, { fetch }), Effect27.provideService(ReleaseClock, {
|
|
8032
8795
|
sleep: (milliseconds) => Bun.sleep(milliseconds),
|
|
8033
8796
|
now: () => new Date().toISOString()
|
|
8034
|
-
}),
|
|
8797
|
+
}), Effect27.provideService(ReleaseFs, nodeFs), Effect27.provideService(ReleaseSigning, {
|
|
8035
8798
|
privateKey: environmentKey(process.env),
|
|
8036
8799
|
codesign: codesignRun
|
|
8037
8800
|
}));
|
|
8038
8801
|
|
|
8802
|
+
// src/commands/prepare-stable-catalog.ts
|
|
8803
|
+
import { createHash as createHash17 } from "crypto";
|
|
8804
|
+
import { createReadStream } from "fs";
|
|
8805
|
+
import { lstat as lstat20, mkdir as mkdir12, readFile as readFile11, rm as rm11, writeFile as writeFile12 } from "fs/promises";
|
|
8806
|
+
import { basename as basename16, dirname as dirname15, join as join37 } from "path";
|
|
8807
|
+
|
|
8808
|
+
// src/library/stable-catalogs.ts
|
|
8809
|
+
function object(value) {
|
|
8810
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
8811
|
+
throw new Error("Expected a JSON object");
|
|
8812
|
+
return value;
|
|
8813
|
+
}
|
|
8814
|
+
function requireText(value, label, pattern) {
|
|
8815
|
+
if (typeof value !== "string" || value.length < 1 || value.length > 200 || Array.from(value).some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127) || pattern && !pattern.test(value))
|
|
8816
|
+
throw new Error(`Invalid ${label}`);
|
|
8817
|
+
return value;
|
|
8818
|
+
}
|
|
8819
|
+
function requireHttps(value, label) {
|
|
8820
|
+
const url = new URL(requireText(value, label));
|
|
8821
|
+
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash)
|
|
8822
|
+
throw new Error(`Expected canonical HTTPS URL for ${label}`);
|
|
8823
|
+
return url;
|
|
8824
|
+
}
|
|
8825
|
+
var sha = (value) => requireText(value, "SHA-256", /^[a-f0-9]{64}$/);
|
|
8826
|
+
var source = (value) => requireText(value, "source SHA", /^[a-f0-9]{40}$/);
|
|
8827
|
+
var file = (value) => requireText(value, "asset name", /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/);
|
|
8828
|
+
var quoted = JSON.stringify;
|
|
8829
|
+
var ruby = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
|
|
8830
|
+
function asset(value) {
|
|
8831
|
+
const row = object(value);
|
|
8832
|
+
const size = row.size;
|
|
8833
|
+
if (typeof size !== "number" || !Number.isSafeInteger(size) || size <= 0)
|
|
8834
|
+
throw new Error("Invalid asset size");
|
|
8835
|
+
return { name: file(row.name), size, sha256: sha(row.sha256) };
|
|
8836
|
+
}
|
|
8837
|
+
function select(value, name, tag, stable = false) {
|
|
8838
|
+
const doc = object(value);
|
|
8839
|
+
if (doc.tag !== tag || !Array.isArray(doc.assets) || stable && doc.channel !== "stable")
|
|
8840
|
+
throw new Error(stable ? "Expected matching Stable pointer" : "Expected exact asset manifest");
|
|
8841
|
+
const matching = doc.assets.filter((row) => object(row).name === name);
|
|
8842
|
+
if (matching.length !== 1)
|
|
8843
|
+
throw new Error("Expected exactly one matching installer asset");
|
|
8844
|
+
return asset(matching[0]);
|
|
8845
|
+
}
|
|
8846
|
+
function equal(actual, expected) {
|
|
8847
|
+
return actual.name === expected.name && actual.size === expected.size && actual.sha256 === expected.sha256;
|
|
8848
|
+
}
|
|
8849
|
+
function requireChecks(receipt, keys) {
|
|
8850
|
+
if (keys.some((key) => receipt[key] !== true))
|
|
8851
|
+
throw new Error("Missing required native signing, install, launch, upgrade or manager proof");
|
|
8852
|
+
}
|
|
8853
|
+
function prepareStableCatalog(input) {
|
|
8854
|
+
const { channel, phase, measuredAsset } = input;
|
|
8855
|
+
if (channel !== "homebrew" && channel !== "winget" || phase !== "preflight" && phase !== "published-stable")
|
|
8856
|
+
throw new Error("Invalid catalog channel or release phase");
|
|
8857
|
+
const config = object(input.config);
|
|
8858
|
+
const name = requireText(config.name, "product name");
|
|
8859
|
+
const desc = requireText(config.description, "description");
|
|
8860
|
+
const homepage = requireHttps(config.homepage, "homepage").href;
|
|
8861
|
+
const base = requireHttps(config.releaseBase, "release base");
|
|
8862
|
+
if (!base.pathname.endsWith("/"))
|
|
8863
|
+
throw new Error("Expected release base directory URL");
|
|
8864
|
+
const channelConfig = object(config[channel]);
|
|
8865
|
+
const receipt = object(input.receipt);
|
|
8866
|
+
const tag = requireText(receipt.tag, "release tag", /^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/);
|
|
8867
|
+
if (receipt.schema !== "stable-catalog.v1" || receipt.channel !== channel)
|
|
8868
|
+
throw new Error("Wrong qualification receipt");
|
|
8869
|
+
if (source(receipt.sourceSha) !== source(input.expectedSourceSha))
|
|
8870
|
+
throw new Error("Receipt source differs from the protected candidate source");
|
|
8871
|
+
const template = requireText(channelConfig.artifact, "asset template", /^[A-Za-z0-9][A-Za-z0-9._-]*\{tag\}[A-Za-z0-9._-]*$/);
|
|
8872
|
+
const assetName = file(template.replace("{tag}", tag));
|
|
8873
|
+
if (!assetName.endsWith(channel === "homebrew" ? ".dmg" : ".zip"))
|
|
8874
|
+
throw new Error("Wrong installer format");
|
|
8875
|
+
const staged = select(input.manifest, assetName, tag);
|
|
8876
|
+
if (!equal(staged, asset(measuredAsset)) || !equal(staged, asset(receipt.asset)))
|
|
8877
|
+
throw new Error("Digest or size disagrees across installer bytes, manifest and receipt");
|
|
8878
|
+
if (phase === "published-stable" && !equal(staged, select(input.stablePointer, assetName, tag, true)))
|
|
8879
|
+
throw new Error("Stable pointer disagrees with installer release manifest");
|
|
8880
|
+
const version = tag.slice(1);
|
|
8881
|
+
const url = new URL(`${tag}/${assetName}`, base).href;
|
|
8882
|
+
requireChecks(receipt, [
|
|
8883
|
+
"freshInstall",
|
|
8884
|
+
"launch",
|
|
8885
|
+
"upgrade",
|
|
8886
|
+
"profileRetained",
|
|
8887
|
+
"managerOwnsUpdates"
|
|
8888
|
+
]);
|
|
8889
|
+
if (channel === "homebrew") {
|
|
8890
|
+
requireChecks(receipt, ["developerId", "notarized"]);
|
|
8891
|
+
if (receipt.platform !== "macos-arm64")
|
|
8892
|
+
throw new Error("Wrong macOS qualification platform");
|
|
8893
|
+
const token = requireText(channelConfig.token, "cask token", /^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
8894
|
+
const bundle = requireText(channelConfig.bundle, "app bundle", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.app$/);
|
|
8895
|
+
return [
|
|
8896
|
+
{
|
|
8897
|
+
path: `Casks/${token}.rb`,
|
|
8898
|
+
contents: `cask ${ruby(token)} do
|
|
8899
|
+
version ${ruby(version)}
|
|
8900
|
+
sha256 ${ruby(staged.sha256)}
|
|
8901
|
+
|
|
8902
|
+
url ${ruby(url)}
|
|
8903
|
+
name ${ruby(name)}
|
|
8904
|
+
desc ${ruby(desc)}
|
|
8905
|
+
homepage ${ruby(homepage)}
|
|
8906
|
+
|
|
8907
|
+
depends_on arch: :arm64
|
|
8908
|
+
|
|
8909
|
+
app ${ruby(bundle)}
|
|
8910
|
+
end
|
|
8911
|
+
`
|
|
8912
|
+
}
|
|
8913
|
+
];
|
|
8914
|
+
}
|
|
8915
|
+
requireChecks(receipt, ["authenticode", "windows11", "windows10", "unattended", "uninstall"]);
|
|
8916
|
+
if (receipt.platform !== "windows-x64")
|
|
8917
|
+
throw new Error("Wrong Windows qualification platform");
|
|
8918
|
+
const id = requireText(channelConfig.identifier, "WinGet package identifier", /^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/);
|
|
8919
|
+
const publisher = requireText(channelConfig.publisher, "WinGet publisher");
|
|
8920
|
+
const license = requireText(channelConfig.license, "license");
|
|
8921
|
+
const exe = requireText(receipt.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
|
|
8922
|
+
const flags = /^[-/][a-zA-Z0-9_-]+(?: [-/][a-zA-Z0-9_-]+)*$/;
|
|
8923
|
+
const silent = requireText(receipt.silent, "silent flags", flags);
|
|
8924
|
+
const progress = requireText(receipt.silentWithProgress, "silent progress flags", flags);
|
|
8925
|
+
const schemaVersion = "1.12.0";
|
|
8926
|
+
const path = `manifests/${id[0].toLowerCase()}/${id.replaceAll(".", "/")}/${version}/${id}`;
|
|
8927
|
+
const manifest = (type, body) => `# yaml-language-server: $schema=https://aka.ms/winget-manifest.${type}.${schemaVersion}.schema.json
|
|
8928
|
+
PackageIdentifier: ${quoted(id)}
|
|
8929
|
+
PackageVersion: ${quoted(version)}
|
|
8930
|
+
${body}ManifestType: ${type}
|
|
8931
|
+
ManifestVersion: ${schemaVersion}
|
|
8932
|
+
`;
|
|
8933
|
+
return [
|
|
8934
|
+
{ path: `${path}.yaml`, contents: manifest("version", `DefaultLocale: en-US
|
|
8935
|
+
`) },
|
|
8936
|
+
{
|
|
8937
|
+
path: `${path}.installer.yaml`,
|
|
8938
|
+
contents: manifest("installer", `InstallerType: zip
|
|
8939
|
+
NestedInstallerType: exe
|
|
8940
|
+
NestedInstallerFiles:
|
|
8941
|
+
- RelativeFilePath: ${quoted(exe)}
|
|
8942
|
+
InstallerSwitches:
|
|
8943
|
+
Silent: ${quoted(silent)}
|
|
8944
|
+
SilentWithProgress: ${quoted(progress)}
|
|
8945
|
+
Installers:
|
|
8946
|
+
- Architecture: x64
|
|
8947
|
+
InstallerUrl: ${quoted(url)}
|
|
8948
|
+
InstallerSha256: ${staged.sha256.toUpperCase()}
|
|
8949
|
+
`)
|
|
8950
|
+
},
|
|
8951
|
+
{
|
|
8952
|
+
path: `${path}.locale.en-US.yaml`,
|
|
8953
|
+
contents: manifest("defaultLocale", `PackageLocale: en-US
|
|
8954
|
+
Publisher: ${quoted(publisher)}
|
|
8955
|
+
PublisherUrl: ${quoted(homepage)}
|
|
8956
|
+
PackageName: ${quoted(name)}
|
|
8957
|
+
PackageUrl: ${quoted(homepage)}
|
|
8958
|
+
License: ${quoted(license)}
|
|
8959
|
+
ShortDescription: ${quoted(desc)}
|
|
8960
|
+
`)
|
|
8961
|
+
}
|
|
8962
|
+
];
|
|
8963
|
+
}
|
|
8964
|
+
|
|
8965
|
+
// src/commands/prepare-stable-catalog.ts
|
|
8966
|
+
var read2 = async (path) => {
|
|
8967
|
+
const stat = await lstat20(path);
|
|
8968
|
+
if (!stat.isFile() || stat.size > 1024 * 1024)
|
|
8969
|
+
throw new Error("Expected bounded ordinary JSON file");
|
|
8970
|
+
return JSON.parse(await readFile11(path, "utf8"));
|
|
8971
|
+
};
|
|
8972
|
+
async function prepareStableCatalogCommand(args) {
|
|
8973
|
+
const [
|
|
8974
|
+
channel,
|
|
8975
|
+
phase,
|
|
8976
|
+
expectedSourceSha,
|
|
8977
|
+
configPath,
|
|
8978
|
+
receiptPath,
|
|
8979
|
+
manifestPath,
|
|
8980
|
+
artifact,
|
|
8981
|
+
out,
|
|
8982
|
+
stablePointerPath,
|
|
8983
|
+
...extra
|
|
8984
|
+
] = args;
|
|
8985
|
+
if (channel !== "homebrew" && channel !== "winget" || phase !== "preflight" && phase !== "published-stable" || !expectedSourceSha || !configPath || !receiptPath || !manifestPath || !artifact || !out || extra.length || phase === "published-stable" !== Boolean(stablePointerPath))
|
|
8986
|
+
throw new Error("Expected channel, phase, source SHA, config, receipt, manifest, archive, new output directory [stable pointer]");
|
|
8987
|
+
const st = await lstat20(artifact);
|
|
8988
|
+
if (!st.isFile())
|
|
8989
|
+
throw new Error("Expected ordinary installer file");
|
|
8990
|
+
const hash = createHash17("sha256");
|
|
8991
|
+
for await (const chunk of createReadStream(artifact))
|
|
8992
|
+
hash.update(chunk);
|
|
8993
|
+
const files = prepareStableCatalog({
|
|
8994
|
+
channel,
|
|
8995
|
+
phase,
|
|
8996
|
+
expectedSourceSha,
|
|
8997
|
+
config: await read2(configPath),
|
|
8998
|
+
receipt: await read2(receiptPath),
|
|
8999
|
+
manifest: await read2(manifestPath),
|
|
9000
|
+
stablePointer: stablePointerPath && await read2(stablePointerPath),
|
|
9001
|
+
measuredAsset: { name: basename16(artifact), size: st.size, sha256: hash.digest("hex") }
|
|
9002
|
+
});
|
|
9003
|
+
await mkdir12(out);
|
|
9004
|
+
try {
|
|
9005
|
+
for (const entry of files) {
|
|
9006
|
+
const target = join37(out, entry.path);
|
|
9007
|
+
await mkdir12(dirname15(target), { recursive: true });
|
|
9008
|
+
await writeFile12(target, entry.contents, { flag: "wx" });
|
|
9009
|
+
}
|
|
9010
|
+
return { channel, phase, files: files.length };
|
|
9011
|
+
} catch (error) {
|
|
9012
|
+
await rm11(out, { recursive: true, force: true });
|
|
9013
|
+
throw error;
|
|
9014
|
+
}
|
|
9015
|
+
}
|
|
9016
|
+
|
|
9017
|
+
// src/library/apt/stage-apt-repository.ts
|
|
9018
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
9019
|
+
import { mkdir as mkdir13, readFile as readFile12, rm as rm12, writeFile as writeFile13 } from "fs/promises";
|
|
9020
|
+
import { dirname as dirname16, isAbsolute as isAbsolute6, join as join38 } from "path";
|
|
9021
|
+
|
|
9022
|
+
// src/library/apt/apt-metadata.ts
|
|
9023
|
+
import { createHash as createHash18 } from "crypto";
|
|
9024
|
+
import { gzipSync } from "zlib";
|
|
9025
|
+
var sha256 = (data) => createHash18("sha256").update(data).digest("hex");
|
|
9026
|
+
function stageAptMetadata({ policy, tag, assets, deb, control, now }) {
|
|
9027
|
+
if (!/^v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$/.test(tag))
|
|
9028
|
+
throw new Error("Invalid release tag");
|
|
9029
|
+
const { packageName, architecture, assetName: name, suite, origin } = policy;
|
|
9030
|
+
if (!/^[a-z][a-z0-9+.-]{1,62}$/.test(packageName) || architecture !== "amd64" && architecture !== "arm64" || !/^[A-Za-z0-9][A-Za-z0-9_.+-]*\.deb$/.test(name) || suite !== "daily" && suite !== "stable" || !/^[A-Za-z0-9][A-Za-z0-9 .+_-]{0,62}$/.test(origin))
|
|
9031
|
+
throw new Error("Invalid Debian repository policy");
|
|
9032
|
+
const matching = assets.filter((asset) => asset.name === name);
|
|
9033
|
+
if (matching.length !== 1)
|
|
9034
|
+
throw new Error("Require one staged Debian artifact");
|
|
9035
|
+
const asset = matching[0];
|
|
9036
|
+
if (!deb.length || asset.size !== deb.length || asset.sha256 !== sha256(deb))
|
|
9037
|
+
throw new Error("Staged Debian bytes do not match the verified release inventory");
|
|
9038
|
+
const fields = new Map;
|
|
9039
|
+
let lines = control.replaceAll(`\r
|
|
9040
|
+
`, `
|
|
9041
|
+
`).split(`
|
|
9042
|
+
`);
|
|
9043
|
+
if (lines.at(-1) === "")
|
|
9044
|
+
lines = lines.slice(0, -1);
|
|
9045
|
+
for (const [index, line] of lines.entries()) {
|
|
9046
|
+
if (/^[ \t]/.test(line) && index !== 0)
|
|
9047
|
+
continue;
|
|
9048
|
+
const field = /^([a-z][a-z0-9-]*):[ \t]*(.*)$/i.exec(line);
|
|
9049
|
+
if (!field || fields.has(field[1].toLowerCase()))
|
|
9050
|
+
throw new Error("Invalid or duplicate Debian control field");
|
|
9051
|
+
fields.set(field[1].toLowerCase(), field[2]);
|
|
9052
|
+
}
|
|
9053
|
+
for (const key of ["filename", "size", "md5sum", "sha1", "sha256", "sha512"])
|
|
9054
|
+
if (fields.has(key))
|
|
9055
|
+
throw new Error("Debian control includes repository-owned metadata");
|
|
9056
|
+
if (fields.get("package") !== packageName || fields.get("version") !== tag.slice(1) || fields.get("architecture") !== architecture || !fields.get("description"))
|
|
9057
|
+
throw new Error("Unexpected Debian package, version, architecture or description");
|
|
9058
|
+
if (!Number.isFinite(now.getTime()))
|
|
9059
|
+
throw new Error("Invalid release timestamp");
|
|
9060
|
+
const filename = `pool/main/${packageName[0]}/${packageName}/${name}`;
|
|
9061
|
+
const entries = `${lines.join(`
|
|
9062
|
+
`)}
|
|
9063
|
+
Filename: ${filename}
|
|
9064
|
+
Size: ${asset.size}
|
|
9065
|
+
SHA256: ${asset.sha256}
|
|
9066
|
+
|
|
9067
|
+
`;
|
|
9068
|
+
const plain = new TextEncoder().encode(entries);
|
|
9069
|
+
const compressed = gzipSync(plain);
|
|
9070
|
+
const directories = `main/binary-${architecture}`;
|
|
9071
|
+
const members = [
|
|
9072
|
+
[`${directories}/Packages`, plain],
|
|
9073
|
+
[`${directories}/Packages.gz`, compressed]
|
|
9074
|
+
];
|
|
9075
|
+
const release = [
|
|
9076
|
+
`Origin: ${origin}`,
|
|
9077
|
+
`Label: ${origin} ${suite}`,
|
|
9078
|
+
`Suite: ${suite}`,
|
|
9079
|
+
`Codename: ${suite}`,
|
|
9080
|
+
`Date: ${now.toUTCString()}`,
|
|
9081
|
+
`Valid-Until: ${new Date(now.getTime() + 30 * 86400000).toUTCString()}`,
|
|
9082
|
+
`Architectures: ${architecture}`,
|
|
9083
|
+
"Components: main",
|
|
9084
|
+
"Acquire-By-Hash: yes",
|
|
9085
|
+
"SHA256:",
|
|
9086
|
+
...members.map(([path, bytes]) => ` ${sha256(bytes)} ${bytes.length} ${path}`),
|
|
9087
|
+
""
|
|
9088
|
+
].join(`
|
|
9089
|
+
`);
|
|
9090
|
+
return {
|
|
9091
|
+
packagePath: filename,
|
|
9092
|
+
release,
|
|
9093
|
+
files: new Map([
|
|
9094
|
+
...members,
|
|
9095
|
+
...members.map(([, bytes]) => [`${directories}/by-hash/SHA256/${sha256(bytes)}`, bytes])
|
|
9096
|
+
])
|
|
9097
|
+
};
|
|
9098
|
+
}
|
|
9099
|
+
|
|
9100
|
+
// src/library/apt/stage-apt-repository.ts
|
|
9101
|
+
function cmd(program, options, label) {
|
|
9102
|
+
const run = spawnSync2(program, options, { encoding: "utf8", timeout: 60000 });
|
|
9103
|
+
if (run.error || run.status !== 0)
|
|
9104
|
+
throw new Error(label);
|
|
9105
|
+
return run.stdout;
|
|
9106
|
+
}
|
|
9107
|
+
async function add(path, bytes) {
|
|
9108
|
+
await mkdir13(dirname16(path), { recursive: true });
|
|
9109
|
+
await writeFile13(path, bytes, { flag: "wx" });
|
|
9110
|
+
}
|
|
9111
|
+
async function stageAptRepositoryCommand(args) {
|
|
9112
|
+
const [tag, policyPath, inventoryPath, packagePath, output, signingHome, trustedFingerprint] = args;
|
|
9113
|
+
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 || !isAbsolute6(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
|
|
9114
|
+
throw new Error("Expected TAG POLICY VERIFIED_INVENTORY DEB NEW_OUTPUT GPG_HOME PINNED_FINGERPRINT");
|
|
9115
|
+
const policy = JSON.parse(await readFile12(policyPath, "utf8"));
|
|
9116
|
+
const inventory = JSON.parse(await readFile12(inventoryPath, "utf8"));
|
|
9117
|
+
if (inventory.tag !== tag || !Array.isArray(inventory.assets))
|
|
9118
|
+
throw new Error("Verified inventory does not name requested release");
|
|
9119
|
+
const deb = await readFile12(packagePath);
|
|
9120
|
+
await mkdir13(output, { mode: 448 });
|
|
9121
|
+
try {
|
|
9122
|
+
const stagedInput = join38(output, ".input.deb");
|
|
9123
|
+
await writeFile13(stagedInput, deb, { mode: 384, flag: "wx" });
|
|
9124
|
+
const control = cmd("dpkg-deb", ["--field", stagedInput], "Debian control inspection failed");
|
|
9125
|
+
const staged = stageAptMetadata({
|
|
9126
|
+
policy,
|
|
9127
|
+
tag,
|
|
9128
|
+
assets: inventory.assets,
|
|
9129
|
+
deb,
|
|
9130
|
+
control,
|
|
9131
|
+
now: new Date
|
|
9132
|
+
});
|
|
9133
|
+
const base = join38(output, "dists", policy.suite);
|
|
9134
|
+
await add(join38(output, staged.packagePath), deb);
|
|
9135
|
+
for (const [path, contents] of staged.files)
|
|
9136
|
+
await add(join38(base, path), contents);
|
|
9137
|
+
await add(join38(base, "Release"), staged.release);
|
|
9138
|
+
const flags = [
|
|
9139
|
+
"--batch",
|
|
9140
|
+
"--no-tty",
|
|
9141
|
+
"--pinentry-mode",
|
|
9142
|
+
"error",
|
|
9143
|
+
"--homedir",
|
|
9144
|
+
signingHome,
|
|
9145
|
+
"--local-user",
|
|
9146
|
+
`${trustedFingerprint}!`,
|
|
9147
|
+
"--digest-algo",
|
|
9148
|
+
"SHA256"
|
|
9149
|
+
];
|
|
9150
|
+
for (const [name, mode] of [
|
|
9151
|
+
["InRelease", "--clearsign"],
|
|
9152
|
+
["Release.gpg", "--detach-sign"]
|
|
9153
|
+
]) {
|
|
9154
|
+
cmd("gpg", [...flags, "--armor", "--output", join38(base, name), mode, join38(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
|
|
9155
|
+
}
|
|
9156
|
+
const { unlink } = await import("fs/promises");
|
|
9157
|
+
await unlink(stagedInput);
|
|
9158
|
+
await add(join38(output, "STAGED"), `${tag}
|
|
9159
|
+
`);
|
|
9160
|
+
return { tag, staged: true };
|
|
9161
|
+
} catch (error) {
|
|
9162
|
+
await rm12(output, { recursive: true, force: true });
|
|
9163
|
+
throw error;
|
|
9164
|
+
}
|
|
9165
|
+
}
|
|
9166
|
+
|
|
9167
|
+
// src/linux-channel-proof-cli.ts
|
|
9168
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
9169
|
+
import { createHash as createHash19 } from "crypto";
|
|
9170
|
+
import { createReadStream as createReadStream2 } from "fs";
|
|
9171
|
+
import { lstat as lstat21, readFile as readFile13, realpath as realpath11 } from "fs/promises";
|
|
9172
|
+
import { join as join39 } from "path";
|
|
9173
|
+
import { pathToFileURL } from "url";
|
|
9174
|
+
function check(ok, message) {
|
|
9175
|
+
if (!ok)
|
|
9176
|
+
throw new Error(message);
|
|
9177
|
+
}
|
|
9178
|
+
async function hash(path) {
|
|
9179
|
+
check((await lstat21(path)).isFile(), "artifact must be a regular file");
|
|
9180
|
+
const digest = createHash19("sha256");
|
|
9181
|
+
for await (const chunk of createReadStream2(path))
|
|
9182
|
+
digest.update(chunk);
|
|
9183
|
+
return digest.digest("hex");
|
|
9184
|
+
}
|
|
9185
|
+
function options(text, section) {
|
|
9186
|
+
const values = new Map;
|
|
9187
|
+
let matched = false;
|
|
9188
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
9189
|
+
const line = raw.trim();
|
|
9190
|
+
if (!line || line.startsWith("#") || line.startsWith(";"))
|
|
9191
|
+
continue;
|
|
9192
|
+
if (line === `[${section}]` && !matched) {
|
|
9193
|
+
matched = true;
|
|
9194
|
+
continue;
|
|
9195
|
+
}
|
|
9196
|
+
const field = /^([a-z_]+)\s*=\s*(\S+)$/.exec(line);
|
|
9197
|
+
check(matched && field && !values.has(field[1]), "unexpected or duplicate repository option");
|
|
9198
|
+
values.set(field[1], field[2]);
|
|
9199
|
+
}
|
|
9200
|
+
check(matched, "expected exactly one repository section");
|
|
9201
|
+
return values;
|
|
9202
|
+
}
|
|
9203
|
+
async function verifyRpmStage(stage) {
|
|
9204
|
+
check(/^[0-9a-f]{40}$/.test(stage.sourceSha), "expected an exact source commit");
|
|
9205
|
+
check(/^[a-z0-9][a-z0-9._+-]*$/.test(stage.packageName), "invalid RPM package name");
|
|
9206
|
+
check(/^[a-zA-Z0-9][a-zA-Z0-9._+~^]*$/.test(stage.version), "invalid RPM version");
|
|
9207
|
+
check(stage.architecture === "x86_64", "only x86_64 is supported");
|
|
9208
|
+
check(/^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/.test(stage.repoId), "invalid repository ID");
|
|
9209
|
+
for (const artifact of [stage.payload, stage.rpm]) {
|
|
9210
|
+
check(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
|
|
9211
|
+
check(await hash(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
|
|
9212
|
+
}
|
|
9213
|
+
const repo = await realpath11(stage.repository);
|
|
9214
|
+
const keyUrl = pathToFileURL(await realpath11(stage.publicKey)).href;
|
|
9215
|
+
const config = options(await readFile13(stage.repoFile, "utf8"), stage.repoId);
|
|
9216
|
+
check(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
|
|
9217
|
+
check(config.get("gpgkey") === keyUrl, "expected the configured QA public key");
|
|
9218
|
+
for (const flag of ["pkg_gpgcheck", "repo_gpgcheck"]) {
|
|
9219
|
+
check(config.get(flag) === "1", `${flag} must be enabled`);
|
|
9220
|
+
}
|
|
9221
|
+
const allowed = new Set(["name", "enabled", "baseurl", "gpgkey", "pkg_gpgcheck", "repo_gpgcheck"]);
|
|
9222
|
+
check([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
|
|
9223
|
+
for (const path of [
|
|
9224
|
+
stage.publicKey,
|
|
9225
|
+
join39(repo, "repodata/repomd.xml"),
|
|
9226
|
+
join39(repo, "repodata/repomd.xml.asc")
|
|
9227
|
+
]) {
|
|
9228
|
+
check((await lstat21(path)).isFile(), "expected regular key and signed metadata files");
|
|
9229
|
+
}
|
|
9230
|
+
const result = spawnSync3("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath11(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
|
|
9231
|
+
check(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
|
|
9232
|
+
check(result.status === 0 && result.stdout === `${stage.packageName}|${stage.version}|${stage.architecture}`, "RPM header does not match the requested package, version and architecture");
|
|
9233
|
+
return { kind: "rpm-staging-inputs", sourceSha: stage.sourceSha };
|
|
9234
|
+
}
|
|
9235
|
+
var systemTalkDenied = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
|
|
9236
|
+
function verifyFlatpakCapabilities(policy, result) {
|
|
9237
|
+
check(/^[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");
|
|
9238
|
+
check(/^[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");
|
|
9239
|
+
check(result.architecture === "x86_64", "only x86_64 is supported");
|
|
9240
|
+
const cap = policy.permissions;
|
|
9241
|
+
const actual = result.effectivePermissions;
|
|
9242
|
+
check(cap.sockets.every((name) => name === "wayland" || name === "pulseaudio"), "unsafe socket policy");
|
|
9243
|
+
check(cap.devices.every((name) => name === "dri"), "unsafe device policy");
|
|
9244
|
+
check(cap.sessionTalkNames.every((name) => /^[A-Za-z_][\w-]*(\.[A-Za-z_][\w-]*)+$/.test(name) && !systemTalkDenied.test(name)), "unsafe session-bus policy");
|
|
9245
|
+
check(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");
|
|
9246
|
+
check([
|
|
9247
|
+
result.localRepositoryInstall,
|
|
9248
|
+
result.upgradedAndRetainedData,
|
|
9249
|
+
result.sandboxedRenderer,
|
|
9250
|
+
result.portalSelectedWorkspace,
|
|
9251
|
+
result.sandboxTerminalAndCli,
|
|
9252
|
+
result.unselectedWorkspaceDenied,
|
|
9253
|
+
result.hostCredentialsDenied,
|
|
9254
|
+
result.genericHostExecutionDenied
|
|
9255
|
+
].every((outcome) => outcome === true), "missing a required Flatpak capability or isolation observation");
|
|
9256
|
+
return { kind: "flatpak-observations", sourceSha: result.sourceSha };
|
|
9257
|
+
}
|
|
9258
|
+
|
|
8039
9259
|
// src/library/arch-publish.ts
|
|
8040
|
-
import { createHash as
|
|
8041
|
-
import { join as
|
|
9260
|
+
import { createHash as createHash20 } from "crypto";
|
|
9261
|
+
import { join as join40 } from "path";
|
|
8042
9262
|
import { tmpdir as tmpdir5 } from "os";
|
|
8043
|
-
import { Effect as
|
|
9263
|
+
import { Effect as Effect28 } from "effect";
|
|
8044
9264
|
|
|
8045
9265
|
// ../../src/release/arch-package.ts
|
|
8046
9266
|
function archPkgver(tag) {
|
|
@@ -8221,7 +9441,7 @@ exec pacman -S --needed --noconfirm "$@"
|
|
|
8221
9441
|
// src/library/arch-publish.ts
|
|
8222
9442
|
var AUR_HOST_KEY = "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN";
|
|
8223
9443
|
var MAX_LICENSE_BYTES = 1024 * 1024;
|
|
8224
|
-
var feedBytes = (feed, path, maximum) =>
|
|
9444
|
+
var feedBytes = (feed, path, maximum) => Effect28.gen(function* () {
|
|
8225
9445
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
8226
9446
|
const scope = feedUrl(feed);
|
|
8227
9447
|
const response = yield* step(() => fetchReleaseLocation(`${scope}${path}`, scope, fetch2, AbortSignal.timeout(30000)));
|
|
@@ -8231,7 +9451,7 @@ var feedBytes = (feed, path, maximum) => Effect24.gen(function* () {
|
|
|
8231
9451
|
}
|
|
8232
9452
|
return yield* step(() => readReleaseBytes(response, maximum));
|
|
8233
9453
|
});
|
|
8234
|
-
var feedJson = (feed, path, maximum) =>
|
|
9454
|
+
var feedJson = (feed, path, maximum) => Effect28.gen(function* () {
|
|
8235
9455
|
const bytes = yield* feedBytes(feed, path, maximum);
|
|
8236
9456
|
if (!bytes)
|
|
8237
9457
|
return null;
|
|
@@ -8243,13 +9463,13 @@ var feedJson = (feed, path, maximum) => Effect24.gen(function* () {
|
|
|
8243
9463
|
}
|
|
8244
9464
|
});
|
|
8245
9465
|
});
|
|
8246
|
-
var readChannelTag = (feed, channel) =>
|
|
9466
|
+
var readChannelTag = (feed, channel) => Effect28.gen(function* () {
|
|
8247
9467
|
const parsed = yield* feedJson(feed, `channels/${channel}.json`, 262144);
|
|
8248
9468
|
if (parsed === null)
|
|
8249
9469
|
return null;
|
|
8250
9470
|
return yield* step(async () => parseFeedRelease(parsed).tag);
|
|
8251
9471
|
});
|
|
8252
|
-
var readLicense = (url) =>
|
|
9472
|
+
var readLicense = (url) => Effect28.gen(function* () {
|
|
8253
9473
|
const { fetch: fetch2 } = yield* ReleaseFetch;
|
|
8254
9474
|
const response = yield* step(() => fetch2(url, { redirect: "follow", signal: AbortSignal.timeout(30000) }));
|
|
8255
9475
|
if (response.status !== 200 || !response.body) {
|
|
@@ -8257,12 +9477,12 @@ var readLicense = (url) => Effect24.gen(function* () {
|
|
|
8257
9477
|
return yield* fail("Release license is unavailable");
|
|
8258
9478
|
}
|
|
8259
9479
|
const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
|
|
8260
|
-
const sha256 = yield* step(async () =>
|
|
9480
|
+
const sha256 = yield* step(async () => createHash20("sha256").update(bytes).digest("hex"));
|
|
8261
9481
|
return { url, sha256 };
|
|
8262
9482
|
});
|
|
8263
|
-
var git2 = (args) =>
|
|
9483
|
+
var git2 = (args) => Effect28.gen(function* () {
|
|
8264
9484
|
const { run } = yield* ReleaseGit;
|
|
8265
|
-
return yield*
|
|
9485
|
+
return yield* Effect28.tryPromise({
|
|
8266
9486
|
try: () => run(args),
|
|
8267
9487
|
catch: (error) => {
|
|
8268
9488
|
const stderr = String(error.stderr ?? "").trim().split(`
|
|
@@ -8275,11 +9495,11 @@ var git2 = (args) => Effect24.gen(function* () {
|
|
|
8275
9495
|
}
|
|
8276
9496
|
});
|
|
8277
9497
|
});
|
|
8278
|
-
var gitExit = (args) =>
|
|
9498
|
+
var gitExit = (args) => Effect28.gen(function* () {
|
|
8279
9499
|
const { run } = yield* ReleaseGit;
|
|
8280
|
-
return yield*
|
|
9500
|
+
return yield* Effect28.promise(() => run(args).then(() => 0, (error) => Number(error.code ?? 1) || 1));
|
|
8281
9501
|
});
|
|
8282
|
-
var verifyArchRelease = (options) =>
|
|
9502
|
+
var verifyArchRelease = (options) => Effect28.gen(function* () {
|
|
8283
9503
|
const parsed = parseReleaseConfig(options.config);
|
|
8284
9504
|
const { config } = options;
|
|
8285
9505
|
const repository = typeof config.repository === "string" && isRepositorySlug(config.repository) ? config.repository : null;
|
|
@@ -8299,7 +9519,7 @@ var verifyArchRelease = (options) => Effect24.gen(function* () {
|
|
|
8299
9519
|
if (!listed)
|
|
8300
9520
|
return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
|
|
8301
9521
|
const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
|
|
8302
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
9522
|
+
if (!bytes || bytes.length !== listed.size || createHash20("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
8303
9523
|
return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
|
|
8304
9524
|
const json = yield* step(async () => {
|
|
8305
9525
|
try {
|
|
@@ -8329,7 +9549,7 @@ var verifyArchRelease = (options) => Effect24.gen(function* () {
|
|
|
8329
9549
|
return yield* fail("Signed descriptor does not bind the published archive");
|
|
8330
9550
|
return descriptor.asset;
|
|
8331
9551
|
});
|
|
8332
|
-
var publishArchPackageEffect = (options) =>
|
|
9552
|
+
var publishArchPackageEffect = (options) => Effect28.gen(function* () {
|
|
8333
9553
|
const { archPackage: policy, feed } = parseReleaseConfig(options.config);
|
|
8334
9554
|
if (!policy)
|
|
8335
9555
|
return { status: "not-configured" };
|
|
@@ -8371,7 +9591,7 @@ var publishArchPackageEffect = (options) => Effect24.gen(function* () {
|
|
|
8371
9591
|
const directory = options.printDirectory;
|
|
8372
9592
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
8373
9593
|
for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
|
|
8374
|
-
yield* step(() => fs.writeFile(
|
|
9594
|
+
yield* step(() => fs.writeFile(join40(directory, name), contents, { mode: 420 }));
|
|
8375
9595
|
}
|
|
8376
9596
|
const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
|
|
8377
9597
|
if (options.dryRun)
|
|
@@ -8383,15 +9603,15 @@ var publishArchPackageEffect = (options) => Effect24.gen(function* () {
|
|
|
8383
9603
|
const key = Buffer.from(encodedKey, "base64").toString("utf8");
|
|
8384
9604
|
if (!key.includes("PRIVATE KEY"))
|
|
8385
9605
|
return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
|
|
8386
|
-
return yield*
|
|
8387
|
-
const work = yield* step(() => fs.mkdtemp(
|
|
8388
|
-
yield*
|
|
9606
|
+
return yield* Effect28.gen(function* () {
|
|
9607
|
+
const work = yield* step(() => fs.mkdtemp(join40(tmpdir5(), "arch-package-")));
|
|
9608
|
+
yield* Effect28.addFinalizer(() => Effect28.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
|
|
8389
9609
|
return;
|
|
8390
9610
|
}, () => {
|
|
8391
9611
|
return;
|
|
8392
9612
|
})));
|
|
8393
|
-
const keyFile =
|
|
8394
|
-
const knownHosts =
|
|
9613
|
+
const keyFile = join40(work, "aur_id_ed25519");
|
|
9614
|
+
const knownHosts = join40(work, "aur_known_hosts");
|
|
8395
9615
|
yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
|
|
8396
9616
|
yield* step(() => fs.writeFile(keyFile, key.endsWith(`
|
|
8397
9617
|
`) ? key : `${key}
|
|
@@ -8399,7 +9619,7 @@ var publishArchPackageEffect = (options) => Effect24.gen(function* () {
|
|
|
8399
9619
|
yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
|
|
8400
9620
|
`, { mode: 420 }));
|
|
8401
9621
|
const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
|
|
8402
|
-
const checkout =
|
|
9622
|
+
const checkout = join40(work, policy.pkgname);
|
|
8403
9623
|
yield* git2([
|
|
8404
9624
|
"-c",
|
|
8405
9625
|
`core.sshCommand=${ssh}`,
|
|
@@ -8412,7 +9632,7 @@ var publishArchPackageEffect = (options) => Effect24.gen(function* () {
|
|
|
8412
9632
|
checkout
|
|
8413
9633
|
]);
|
|
8414
9634
|
for (const [name, contents] of Object.entries(files))
|
|
8415
|
-
yield* step(() => fs.writeFile(
|
|
9635
|
+
yield* step(() => fs.writeFile(join40(checkout, name), contents, { mode: 420 }));
|
|
8416
9636
|
yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
|
|
8417
9637
|
const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
|
|
8418
9638
|
if (staged === 0)
|
|
@@ -8433,35 +9653,35 @@ var publishArchPackageEffect = (options) => Effect24.gen(function* () {
|
|
|
8433
9653
|
]);
|
|
8434
9654
|
yield* git2(["-C", checkout, "-c", `core.sshCommand=${ssh}`, "push", "origin", "HEAD:master"]);
|
|
8435
9655
|
return { status: "published", ...base };
|
|
8436
|
-
}).pipe(
|
|
9656
|
+
}).pipe(Effect28.scoped);
|
|
8437
9657
|
});
|
|
8438
9658
|
|
|
8439
9659
|
// src/cli-commands.ts
|
|
8440
|
-
var print = (value) =>
|
|
9660
|
+
var print = (value) => Effect29.gen(function* () {
|
|
8441
9661
|
const { stdout } = yield* ReleaseOutput;
|
|
8442
9662
|
stdout(JSON.stringify(value) + `
|
|
8443
9663
|
`);
|
|
8444
9664
|
});
|
|
8445
|
-
var say = (line) =>
|
|
9665
|
+
var say = (line) => Effect29.gen(function* () {
|
|
8446
9666
|
const { stdout } = yield* ReleaseOutput;
|
|
8447
9667
|
stdout(line + `
|
|
8448
9668
|
`);
|
|
8449
9669
|
});
|
|
8450
9670
|
var invalid = (message = "Invalid workflow invocation") => refuse("usage", message);
|
|
8451
9671
|
var localFlag = (args) => args[0] === "--local" ? [true, args.slice(1)] : [false, args];
|
|
8452
|
-
var hostPlatform =
|
|
9672
|
+
var hostPlatform = Effect29.gen(function* () {
|
|
8453
9673
|
const { platform, arch } = yield* ReleaseConfig;
|
|
8454
9674
|
return yield* step(async () => hostReleasePlatform(platform, arch));
|
|
8455
9675
|
});
|
|
8456
|
-
var withPlanGitHub = (env, effect) =>
|
|
9676
|
+
var withPlanGitHub = (env, effect) => Effect29.gen(function* () {
|
|
8457
9677
|
const github = yield* ReleaseGitHub;
|
|
8458
|
-
return yield* effect.pipe(
|
|
9678
|
+
return yield* effect.pipe(Effect29.provideService(ReleaseGitHub, {
|
|
8459
9679
|
run: github.withEnvironment ? github.withEnvironment(releasePlanGitHubEnvironment(env)) : github.run
|
|
8460
9680
|
}));
|
|
8461
9681
|
});
|
|
8462
9682
|
var publish = (argv) => {
|
|
8463
9683
|
const [local, args] = localFlag(argv);
|
|
8464
|
-
return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.",
|
|
9684
|
+
return runCommand("Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.", Effect29.gen(function* () {
|
|
8465
9685
|
const [directory, configPath, out, ...extra] = args;
|
|
8466
9686
|
if (!directory || !configPath || extra.length || !out !== !local)
|
|
8467
9687
|
return yield* invalid();
|
|
@@ -8474,7 +9694,7 @@ var publish = (argv) => {
|
|
|
8474
9694
|
const clock = yield* ReleaseClock;
|
|
8475
9695
|
const platform = yield* hostPlatform;
|
|
8476
9696
|
const { repository } = yield* localTagProvenanceEffect({ config, tag, sourceSha });
|
|
8477
|
-
const plan = yield*
|
|
9697
|
+
const plan = yield* Effect29.uninterruptible(stageLocalReleaseEffect({
|
|
8478
9698
|
config,
|
|
8479
9699
|
directory,
|
|
8480
9700
|
out,
|
|
@@ -8492,7 +9712,7 @@ var publish = (argv) => {
|
|
|
8492
9712
|
};
|
|
8493
9713
|
var cut = (argv) => {
|
|
8494
9714
|
const [local, args] = localFlag(argv);
|
|
8495
|
-
return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`,
|
|
9715
|
+
return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect29.gen(function* () {
|
|
8496
9716
|
const [kind, path, sourceSha, ...extra] = args;
|
|
8497
9717
|
if (kind !== "daily" || !path || extra.length || !sourceSha !== !local)
|
|
8498
9718
|
return yield* invalid();
|
|
@@ -8502,7 +9722,7 @@ var cut = (argv) => {
|
|
|
8502
9722
|
const { env } = yield* ReleaseConfig;
|
|
8503
9723
|
if (local) {
|
|
8504
9724
|
const platform = yield* hostPlatform;
|
|
8505
|
-
const result = yield*
|
|
9725
|
+
const result = yield* Effect29.uninterruptible(runLocalReleaseCutEffect({ kind, config, sourceSha, platform }));
|
|
8506
9726
|
return yield* print(result);
|
|
8507
9727
|
}
|
|
8508
9728
|
const result = yield* releaseCutCommand({
|
|
@@ -8516,7 +9736,7 @@ var cut = (argv) => {
|
|
|
8516
9736
|
};
|
|
8517
9737
|
var promote = (argv) => {
|
|
8518
9738
|
const [local, args] = localFlag(argv);
|
|
8519
|
-
return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.",
|
|
9739
|
+
return runCommand("Unable to promote the release; check the trusted workflow or feed and release configuration.", Effect29.gen(function* () {
|
|
8520
9740
|
const [path, out, ...extra] = args;
|
|
8521
9741
|
const { env } = yield* ReleaseConfig;
|
|
8522
9742
|
const held = env.STABLE_PROMOTION_HELD;
|
|
@@ -8526,7 +9746,7 @@ var promote = (argv) => {
|
|
|
8526
9746
|
if (local) {
|
|
8527
9747
|
const clock = yield* ReleaseClock;
|
|
8528
9748
|
const repository = yield* originRepositoryEffect;
|
|
8529
|
-
const result = yield*
|
|
9749
|
+
const result = yield* Effect29.uninterruptible(runLocalPromotionEffect({
|
|
8530
9750
|
config,
|
|
8531
9751
|
out,
|
|
8532
9752
|
now: clock.now(),
|
|
@@ -8539,7 +9759,7 @@ var promote = (argv) => {
|
|
|
8539
9759
|
yield* print(yield* promotionCommand({ env, config }));
|
|
8540
9760
|
}), { requireGitHubActions: !local });
|
|
8541
9761
|
};
|
|
8542
|
-
var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`,
|
|
9762
|
+
var finalize = (argv) => runCommand((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
8543
9763
|
const { env } = yield* ReleaseConfig;
|
|
8544
9764
|
if (argv[0] === "--local") {
|
|
8545
9765
|
const [configPath, tag, ...extra] = argv.slice(1);
|
|
@@ -8560,7 +9780,7 @@ var finalize = (argv) => runCommand((error) => `Release finalization failed: ${r
|
|
|
8560
9780
|
yield* finalizeReleasePleaseDraftEffect({ env, config, ...identity });
|
|
8561
9781
|
yield* say("Qualified draft published as a prerelease");
|
|
8562
9782
|
}));
|
|
8563
|
-
var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.",
|
|
9783
|
+
var planAssets = (args) => runCommand("Unable to plan release assets; check release provenance and the trusted workflow.", Effect29.gen(function* () {
|
|
8564
9784
|
const [tag, path, ...extra] = args;
|
|
8565
9785
|
if (!tag || !path || extra.length)
|
|
8566
9786
|
return yield* invalid("Expected release tag and configuration file");
|
|
@@ -8568,7 +9788,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
|
|
|
8568
9788
|
const { env } = yield* ReleaseConfig;
|
|
8569
9789
|
yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
|
|
8570
9790
|
}));
|
|
8571
|
-
var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.",
|
|
9791
|
+
var sign2 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect29.gen(function* () {
|
|
8572
9792
|
const [identityPath, artifactPath, feed, ...extra] = args;
|
|
8573
9793
|
const { env } = yield* ReleaseConfig;
|
|
8574
9794
|
if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
|
|
@@ -8579,7 +9799,7 @@ var sign2 = (args) => runCommand("Unable to sign release artifact; check the ide
|
|
|
8579
9799
|
}));
|
|
8580
9800
|
var signDescriptors = (argv) => {
|
|
8581
9801
|
const [local, args] = localFlag(argv);
|
|
8582
|
-
return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.",
|
|
9802
|
+
return runCommand("Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.", Effect29.gen(function* () {
|
|
8583
9803
|
const [directory, configPath, ...extra] = args;
|
|
8584
9804
|
const { env } = yield* ReleaseConfig;
|
|
8585
9805
|
const {
|
|
@@ -8612,7 +9832,7 @@ var signDescriptors = (argv) => {
|
|
|
8612
9832
|
}));
|
|
8613
9833
|
}));
|
|
8614
9834
|
};
|
|
8615
|
-
var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`,
|
|
9835
|
+
var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.message}`, Effect29.gen(function* () {
|
|
8616
9836
|
const args = [...argv];
|
|
8617
9837
|
const flag = args.indexOf("--artifacts");
|
|
8618
9838
|
const artifacts = flag === -1 ? undefined : args.splice(flag, 2)[1];
|
|
@@ -8664,9 +9884,9 @@ var releaseStep = (argv) => runCommand((error) => `Release step failed: ${error.
|
|
|
8664
9884
|
return yield* invalid(`Unknown release step ${String(name)}`);
|
|
8665
9885
|
}
|
|
8666
9886
|
}));
|
|
8667
|
-
var verifyMacosSigning = (args) =>
|
|
9887
|
+
var verifyMacosSigning = (args) => Effect29.gen(function* () {
|
|
8668
9888
|
let problems = 0;
|
|
8669
|
-
const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.",
|
|
9889
|
+
const code = yield* runCommand("Unable to check the app signing; run it on macOS with codesign.", Effect29.gen(function* () {
|
|
8670
9890
|
const [app, flag, ...extra] = args;
|
|
8671
9891
|
if (!app || extra.length || ![undefined, "--hardened"].includes(flag))
|
|
8672
9892
|
return yield* invalid("usage");
|
|
@@ -8679,14 +9899,14 @@ var verifyMacosSigning = (args) => Effect25.gen(function* () {
|
|
|
8679
9899
|
}));
|
|
8680
9900
|
return code || (problems ? 1 : 0);
|
|
8681
9901
|
});
|
|
8682
|
-
var publishFramework = (args) => runCommand((error) => error.message,
|
|
9902
|
+
var publishFramework = (args) => runCommand((error) => error.message, Effect29.gen(function* () {
|
|
8683
9903
|
const [archive, flag, ...extra] = args;
|
|
8684
9904
|
if (!archive || extra.length || flag !== undefined && flag !== "--dry-run")
|
|
8685
9905
|
return yield* invalid("Expected one framework package archive and an optional --dry-run");
|
|
8686
9906
|
const { env } = yield* ReleaseConfig;
|
|
8687
9907
|
yield* print(yield* step(() => publishFrameworkPackage({ env, archive, dryRun: flag === "--dry-run" })));
|
|
8688
9908
|
}));
|
|
8689
|
-
var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`,
|
|
9909
|
+
var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch package: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
8690
9910
|
const args = [...argv];
|
|
8691
9911
|
const printIndex = args.indexOf("--print");
|
|
8692
9912
|
const printDirectory = printIndex === -1 ? undefined : args[printIndex + 1];
|
|
@@ -8721,16 +9941,89 @@ var publishArch = (argv) => runCommand((error) => `Unable to publish the Arch pa
|
|
|
8721
9941
|
...printDirectory ? { printDirectory } : {}
|
|
8722
9942
|
}));
|
|
8723
9943
|
}));
|
|
9944
|
+
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* () {
|
|
9945
|
+
const [action, configPath, ...operands] = args;
|
|
9946
|
+
if (!configPath)
|
|
9947
|
+
return yield* invalid();
|
|
9948
|
+
if (action === "plan" && operands.length === 1) {
|
|
9949
|
+
const config = yield* readReleaseConfig(configPath);
|
|
9950
|
+
const matrix = yield* step(async () => planDailyReleaseMatrix(config, operands[0]));
|
|
9951
|
+
return yield* print(matrix);
|
|
9952
|
+
}
|
|
9953
|
+
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)))
|
|
9954
|
+
return yield* invalid();
|
|
9955
|
+
const [identityPath, artifacts, receipts, parent, baselineArtifacts] = operands;
|
|
9956
|
+
const raw = yield* readBoundedJson(identityPath, 4096, "Daily identity");
|
|
9957
|
+
if (!isRecord(raw) || typeof raw.tag !== "string" || typeof raw.sourceSha !== "string" || typeof raw.workflowSha !== "string" || typeof raw.runId !== "string" || typeof raw.runAttempt !== "number")
|
|
9958
|
+
return yield* invalid();
|
|
9959
|
+
const { tag, sourceSha, workflowSha, runId, runAttempt } = raw;
|
|
9960
|
+
const config = yield* readReleaseConfig(configPath);
|
|
9961
|
+
const identity = { tag, sourceSha, workflowSha, runId, runAttempt };
|
|
9962
|
+
if (action === "observe-native") {
|
|
9963
|
+
const baseline = baselineArtifacts ? yield* readBoundedJson(baselineArtifacts, 4096, "Daily baseline") : undefined;
|
|
9964
|
+
return yield* print(yield* observeDailyNativeEffect({
|
|
9965
|
+
config,
|
|
9966
|
+
identity,
|
|
9967
|
+
artifacts,
|
|
9968
|
+
checkName: receipts,
|
|
9969
|
+
driver: parent,
|
|
9970
|
+
baseline
|
|
9971
|
+
}, runDailyNativeDriver));
|
|
9972
|
+
}
|
|
9973
|
+
if (action === "produce-native-receipt") {
|
|
9974
|
+
const { env, platform: os, arch } = yield* ReleaseConfig;
|
|
9975
|
+
yield* step(async () => assertHostedRunner(env, "Daily native receipt"));
|
|
9976
|
+
const report = yield* readBoundedJson(parent, 65536, "Daily native job report");
|
|
9977
|
+
return yield* print(yield* createDailyNativeReceiptEffect({
|
|
9978
|
+
config,
|
|
9979
|
+
identity,
|
|
9980
|
+
artifacts,
|
|
9981
|
+
checkName: receipts,
|
|
9982
|
+
baselineArtifacts,
|
|
9983
|
+
report
|
|
9984
|
+
}, { os, arch }));
|
|
9985
|
+
}
|
|
9986
|
+
const options = {
|
|
9987
|
+
config,
|
|
9988
|
+
identity,
|
|
9989
|
+
artifacts,
|
|
9990
|
+
receipts
|
|
9991
|
+
};
|
|
9992
|
+
const result = action === "verify" ? yield* verifyDailyReleaseMatrixEffect(options) : yield* stageDailyBatchEffect({ ...options, parent });
|
|
9993
|
+
return yield* print(result);
|
|
9994
|
+
}));
|
|
9995
|
+
var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9996
|
+
yield* print(yield* step(() => prepareStableCatalogCommand(args)));
|
|
9997
|
+
}));
|
|
9998
|
+
var stageAptRepository = (args) => runCommand((error) => `Unable to stage Apt repository: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
9999
|
+
yield* print(yield* step(() => stageAptRepositoryCommand(args)));
|
|
10000
|
+
}));
|
|
10001
|
+
var linuxChannelProof = (args) => runCommand((error) => `Unable to check Linux package channel: ${redactedErrorMessage(error)}`, Effect29.gen(function* () {
|
|
10002
|
+
const [channel, input, ...extra] = args;
|
|
10003
|
+
if (channel !== "rpm" && channel !== "flatpak" || !input || extra.length)
|
|
10004
|
+
return yield* invalid("Expected <rpm|flatpak> <input.json>");
|
|
10005
|
+
const value = yield* readBoundedJson(input, 1024 * 1024, "Linux channel proof");
|
|
10006
|
+
if (channel === "rpm") {
|
|
10007
|
+
yield* print(yield* step(() => verifyRpmStage(value)));
|
|
10008
|
+
} else {
|
|
10009
|
+
const { policy, observation } = value;
|
|
10010
|
+
yield* print(yield* step(async () => verifyFlatpakCapabilities(policy, observation)));
|
|
10011
|
+
}
|
|
10012
|
+
}));
|
|
8724
10013
|
var commands = {
|
|
8725
10014
|
cut,
|
|
10015
|
+
"daily-matrix": dailyMatrix,
|
|
8726
10016
|
finalize,
|
|
10017
|
+
"linux-channel-proof": linuxChannelProof,
|
|
8727
10018
|
"plan-assets": planAssets,
|
|
10019
|
+
"prepare-stable-catalog": prepareStableCatalog2,
|
|
8728
10020
|
promote,
|
|
8729
10021
|
publish,
|
|
8730
10022
|
"publish-arch": publishArch,
|
|
8731
10023
|
"publish-framework-package": publishFramework,
|
|
8732
10024
|
sign: sign2,
|
|
8733
10025
|
"sign-descriptors": signDescriptors,
|
|
10026
|
+
"stage-apt-repository": stageAptRepository,
|
|
8734
10027
|
step: releaseStep,
|
|
8735
10028
|
"verify-macos-signing": verifyMacosSigning
|
|
8736
10029
|
};
|
|
@@ -8739,7 +10032,7 @@ var releaseCli = (argv) => {
|
|
|
8739
10032
|
const command = name === undefined ? undefined : commands[name];
|
|
8740
10033
|
if (command)
|
|
8741
10034
|
return command(args);
|
|
8742
|
-
return
|
|
10035
|
+
return Effect29.gen(function* () {
|
|
8743
10036
|
const { stderr } = yield* ReleaseOutput;
|
|
8744
10037
|
stderr(`Usage: adea-release <${Object.keys(commands).join("|")}> [arguments]; unknown command ${String(name)}
|
|
8745
10038
|
`);
|
|
@@ -8748,4 +10041,4 @@ var releaseCli = (argv) => {
|
|
|
8748
10041
|
};
|
|
8749
10042
|
|
|
8750
10043
|
// src/cli.ts
|
|
8751
|
-
process.exitCode = await
|
|
10044
|
+
process.exitCode = await Effect30.runPromise(provideLivePorts(releaseCli(process.argv.slice(2))));
|