@adea-ai/app-framework-release-tools 0.6.0 → 0.8.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/circleci/circleci-daily-workspace.js +473 -0
- package/dist/circleci/circleci-gitlab-qualification.js +103 -0
- package/dist/circleci/prepare-daily-workspace.js +155 -0
- package/dist/cli.js +1980 -707
- package/dist/index.js +1329 -462
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,8 +17,12 @@ var __export = (target, all) => {
|
|
|
17
17
|
// src/index.ts
|
|
18
18
|
var exports_src = {};
|
|
19
19
|
__export(exports_src, {
|
|
20
|
+
assertStandaloneWindowsPayload: () => assertStandaloneWindowsPayload,
|
|
20
21
|
buildLinuxFormats: () => buildLinuxFormats,
|
|
22
|
+
buildStandaloneWindowsExe: () => buildStandaloneWindowsExe,
|
|
21
23
|
compareLinuxReproducibility: () => compareLinuxReproducibility,
|
|
24
|
+
createAptR2Store: () => createAptR2Store,
|
|
25
|
+
createAptSignatureVerifier: () => createAptSignatureVerifier,
|
|
22
26
|
createDailyBatchR2Client: () => createDailyBatchR2Client,
|
|
23
27
|
createDailyBatchR2Store: () => createDailyBatchR2Store,
|
|
24
28
|
createDailyBatchS3Transport: () => createDailyBatchS3Transport,
|
|
@@ -27,14 +31,17 @@ __export(exports_src, {
|
|
|
27
31
|
createGitHubReleasePublisher: () => createGitHubReleasePublisher,
|
|
28
32
|
createMacosDmg: () => createMacosDmg,
|
|
29
33
|
desktopDailyProfile: () => desktopDailyProfile,
|
|
34
|
+
expandedDesktopDailyProfile: () => expandedDesktopDailyProfile,
|
|
30
35
|
fileIdentity: () => fileIdentity2,
|
|
31
36
|
finalizeReleasePleaseDraft: () => finalizeReleasePleaseDraft,
|
|
32
37
|
inspectDailyBatch: () => inspectDailyBatch,
|
|
38
|
+
inspectDailyPreSigning: () => inspectDailyPreSigning,
|
|
33
39
|
inspectStagedStep: () => inspectStagedStep,
|
|
34
40
|
planDailyReleaseMatrix: () => planDailyReleaseMatrix,
|
|
35
41
|
planQualificationRun: () => planQualificationRun2,
|
|
36
42
|
planReleaseAssets: () => planReleaseAssets2,
|
|
37
43
|
promoteDailyBatch: () => promoteDailyBatch,
|
|
44
|
+
publishAptRepository: () => publishAptRepository,
|
|
38
45
|
publishFrameworkPackage: () => publishFrameworkPackage,
|
|
39
46
|
publishQualifiedRelease: () => publishQualifiedRelease,
|
|
40
47
|
qualifyGitHubRelease: () => qualifyGitHubRelease,
|
|
@@ -364,10 +371,20 @@ var tokens = (value, minimum) => Array.isArray(value) && value.length >= minimum
|
|
|
364
371
|
var relativePath = (value) => typeof value === "string" && value.length <= 200 && /^[A-Za-z0-9._/-]+$/.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== "..");
|
|
365
372
|
var platformTargets = {
|
|
366
373
|
"macos-arm64": ["darwin", "arm64"],
|
|
374
|
+
"macos-x64": ["darwin", "x64"],
|
|
367
375
|
"windows-x64": ["win32", "x64"],
|
|
368
|
-
"linux-x64": ["linux", "x64"]
|
|
376
|
+
"linux-x64": ["linux", "x64"],
|
|
377
|
+
"linux-arm64": ["linux", "arm64"]
|
|
369
378
|
};
|
|
370
379
|
var releasePlatforms = Object.keys(platformTargets);
|
|
380
|
+
var legacyDesktopPlatforms = [
|
|
381
|
+
"macos-arm64",
|
|
382
|
+
"windows-x64",
|
|
383
|
+
"linux-x64"
|
|
384
|
+
];
|
|
385
|
+
function requiredDesktopPlatforms(profile) {
|
|
386
|
+
return profile === "desktop-v2" ? releasePlatforms : legacyDesktopPlatforms;
|
|
387
|
+
}
|
|
371
388
|
function parseCommandArtifacts(value, platforms) {
|
|
372
389
|
if (value === undefined)
|
|
373
390
|
return [];
|
|
@@ -442,7 +459,7 @@ function parseReleaseConfig(config) {
|
|
|
442
459
|
throw new Error("Invalid offline expected read");
|
|
443
460
|
}
|
|
444
461
|
const platforms = config.platforms;
|
|
445
|
-
for (const required of
|
|
462
|
+
for (const required of requiredDesktopPlatforms(config.dailyReleaseProfile))
|
|
446
463
|
if (!Object.hasOwn(platforms, required))
|
|
447
464
|
throw new Error("Releases require all supported desktop platforms");
|
|
448
465
|
for (const [platform, assets] of Object.entries(platforms))
|
|
@@ -572,7 +589,7 @@ function discoveryPolicies(config, tag) {
|
|
|
572
589
|
result.push({ name, channel, platform, os, arch, appId: kind.appId, payload });
|
|
573
590
|
}
|
|
574
591
|
for (const kind of kinds)
|
|
575
|
-
for (const platform of
|
|
592
|
+
for (const platform of requiredDesktopPlatforms(config.dailyReleaseProfile))
|
|
576
593
|
if (!result.some((value) => value.channel === channel && value.appId === kind.appId && value.platform === platform))
|
|
577
594
|
throw new Error("Missing platform discovery policy");
|
|
578
595
|
}
|
|
@@ -1904,17 +1921,25 @@ function runnerTemp(env) {
|
|
|
1904
1921
|
}
|
|
1905
1922
|
|
|
1906
1923
|
// ../../src/installer/installer-layout.ts
|
|
1924
|
+
var INSTALLER_HOSTS = {
|
|
1925
|
+
"macos-arm64": "darwin/arm64",
|
|
1926
|
+
"macos-x64": "darwin/x64",
|
|
1927
|
+
"windows-x64": "win32/x64",
|
|
1928
|
+
"linux-x64": "linux/x64",
|
|
1929
|
+
"linux-arm64": "linux/arm64"
|
|
1930
|
+
};
|
|
1931
|
+
function isInstallerPlatform(value) {
|
|
1932
|
+
return typeof value === "string" && Object.hasOwn(INSTALLER_HOSTS, value);
|
|
1933
|
+
}
|
|
1934
|
+
function isMacInstallerPlatform(platform) {
|
|
1935
|
+
return platform === "macos-arm64" || platform === "macos-x64";
|
|
1936
|
+
}
|
|
1907
1937
|
function assertInstallerContext(env, platform, host, arch) {
|
|
1908
1938
|
assertHostedRunner(env, "Installer execution");
|
|
1909
1939
|
assertInstallerHost(platform, host, arch);
|
|
1910
1940
|
}
|
|
1911
1941
|
function assertInstallerHost(platform, host, arch) {
|
|
1912
|
-
const expected =
|
|
1913
|
-
"macos-arm64": "darwin/arm64",
|
|
1914
|
-
"windows-x64": "win32/x64",
|
|
1915
|
-
"linux-x64": "linux/x64",
|
|
1916
|
-
"linux-arm64": "linux/arm64"
|
|
1917
|
-
}[platform];
|
|
1942
|
+
const expected = INSTALLER_HOSTS[platform];
|
|
1918
1943
|
if (!expected || `${host}/${arch}` !== expected)
|
|
1919
1944
|
throw new Error("Installer requires matching native OS and architecture");
|
|
1920
1945
|
}
|
|
@@ -1941,11 +1966,11 @@ function assertPayloadLayout(options) {
|
|
|
1941
1966
|
const { platform, appName, renderer } = options;
|
|
1942
1967
|
const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
|
|
1943
1968
|
assertPortableAppName(appName);
|
|
1944
|
-
if (!
|
|
1969
|
+
if (!isInstallerPlatform(platform) || !["native", "cef"].includes(renderer))
|
|
1945
1970
|
throw new Error("Invalid installer profile");
|
|
1946
1971
|
const fold = platform === "windows-x64";
|
|
1947
1972
|
const entries = paths(options.entries, fold);
|
|
1948
|
-
const mac = platform
|
|
1973
|
+
const mac = isMacInstallerPlatform(platform);
|
|
1949
1974
|
const root = mac ? `${appName}.app/Contents` : appName.replaceAll(" ", "");
|
|
1950
1975
|
const bin = mac ? `${root}/MacOS` : `${root}/bin`;
|
|
1951
1976
|
const resources = `${root}/Resources`;
|
|
@@ -3513,6 +3538,12 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
|
|
|
3513
3538
|
throw new Error("Daily manifest upload differs");
|
|
3514
3539
|
if (JSON.stringify(parseManifest(await candidate.verify())) !== JSON.stringify(first))
|
|
3515
3540
|
throw new Error("Daily candidate changed during upload");
|
|
3541
|
+
if (old?.manifestDigest === digest) {
|
|
3542
|
+
const selected = await readDailyBatch(store, target, keys);
|
|
3543
|
+
if (!selected || selected.manifestDigest !== digest)
|
|
3544
|
+
throw new Error("Daily pointer changed during promotion retry");
|
|
3545
|
+
return selected;
|
|
3546
|
+
}
|
|
3516
3547
|
const signed = await signDailyPointer({
|
|
3517
3548
|
schema: "framework/daily-pointer/v3",
|
|
3518
3549
|
appId,
|
|
@@ -3677,23 +3708,395 @@ function createDailyBatchR2Store(send) {
|
|
|
3677
3708
|
}
|
|
3678
3709
|
};
|
|
3679
3710
|
}
|
|
3711
|
+
// src/library/apt/apt-r2-store.ts
|
|
3712
|
+
var key = /^apt\/(?:adea|cortana)\/(?:archive-keyring\.gpg|dists\/(?:daily|stable)\/(?:InRelease|main\/binary-(?:amd64|arm64)\/by-hash\/SHA256\/[0-9a-f]{64})|pool\/main\/(?:a\/adea-desktop\/Adea|c\/cortana-desktop\/Cortana)-v(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})-linux-(?:x64|arm64)\.deb)$/;
|
|
3713
|
+
var pointer2 = /^apt\/(?:adea|cortana)\/dists\/(?:daily|stable)\/InRelease$/;
|
|
3714
|
+
var validEtag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3715
|
+
var max = 768 * 1024 ** 2;
|
|
3716
|
+
var metadataLimit = 256 * 1024;
|
|
3717
|
+
function validKey(k, mode) {
|
|
3718
|
+
if (!key.test(k) || mode === "pointer" !== pointer2.test(k))
|
|
3719
|
+
throw Error("Unapproved APT repository path");
|
|
3720
|
+
const parts = k.split("/");
|
|
3721
|
+
if (parts[2] === "pool" && parts[1][0] !== parts[4])
|
|
3722
|
+
throw Error("Cross-application APT pool path");
|
|
3723
|
+
return k;
|
|
3724
|
+
}
|
|
3725
|
+
async function* once(bytes) {
|
|
3726
|
+
yield bytes;
|
|
3727
|
+
}
|
|
3728
|
+
async function discard(body) {
|
|
3729
|
+
for await (const _ of body) {}
|
|
3730
|
+
}
|
|
3731
|
+
async function bounded2(body, limit) {
|
|
3732
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > max)
|
|
3733
|
+
throw Error("Invalid read bound");
|
|
3734
|
+
const chunks = [];
|
|
3735
|
+
let size = 0;
|
|
3736
|
+
for await (const chunk of body) {
|
|
3737
|
+
size += chunk.length;
|
|
3738
|
+
if (size > limit)
|
|
3739
|
+
throw Error("APT repository object beyond read bound");
|
|
3740
|
+
chunks.push(chunk);
|
|
3741
|
+
}
|
|
3742
|
+
return Buffer.concat(chunks, size);
|
|
3743
|
+
}
|
|
3744
|
+
function createAptR2Store(send) {
|
|
3745
|
+
const immutable = createDailyBatchR2Store(send);
|
|
3746
|
+
return {
|
|
3747
|
+
async remote(k, limit) {
|
|
3748
|
+
return bounded2(await immutable.readObject(validKey(k, "immutable")), limit);
|
|
3749
|
+
},
|
|
3750
|
+
async putImmutable(k, b, expected) {
|
|
3751
|
+
if (b.length > max || b.length !== expected.size)
|
|
3752
|
+
throw Error("Invalid immutable APT size");
|
|
3753
|
+
await immutable.putImmutable(validKey(k, "immutable"), once(b), expected.size, expected.sha256);
|
|
3754
|
+
},
|
|
3755
|
+
async readPointer(k, limit) {
|
|
3756
|
+
if (limit > metadataLimit)
|
|
3757
|
+
throw Error("Invalid InRelease read bound");
|
|
3758
|
+
const response = await send({ method: "GET", key: validKey(k, "pointer"), headers: {} });
|
|
3759
|
+
if (response.status === 404) {
|
|
3760
|
+
await discard(response.body);
|
|
3761
|
+
return null;
|
|
3762
|
+
}
|
|
3763
|
+
const etag = response.headers.etag;
|
|
3764
|
+
if (response.status !== 200 || !etag || !validEtag.test(etag)) {
|
|
3765
|
+
await discard(response.body);
|
|
3766
|
+
throw Error("Cannot read InRelease validator");
|
|
3767
|
+
}
|
|
3768
|
+
return { etag, bytes: await bounded2(response.body, limit) };
|
|
3769
|
+
},
|
|
3770
|
+
async casInRelease(k, prev, b) {
|
|
3771
|
+
if (prev !== null && !validEtag.test(prev) || !b.length || b.length > metadataLimit)
|
|
3772
|
+
throw Error("Invalid conditional InRelease write");
|
|
3773
|
+
const response = await send({
|
|
3774
|
+
method: "PUT",
|
|
3775
|
+
key: validKey(k, "pointer"),
|
|
3776
|
+
headers: {
|
|
3777
|
+
...prev === null ? { "if-none-match": "*" } : { "if-match": prev },
|
|
3778
|
+
"content-length": String(b.length),
|
|
3779
|
+
"content-type": "application/octet-stream",
|
|
3780
|
+
"cache-control": "no-cache"
|
|
3781
|
+
},
|
|
3782
|
+
body: once(b)
|
|
3783
|
+
});
|
|
3784
|
+
await discard(response.body);
|
|
3785
|
+
if (response.status === 412)
|
|
3786
|
+
return false;
|
|
3787
|
+
if (response.status !== 200)
|
|
3788
|
+
throw Error("Conditional InRelease write failed");
|
|
3789
|
+
return true;
|
|
3790
|
+
}
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
// src/library/apt/publish-apt-repository.ts
|
|
3794
|
+
import { createHash as createHash9 } from "crypto";
|
|
3795
|
+
import { gunzipSync } from "zlib";
|
|
3796
|
+
var ARCHES = ["amd64", "arm64"];
|
|
3797
|
+
var version = /^(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})\.(?:0|[1-9]\d{0,8})$/;
|
|
3798
|
+
var hex3 = /^[0-9a-f]{64}$/;
|
|
3799
|
+
var indexLimit = 256 * 1024;
|
|
3800
|
+
var debLimit = 768 * 1024 ** 2;
|
|
3801
|
+
var etag = /^"[0-9a-f]{32}(?:-[1-9]\d{0,6})?"$/i;
|
|
3802
|
+
var digest = (bytes) => createHash9("sha256").update(bytes).digest("hex");
|
|
3803
|
+
var decode = (bytes) => new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
3804
|
+
var same2 = (a, b) => Buffer.from(a).equals(b);
|
|
3805
|
+
function need(condition, message) {
|
|
3806
|
+
if (!condition)
|
|
3807
|
+
throw Error(message);
|
|
3808
|
+
}
|
|
3809
|
+
function release(bytes, suite) {
|
|
3810
|
+
need(bytes.length > 0 && bytes.length <= indexLimit, "Invalid APT Release size");
|
|
3811
|
+
const lines = decode(bytes).trimEnd().split(`
|
|
3812
|
+
`);
|
|
3813
|
+
const fields = new Map;
|
|
3814
|
+
const bindings = new Map;
|
|
3815
|
+
let hashes = false;
|
|
3816
|
+
for (const line of lines) {
|
|
3817
|
+
if (line === "SHA256:" && !hashes) {
|
|
3818
|
+
hashes = true;
|
|
3819
|
+
continue;
|
|
3820
|
+
}
|
|
3821
|
+
if (!hashes) {
|
|
3822
|
+
const m = /^([A-Za-z-]+): (.{1,200})$/.exec(line);
|
|
3823
|
+
need(m && !fields.has(m[1]), "Invalid APT Release header");
|
|
3824
|
+
fields.set(m[1], m[2]);
|
|
3825
|
+
continue;
|
|
3826
|
+
}
|
|
3827
|
+
const m = /^ ([0-9a-f]{64}) ([1-9]\d{0,5}) (main\/binary-(?:amd64|arm64)\/Packages(?:\.gz)?)$/.exec(line);
|
|
3828
|
+
need(m && Number(m[2]) <= indexLimit && !bindings.has(m[3]), "Invalid APT Release index binding");
|
|
3829
|
+
bindings.set(m[3], { sha256: m[1], size: Number(m[2]) });
|
|
3830
|
+
}
|
|
3831
|
+
need(fields.get("Suite") === suite && fields.get("Codename") === suite && fields.get("Architectures") === "amd64 arm64" && fields.get("Components") === "main" && fields.get("Acquire-By-Hash") === "yes" && !!fields.get("Origin") && !!fields.get("Label") && bindings.size === 4, "APT Release metadata does not match the exact suite and architecture policy");
|
|
3832
|
+
const created = Date.parse(fields.get("Date") ?? "");
|
|
3833
|
+
const validUntil = Date.parse(fields.get("Valid-Until") ?? "");
|
|
3834
|
+
need(Number.isFinite(created) && validUntil - created === 30 * 86400000, "Invalid APT metadata clock");
|
|
3835
|
+
return { fields, bindings, created, validUntil };
|
|
3836
|
+
}
|
|
3837
|
+
function identity(app, arch, v) {
|
|
3838
|
+
const pkg = app + "-desktop";
|
|
3839
|
+
const brand = app === "adea" ? "Adea" : "Cortana";
|
|
3840
|
+
const name = brand + "-v" + v + "-linux-" + (arch === "amd64" ? "x64" : "arm64") + ".deb";
|
|
3841
|
+
return { pkg, name, path: "pool/main/" + app[0] + "/" + pkg + "/" + name };
|
|
3842
|
+
}
|
|
3843
|
+
function packageIndex(bytes, app, arch) {
|
|
3844
|
+
const text = decode(bytes);
|
|
3845
|
+
need(text.endsWith(`
|
|
3846
|
+
|
|
3847
|
+
`) && !text.slice(0, -2).includes(`
|
|
3848
|
+
|
|
3849
|
+
`), "Expected a single APT package stanza");
|
|
3850
|
+
const fields = new Map;
|
|
3851
|
+
for (const line of text.slice(0, -2).split(`
|
|
3852
|
+
`)) {
|
|
3853
|
+
if (/^[ \t]/.test(line) && fields.size)
|
|
3854
|
+
continue;
|
|
3855
|
+
const m = /^([A-Za-z0-9-]+):[ \t]*(.*)$/.exec(line);
|
|
3856
|
+
need(m && !fields.has(m[1].toLowerCase()), "Invalid APT Packages field");
|
|
3857
|
+
fields.set(m[1].toLowerCase(), m[2]);
|
|
3858
|
+
}
|
|
3859
|
+
const v = fields.get("version") ?? "";
|
|
3860
|
+
need(version.test(v), "Invalid APT package version");
|
|
3861
|
+
const id = identity(app, arch, v);
|
|
3862
|
+
const size = Number(fields.get("size"));
|
|
3863
|
+
const sha256 = fields.get("sha256") ?? "";
|
|
3864
|
+
need(fields.get("architecture") === arch && fields.get("package") === id.pkg && fields.get("filename") === id.path && String(size) === fields.get("size") && Number.isSafeInteger(size) && size > 0 && size <= debLimit && hex3.test(sha256), "Unexpected APT package identity or size");
|
|
3865
|
+
return { ...id, version: v, size, sha256 };
|
|
3866
|
+
}
|
|
3867
|
+
function byHash(path, binding) {
|
|
3868
|
+
return path.slice(0, path.lastIndexOf("/")) + "/by-hash/SHA256/" + binding.sha256;
|
|
3869
|
+
}
|
|
3870
|
+
function check(bytes, expected) {
|
|
3871
|
+
need(bytes.length === expected.size && digest(bytes) === expected.sha256, "APT object bytes mismatch");
|
|
3872
|
+
return bytes;
|
|
3873
|
+
}
|
|
3874
|
+
function compare(a, b) {
|
|
3875
|
+
const old = b.split(".").map(Number);
|
|
3876
|
+
return a.split(".").map(Number).map((n, i) => n - old[i]).find(Boolean) ?? 0;
|
|
3877
|
+
}
|
|
3878
|
+
async function index(read, app, arch, bindings, base) {
|
|
3879
|
+
const prefix = "main/binary-" + arch + "/Packages";
|
|
3880
|
+
const entries = await Promise.all(["", ".gz"].map(async (suffix) => {
|
|
3881
|
+
const path = prefix + suffix;
|
|
3882
|
+
const binding = bindings.get(path);
|
|
3883
|
+
need(binding, "Missing APT index binding");
|
|
3884
|
+
const key = base + byHash(path, binding);
|
|
3885
|
+
return { key, binding, bytes: check(await read(key, binding.size), binding) };
|
|
3886
|
+
}));
|
|
3887
|
+
need(same2(entries[0].bytes, gunzipSync(entries[1].bytes, { maxOutputLength: indexLimit })), "Compressed and plain APT indices differ");
|
|
3888
|
+
return { entries, pkg: packageIndex(entries[0].bytes, app, arch) };
|
|
3889
|
+
}
|
|
3890
|
+
async function publishAptRepository({ app, suite, tag, assets }, port, now = Date.now()) {
|
|
3891
|
+
need((app === "adea" || app === "cortana") && (suite === "stable" || suite === "daily") && tag.startsWith("v") && version.test(tag.slice(1)) && Number.isFinite(now) && assets.length <= 256, "Invalid authorized APT candidate");
|
|
3892
|
+
const root = "apt/" + app + "/";
|
|
3893
|
+
const dists = "dists/" + suite + "/";
|
|
3894
|
+
const key = root + dists + "InRelease";
|
|
3895
|
+
const proposed = await port.staged(dists + "InRelease", indexLimit);
|
|
3896
|
+
need(proposed.length > 0 && proposed.length <= indexLimit, "Invalid staged InRelease");
|
|
3897
|
+
const plan = release(await port.verify(proposed), suite);
|
|
3898
|
+
need(plan.created <= now + 5 * 60000 && plan.validUntil > now, "Candidate APT metadata is not current");
|
|
3899
|
+
const parts = await Promise.all(ARCHES.map((arch) => index(port.staged, app, arch, plan.bindings, dists)));
|
|
3900
|
+
for (const { pkg } of parts) {
|
|
3901
|
+
const allowed = assets.filter((a) => a.name === pkg.name);
|
|
3902
|
+
need(pkg.version === tag.slice(1) && allowed.length === 1 && allowed[0].size === pkg.size && allowed[0].sha256 === pkg.sha256, "APT package is not part of the independently verified release");
|
|
3903
|
+
}
|
|
3904
|
+
const prior = await port.readPointer(key, indexLimit);
|
|
3905
|
+
if (prior) {
|
|
3906
|
+
need(etag.test(prior.etag) && prior.bytes.length <= indexLimit, "Invalid current APT pointer");
|
|
3907
|
+
const old = release(await port.verify(prior.bytes), suite);
|
|
3908
|
+
need(old.fields.get("Origin") === plan.fields.get("Origin") && old.fields.get("Label") === plan.fields.get("Label"), "APT repository identity changed");
|
|
3909
|
+
const oldParts = await Promise.all(ARCHES.map((arch) => index(port.remote, app, arch, old.bindings, root + dists)));
|
|
3910
|
+
const current = oldParts[0].pkg.version;
|
|
3911
|
+
need(oldParts[1].pkg.version === current, "Incumbent APT architectures disagree");
|
|
3912
|
+
need(compare(tag.slice(1), current) >= 0 && plan.created >= old.created, "APT version or date would go backwards");
|
|
3913
|
+
if (tag.slice(1) === current) {
|
|
3914
|
+
need(parts.every(({ pkg }, i) => pkg.sha256 === oldParts[i].pkg.sha256 && pkg.size === oldParts[i].pkg.size), "Cannot replace published bytes for the same APT version");
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
for (const { entries, pkg } of parts) {
|
|
3918
|
+
for (const item of [
|
|
3919
|
+
...entries,
|
|
3920
|
+
{
|
|
3921
|
+
key: pkg.path,
|
|
3922
|
+
binding: pkg,
|
|
3923
|
+
bytes: check(await port.staged(pkg.path, pkg.size), pkg)
|
|
3924
|
+
}
|
|
3925
|
+
]) {
|
|
3926
|
+
const name = root + item.key;
|
|
3927
|
+
await port.putImmutable(name, item.bytes, item.binding);
|
|
3928
|
+
check(await port.remote(name, item.binding.size), item.binding);
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
if (prior && same2(prior.bytes, proposed)) {
|
|
3932
|
+
const current = await port.readPointer(key, indexLimit);
|
|
3933
|
+
need(current && current.etag === prior.etag && same2(current.bytes, proposed), "APT pointer changed during retry");
|
|
3934
|
+
return { tag, changed: false };
|
|
3935
|
+
}
|
|
3936
|
+
need(await port.casInRelease(key, prior?.etag ?? null, proposed), "APT InRelease changed concurrently");
|
|
3937
|
+
const current = await port.readPointer(key, indexLimit);
|
|
3938
|
+
need(current && etag.test(current.etag) && same2(current.bytes, proposed), "APT InRelease did not read back as committed");
|
|
3939
|
+
return { tag, changed: true };
|
|
3940
|
+
}
|
|
3941
|
+
// src/library/apt/verify-apt-signature.ts
|
|
3942
|
+
import { createHash as createHash10 } from "crypto";
|
|
3943
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
3944
|
+
import { mkdtemp as mkdtemp3, readFile as readFile5, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
3945
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
3946
|
+
import { join as join7 } from "path";
|
|
3947
|
+
function createAptSignatureVerifier(config) {
|
|
3948
|
+
const { fingerprint } = config;
|
|
3949
|
+
const keyring = Buffer.from(config.keyring);
|
|
3950
|
+
if (keyring.length < 1 || keyring.length > 64 * 1024 || !/^[A-F0-9]{40}$/.test(fingerprint) || !/^[0-9a-f]{64}$/.test(config.sha256) || createHash10("sha256").update(keyring).digest("hex") !== config.sha256)
|
|
3951
|
+
throw Error("Untrusted APT signing keyring");
|
|
3952
|
+
return async (bytes) => {
|
|
3953
|
+
if (bytes.length < 1 || bytes.length > 256 * 1024)
|
|
3954
|
+
throw Error("Invalid InRelease size");
|
|
3955
|
+
const scratch = await mkdtemp3(join7(tmpdir4(), "framework-apt-verification-"));
|
|
3956
|
+
try {
|
|
3957
|
+
const file = join7(scratch, "InRelease");
|
|
3958
|
+
const plain = join7(scratch, "Release");
|
|
3959
|
+
const ring = join7(scratch, "trusted.gpg");
|
|
3960
|
+
await Promise.all([
|
|
3961
|
+
writeFile3(ring, keyring, { flag: "wx", mode: 384 }),
|
|
3962
|
+
writeFile3(file, bytes, { flag: "wx", mode: 384 })
|
|
3963
|
+
]);
|
|
3964
|
+
const status = spawnSync2("gpgv", ["--homedir", scratch, "--keyring", ring, "--status-fd", "1", "--output", plain, file], {
|
|
3965
|
+
env: { PATH: process.env.PATH, HOME: scratch, LC_ALL: "C" },
|
|
3966
|
+
encoding: "utf8",
|
|
3967
|
+
timeout: 15000,
|
|
3968
|
+
maxBuffer: 256 * 1024
|
|
3969
|
+
});
|
|
3970
|
+
const lines = (status.stdout ?? "").split(`
|
|
3971
|
+
`).filter((line) => line.startsWith("[GNUPG:] VALIDSIG "));
|
|
3972
|
+
const signature = (lines[0] ?? "").split(" ");
|
|
3973
|
+
if (status.error || status.status !== 0 || lines.length !== 1 || signature[2] !== fingerprint || signature.at(-1) !== fingerprint || signature[9] !== "8" || signature[10] !== "01" || (status.stdout ?? "").match(/^\[GNUPG:\] (?:REVKEYSIG|EXPKEYSIG|EXPSIG|BADSIG|ERRSIG|KEYEXPIRED)(?:\s|$)/m))
|
|
3974
|
+
throw Error("InRelease lacks an exact valid SHA-256 repository signature");
|
|
3975
|
+
const decoded = await readFile5(plain);
|
|
3976
|
+
if (!decoded.length || decoded.length > 256 * 1024)
|
|
3977
|
+
throw Error("Invalid signed Release size");
|
|
3978
|
+
return decoded;
|
|
3979
|
+
} finally {
|
|
3980
|
+
await rm3(scratch, { recursive: true, force: true });
|
|
3981
|
+
}
|
|
3982
|
+
};
|
|
3983
|
+
}
|
|
3680
3984
|
// src/library/daily-batch-inspection.ts
|
|
3681
|
-
import { join as
|
|
3985
|
+
import { join as join9 } from "path";
|
|
3682
3986
|
import { Effect as Effect17 } from "effect";
|
|
3683
3987
|
|
|
3684
3988
|
// src/library/daily-matrix.ts
|
|
3685
|
-
import {
|
|
3989
|
+
import { createHash as createHash11 } from "crypto";
|
|
3990
|
+
import { join as join8 } from "path";
|
|
3686
3991
|
import { Effect as Effect16 } from "effect";
|
|
3687
3992
|
|
|
3993
|
+
// src/library/daily-native-platform.ts
|
|
3994
|
+
import { execFile as execFile2 } from "child_process";
|
|
3995
|
+
import { win32 } from "path";
|
|
3996
|
+
import { promisify as promisify2 } from "util";
|
|
3997
|
+
function parseWindowsClient(value) {
|
|
3998
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["Version", "BuildNumber", "ProductType", "Architecture"]) || typeof value.BuildNumber !== "string" || !/^\d{5}$/.test(value.BuildNumber) || value.Version !== `10.0.${value.BuildNumber}` || value.ProductType !== 1 || !Array.isArray(value.Architecture) || value.Architecture.length === 0 || !value.Architecture.every((v) => v === 9))
|
|
3999
|
+
throw new Error("Windows native qualification requires an x64 client workstation");
|
|
4000
|
+
const build = Number(value.BuildNumber);
|
|
4001
|
+
if (build === 19045)
|
|
4002
|
+
return { release: "10", build, productType: 1 };
|
|
4003
|
+
if ([22000, 22621, 22631, 26100, 26200, 28000].includes(build))
|
|
4004
|
+
return { release: "11", build, productType: 1 };
|
|
4005
|
+
throw new Error("Windows native qualification requires a reviewed Windows 10 or 11 build");
|
|
4006
|
+
}
|
|
4007
|
+
function matchesWindowsClient(value, release) {
|
|
4008
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["release", "build", "productType"]))
|
|
4009
|
+
return false;
|
|
4010
|
+
try {
|
|
4011
|
+
return value.release === release && parseWindowsClient({
|
|
4012
|
+
Version: `10.0.${value.build}`,
|
|
4013
|
+
BuildNumber: String(value.build),
|
|
4014
|
+
ProductType: value.productType,
|
|
4015
|
+
Architecture: [9]
|
|
4016
|
+
}).release === release && typeof value.build === "number";
|
|
4017
|
+
} catch {
|
|
4018
|
+
return false;
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
var run = promisify2(execFile2);
|
|
4022
|
+
var macToolOptions = {
|
|
4023
|
+
timeout: 30000,
|
|
4024
|
+
maxBuffer: 64 * 1024,
|
|
4025
|
+
env: { PATH: "/usr/bin:/bin:/usr/sbin", LC_ALL: "C" }
|
|
4026
|
+
};
|
|
4027
|
+
async function assertNativeMacHost(arch) {
|
|
4028
|
+
const { stdout } = await run("/usr/sbin/sysctl", ["-in", "hw.optional.arm64"], macToolOptions);
|
|
4029
|
+
const value = stdout.trim();
|
|
4030
|
+
if (arch === "arm64" && value !== "1" || arch === "x64" && value !== "0" && value !== "")
|
|
4031
|
+
throw new Error("Daily native check requires matching Mac hardware, not Rosetta");
|
|
4032
|
+
}
|
|
4033
|
+
var windowsRoot = (env) => {
|
|
4034
|
+
const root = env.SystemRoot;
|
|
4035
|
+
if (!root || !/^[A-Za-z]:\\[A-Za-z0-9 _-]+(?:\\[A-Za-z0-9 _-]+)*$/.test(root))
|
|
4036
|
+
throw new Error("Missing Windows system directory");
|
|
4037
|
+
return root;
|
|
4038
|
+
};
|
|
4039
|
+
var powershell = async (env, script, installer) => {
|
|
4040
|
+
const root = windowsRoot(env);
|
|
4041
|
+
const { stdout } = await run(win32.join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], {
|
|
4042
|
+
env: {
|
|
4043
|
+
SystemRoot: root,
|
|
4044
|
+
WINDIR: root,
|
|
4045
|
+
...installer ? { FRAMEWORK_SIGNED_INSTALLER: installer } : {}
|
|
4046
|
+
},
|
|
4047
|
+
timeout: 30000,
|
|
4048
|
+
maxBuffer: 16384,
|
|
4049
|
+
windowsHide: true
|
|
4050
|
+
});
|
|
4051
|
+
return JSON.parse(stdout);
|
|
4052
|
+
};
|
|
4053
|
+
var readWindowsClient = async (env) => parseWindowsClient(await powershell(env, `$ErrorActionPreference='Stop'; $os=Get-CimInstance Win32_OperatingSystem; $cpu=@(Get-CimInstance Win32_Processor | ForEach-Object { [int]$_.Architecture }); @{Version=[string]$os.Version;BuildNumber=[string]$os.BuildNumber;ProductType=[int]$os.ProductType;Architecture=$cpu} | ConvertTo-Json -Compress`));
|
|
4054
|
+
function installerSigningPolicy(config, check) {
|
|
4055
|
+
const value = isRecord(config) && isRecord(config.dailyNativeSigning) ? config.dailyNativeSigning : {};
|
|
4056
|
+
if (check.format === "dmg" && typeof value.macTeamId === "string" && /^[A-Z0-9]{10}$/.test(value.macTeamId))
|
|
4057
|
+
return { kind: "developer-id", teamId: value.macTeamId };
|
|
4058
|
+
if (check.format === "windows-setup" && typeof value.windowsCertificateSha256 === "string" && /^[a-f0-9]{64}$/.test(value.windowsCertificateSha256))
|
|
4059
|
+
return { kind: "authenticode", certificateSha256: value.windowsCertificateSha256 };
|
|
4060
|
+
throw new Error("Daily desktop qualification requires a reviewed native signing identity");
|
|
4061
|
+
}
|
|
4062
|
+
function matchInstallerSigning(value, policy) {
|
|
4063
|
+
if (!isRecord(value) || !hasExactOwnKeys(value, ["candidate", "baseline"]))
|
|
4064
|
+
return false;
|
|
4065
|
+
return [value.candidate, value.baseline].every((v) => isRecord(v) && hasExactOwnKeys(v, Object.keys(policy)) && Object.entries(policy).every(([key, expected]) => v[key] === expected));
|
|
4066
|
+
}
|
|
4067
|
+
async function verifyInstallerSigning(policy, installer, env) {
|
|
4068
|
+
if (policy.kind === "authenticode") {
|
|
4069
|
+
const value = await powershell(env, `$ErrorActionPreference='Stop'; $s=Get-AuthenticodeSignature -LiteralPath $env:FRAMEWORK_SIGNED_INSTALLER; if ($s.Status -ne 'Valid' -or $s.SignatureType -ne 'Authenticode' -or $null -eq $s.SignerCertificate -or $null -eq $s.TimeStamperCertificate) { throw 'Invalid Authenticode signature or timestamp' }; $sha=[System.Security.Cryptography.SHA256]::Create(); try { ([BitConverter]::ToString($sha.ComputeHash($s.SignerCertificate.RawData))).Replace('-','').ToLowerInvariant() | ConvertTo-Json -Compress } finally { $sha.Dispose() }`, installer);
|
|
4070
|
+
if (value !== policy.certificateSha256)
|
|
4071
|
+
throw new Error("Windows installer signer is not approved");
|
|
4072
|
+
} else {
|
|
4073
|
+
const opts = {
|
|
4074
|
+
timeout: 120000,
|
|
4075
|
+
maxBuffer: 64 * 1024,
|
|
4076
|
+
env: { PATH: "/usr/bin:/bin:/usr/sbin", LC_ALL: "C" }
|
|
4077
|
+
};
|
|
4078
|
+
await run("/usr/bin/codesign", ["--verify", "--strict", installer], opts);
|
|
4079
|
+
const { stderr } = await run("/usr/bin/codesign", ["-dv", "--verbose=4", installer], opts);
|
|
4080
|
+
if (!stderr.split(/\r?\n/).includes(`TeamIdentifier=${policy.teamId}`) || !stderr.split(/\r?\n/).some((line) => /^Authority=Developer ID Application: .+/.test(line)))
|
|
4081
|
+
throw new Error("macOS installer signer is not approved");
|
|
4082
|
+
await run("/usr/bin/xcrun", ["stapler", "validate", installer], opts);
|
|
4083
|
+
const { stdout: assessmentStatus, stderr: assessmentError } = await run("/usr/sbin/spctl", ["--status"], opts);
|
|
4084
|
+
if ((assessmentStatus + assessmentError).trim() !== "assessments enabled")
|
|
4085
|
+
throw new Error("macOS installer qualification requires enabled Gatekeeper assessments");
|
|
4086
|
+
await run("/usr/sbin/spctl", ["--assess", "--type", "open", "--context", "context:primary-signature", installer], opts);
|
|
4087
|
+
}
|
|
4088
|
+
return policy;
|
|
4089
|
+
}
|
|
4090
|
+
|
|
3688
4091
|
// src/library/daily-native-evidence.ts
|
|
3689
|
-
var
|
|
4092
|
+
var digest2 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
|
|
3690
4093
|
var record = (value, keys) => isRecord(value) && hasExactOwnKeys(value, keys);
|
|
3691
4094
|
function assertDailyIdentity(identity) {
|
|
3692
4095
|
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)
|
|
3693
4096
|
throw new Error("Invalid exact Daily identity");
|
|
3694
4097
|
}
|
|
3695
4098
|
function validArtifact(value) {
|
|
3696
|
-
return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 &&
|
|
4099
|
+
return record(value, ["name", "size", "digest"]) && typeof value.name === "string" && typeof value.size === "number" && Number.isSafeInteger(value.size) && value.size > 0 && digest2(value.digest);
|
|
3697
4100
|
}
|
|
3698
4101
|
function originMatches(value, payloadName) {
|
|
3699
4102
|
if (record(value, ["kind", "sourceSha"]))
|
|
@@ -3718,10 +4121,10 @@ function observationsMatch(value, { identity, check, baselineNames }) {
|
|
|
3718
4121
|
"ready",
|
|
3719
4122
|
"fixtureBefore",
|
|
3720
4123
|
"fixtureAfter"
|
|
3721
|
-
]) && 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 &&
|
|
4124
|
+
]) && 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 && digest2(upgrade.fixtureBefore) && upgrade.fixtureAfter === upgrade.fixtureBefore;
|
|
3722
4125
|
}
|
|
3723
4126
|
function validateDailyNativeEvidence(input, schema, context) {
|
|
3724
|
-
const { appId, identity, check, assets } = context;
|
|
4127
|
+
const { appId, identity, check, assets, profile = "desktop-v1", signing } = context;
|
|
3725
4128
|
const [os, arch] = platformTargets[check.platform];
|
|
3726
4129
|
if (!record(input, [
|
|
3727
4130
|
"schema",
|
|
@@ -3737,8 +4140,9 @@ function validateDailyNativeEvidence(input, schema, context) {
|
|
|
3737
4140
|
"format",
|
|
3738
4141
|
"host",
|
|
3739
4142
|
"assets",
|
|
3740
|
-
"observations"
|
|
3741
|
-
|
|
4143
|
+
"observations",
|
|
4144
|
+
...signing ? ["installerSigning"] : []
|
|
4145
|
+
]) || input.schema !== schema || input.appId !== appId || input.profile !== profile || 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, check.windowsClient ? ["os", "arch", "windowsClient"] : ["os", "arch"]) || input.host.os !== os || input.host.arch !== arch || check.windowsClient && !matchesWindowsClient(input.host.windowsClient, check.windowsClient) || signing && !matchInstallerSigning(input.installerSigning, signing) || !Array.isArray(input.assets) || input.assets.length !== assets.length)
|
|
3742
4146
|
throw new Error(`Native receipt identity or result mismatch: ${check.name}`);
|
|
3743
4147
|
for (const expected of assets) {
|
|
3744
4148
|
const matches = input.assets.filter((item) => validArtifact(item) && item.name === expected.name);
|
|
@@ -3747,37 +4151,68 @@ function validateDailyNativeEvidence(input, schema, context) {
|
|
|
3747
4151
|
}
|
|
3748
4152
|
if (!observationsMatch(input.observations, context))
|
|
3749
4153
|
throw new Error(`Missing or invalid native observations: ${check.name}`);
|
|
3750
|
-
return {
|
|
4154
|
+
return {
|
|
4155
|
+
host: {
|
|
4156
|
+
os,
|
|
4157
|
+
arch,
|
|
4158
|
+
...check.windowsClient ? { windowsClient: input.host.windowsClient } : {}
|
|
4159
|
+
},
|
|
4160
|
+
...signing ? { installerSigning: input.installerSigning } : {},
|
|
4161
|
+
observations: input.observations
|
|
4162
|
+
};
|
|
3751
4163
|
}
|
|
3752
4164
|
|
|
3753
4165
|
// src/library/daily-matrix.ts
|
|
3754
4166
|
var desktopDailyProfile = "desktop-v1";
|
|
4167
|
+
var expandedDesktopDailyProfile = "desktop-v2";
|
|
3755
4168
|
var platforms = [
|
|
3756
4169
|
"macos-arm64",
|
|
3757
4170
|
"windows-x64",
|
|
3758
4171
|
"linux-x64"
|
|
3759
4172
|
];
|
|
4173
|
+
var expandedPlatforms = [
|
|
4174
|
+
"macos-arm64",
|
|
4175
|
+
"macos-x64",
|
|
4176
|
+
"windows-x64",
|
|
4177
|
+
"linux-x64",
|
|
4178
|
+
"linux-arm64"
|
|
4179
|
+
];
|
|
3760
4180
|
var receiptLimit = 64 * 1024;
|
|
3761
4181
|
function requireThat(ok, message) {
|
|
3762
4182
|
if (!ok)
|
|
3763
4183
|
throw new Error(message);
|
|
3764
4184
|
}
|
|
3765
4185
|
function planDailyReleaseMatrix(config, tag) {
|
|
3766
|
-
requireThat(isRecord(config) && config.dailyReleaseProfile === desktopDailyProfile && typeof config.appId === "string", "Missing supported Daily release profile");
|
|
4186
|
+
requireThat(isRecord(config) && (config.dailyReleaseProfile === desktopDailyProfile || config.dailyReleaseProfile === expandedDesktopDailyProfile) && typeof config.appId === "string", "Missing supported Daily release profile");
|
|
3767
4187
|
const parsed = parseReleaseConfig(config);
|
|
3768
4188
|
const requirements = parsed.requirements(tag);
|
|
4189
|
+
const profile = config.dailyReleaseProfile;
|
|
4190
|
+
const expanded = profile === expandedDesktopDailyProfile;
|
|
3769
4191
|
const checks = [];
|
|
3770
|
-
|
|
4192
|
+
const primaryAssets = [];
|
|
4193
|
+
for (const platform of expanded ? expandedPlatforms : platforms) {
|
|
3771
4194
|
const pair = requirements.platforms[platform];
|
|
3772
4195
|
requireThat(pair?.length === 2, `Expected installer and updater archive for ${platform}`);
|
|
3773
4196
|
const [installer, archive] = pair;
|
|
3774
|
-
const suffix = platform
|
|
4197
|
+
const suffix = platform.startsWith("macos-") ? ".dmg" : platform === "windows-x64" ? expanded ? "-Setup.exe" : "-Setup.zip" : "-Setup.tar.gz";
|
|
3775
4198
|
requireThat(installer.endsWith(suffix) && archive.endsWith(".tar.zst"), `Unexpected desktop installer or updater format for ${platform}`);
|
|
3776
|
-
const format = platform
|
|
3777
|
-
|
|
4199
|
+
const format = platform.startsWith("macos-") ? "dmg" : platform === "windows-x64" ? "windows-setup" : "portable-linux";
|
|
4200
|
+
primaryAssets.push(installer, archive);
|
|
4201
|
+
if (expanded && platform === "windows-x64") {
|
|
4202
|
+
for (const windowsClient of ["10", "11"])
|
|
4203
|
+
checks.push({
|
|
4204
|
+
name: `installer-${platform}-win${windowsClient}`,
|
|
4205
|
+
platform,
|
|
4206
|
+
format,
|
|
4207
|
+
assets: pair,
|
|
4208
|
+
windowsClient
|
|
4209
|
+
});
|
|
4210
|
+
} else
|
|
4211
|
+
checks.push({ name: `installer-${platform}`, platform, format, assets: pair });
|
|
3778
4212
|
for (const command of parsed.commandArtifacts) {
|
|
3779
4213
|
const name = requirements.commandArtifacts?.[command.kind]?.[platform];
|
|
3780
4214
|
requireThat(name, `Missing command archive for ${platform}`);
|
|
4215
|
+
primaryAssets.push(name);
|
|
3781
4216
|
checks.push({
|
|
3782
4217
|
name: `command-${command.kind}-${platform}`,
|
|
3783
4218
|
platform,
|
|
@@ -3786,25 +4221,27 @@ function planDailyReleaseMatrix(config, tag) {
|
|
|
3786
4221
|
});
|
|
3787
4222
|
}
|
|
3788
4223
|
}
|
|
3789
|
-
const linux
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
assets: [
|
|
3796
|
-
}
|
|
3797
|
-
const names = checks.flatMap((check) => check.assets);
|
|
4224
|
+
for (const linux of expanded ? ["linux-x64", "linux-arm64"] : ["linux-x64"]) {
|
|
4225
|
+
const archive = requirements.platforms[linux][1];
|
|
4226
|
+
const base = archive.slice(0, -".tar.zst".length);
|
|
4227
|
+
const deb = base + ".deb";
|
|
4228
|
+
const appimage = base + ".AppImage";
|
|
4229
|
+
primaryAssets.push(deb, appimage);
|
|
4230
|
+
checks.push({ name: `deb-${linux}`, platform: linux, format: "deb", assets: [deb] }, { name: `appimage-${linux}`, platform: linux, format: "appimage", assets: [appimage] });
|
|
4231
|
+
}
|
|
3798
4232
|
discoveryPolicies(config, tag);
|
|
3799
|
-
const all = [...
|
|
4233
|
+
const all = [...primaryAssets, ...requirements.releaseAssets];
|
|
3800
4234
|
requireThat(new Set(all).size === all.length, "Daily release assets are not unique");
|
|
3801
|
-
return { appId: config.appId, profile
|
|
4235
|
+
return { appId: config.appId, profile, assets: all, checks };
|
|
4236
|
+
}
|
|
4237
|
+
function requiresDailyInstallerSigning(profile, check) {
|
|
4238
|
+
return profile === expandedDesktopDailyProfile && (check.format === "dmg" || check.format === "windows-setup");
|
|
3802
4239
|
}
|
|
3803
4240
|
function priorDailyInstallerNames(config, tag, check) {
|
|
3804
4241
|
const plan = planDailyReleaseMatrix(config, tag);
|
|
3805
4242
|
return {
|
|
3806
4243
|
installer: plan.checks.find((entry) => entry.name === check.name)?.assets[0],
|
|
3807
|
-
payload: plan.checks.find((entry) => entry.
|
|
4244
|
+
payload: plan.checks.find((entry) => entry.platform === check.platform && entry.assets.length === 2)?.assets[1]
|
|
3808
4245
|
};
|
|
3809
4246
|
}
|
|
3810
4247
|
function exactDirectory(root, names) {
|
|
@@ -3840,44 +4277,102 @@ function readNativeReceipt(path, label) {
|
|
|
3840
4277
|
const after = await file.stat();
|
|
3841
4278
|
if (!sameFile(before, after) || before.ctimeMs !== after.ctimeMs)
|
|
3842
4279
|
throw new Error("Native receipt changed during read");
|
|
3843
|
-
return bytes
|
|
4280
|
+
return bytes;
|
|
3844
4281
|
});
|
|
3845
4282
|
return yield* attempt(() => {
|
|
3846
4283
|
try {
|
|
3847
|
-
return
|
|
4284
|
+
return {
|
|
4285
|
+
value: JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(data)),
|
|
4286
|
+
size: data.length,
|
|
4287
|
+
digest: "sha256:" + createHash11("sha256").update(data).digest("hex")
|
|
4288
|
+
};
|
|
3848
4289
|
} catch {
|
|
3849
4290
|
throw new Error(`Invalid native receipt JSON: ${label}`);
|
|
3850
4291
|
}
|
|
3851
4292
|
});
|
|
3852
4293
|
}).pipe(Effect16.scoped);
|
|
3853
4294
|
}
|
|
3854
|
-
var
|
|
4295
|
+
var verifiedMatrix = (options, verifyPrior) => Effect16.gen(function* () {
|
|
3855
4296
|
const { config, identity, artifacts, receipts } = options;
|
|
3856
4297
|
const { tag } = identity;
|
|
3857
4298
|
yield* attempt(() => assertDailyIdentity(identity));
|
|
3858
4299
|
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, tag));
|
|
3859
|
-
|
|
3860
|
-
|
|
4300
|
+
if (verifyPrior && matrix.profile !== expandedDesktopDailyProfile)
|
|
4301
|
+
return yield* fail("Pre-signing validation requires the expanded Daily profile");
|
|
4302
|
+
const payloadNames = new Set(matrix.checks.flatMap((check) => check.assets));
|
|
4303
|
+
const selected = verifyPrior ? matrix.assets.filter((name) => payloadNames.has(name)) : matrix.assets;
|
|
4304
|
+
const receiptNames = matrix.checks.map((check) => check.name + ".json");
|
|
4305
|
+
yield* exactDirectory(artifacts, selected);
|
|
4306
|
+
yield* exactDirectory(receipts, receiptNames);
|
|
3861
4307
|
const inventory = new Map;
|
|
3862
|
-
|
|
3863
|
-
|
|
4308
|
+
const checkedReceipts = [];
|
|
4309
|
+
const claims = [];
|
|
4310
|
+
for (const name of selected)
|
|
4311
|
+
inventory.set(name, yield* fileIdentityEffect(join8(artifacts, name), name));
|
|
3864
4312
|
for (const check of matrix.checks) {
|
|
3865
|
-
const
|
|
3866
|
-
yield*
|
|
4313
|
+
const filename = check.name + ".json";
|
|
4314
|
+
const raw = yield* readNativeReceipt(join8(receipts, filename), check.name);
|
|
4315
|
+
checkedReceipts.push({ name: filename, size: raw.size, digest: raw.digest });
|
|
4316
|
+
const valid = yield* attempt(() => validateDailyNativeEvidence(raw.value, "framework/daily-native-receipt/v2", {
|
|
3867
4317
|
appId: matrix.appId,
|
|
4318
|
+
profile: matrix.profile,
|
|
4319
|
+
signing: requiresDailyInstallerSigning(matrix.profile, check) ? installerSigningPolicy(config, check) : undefined,
|
|
3868
4320
|
identity,
|
|
3869
4321
|
check,
|
|
3870
4322
|
assets: check.assets.map((name) => inventory.get(name)),
|
|
3871
4323
|
baselineNames: (priorTag) => priorDailyInstallerNames(config, priorTag, check)
|
|
3872
4324
|
}));
|
|
4325
|
+
if (verifyPrior && "upgrade" in valid.observations) {
|
|
4326
|
+
const claim = {
|
|
4327
|
+
appId: matrix.appId,
|
|
4328
|
+
check: check.name,
|
|
4329
|
+
platform: check.platform,
|
|
4330
|
+
upgrade: valid.observations.upgrade,
|
|
4331
|
+
...valid.installerSigning ? { installerSigning: valid.installerSigning } : {}
|
|
4332
|
+
};
|
|
4333
|
+
claims.push(claim);
|
|
4334
|
+
}
|
|
3873
4335
|
}
|
|
4336
|
+
const assets = [...inventory.values()];
|
|
4337
|
+
if (verifyPrior) {
|
|
4338
|
+
for (const claim of claims)
|
|
4339
|
+
if ((yield* step(() => verifyPrior(claim))) !== true)
|
|
4340
|
+
return yield* fail("Prior Daily installer or payload is not independently authorized");
|
|
4341
|
+
yield* exactDirectory(artifacts, selected);
|
|
4342
|
+
yield* exactDirectory(receipts, receiptNames);
|
|
4343
|
+
for (const [root, files] of [
|
|
4344
|
+
[artifacts, assets],
|
|
4345
|
+
[receipts, checkedReceipts]
|
|
4346
|
+
]) {
|
|
4347
|
+
for (const expected of files) {
|
|
4348
|
+
const actual = yield* fileIdentityEffect(join8(root, expected.name), expected.name);
|
|
4349
|
+
if (actual.digest !== expected.digest || actual.size !== expected.size)
|
|
4350
|
+
return yield* fail("Daily pre-signing input changed during validation");
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
return { profile: matrix.profile, appId: matrix.appId, identity, assets, checkedReceipts };
|
|
4355
|
+
});
|
|
4356
|
+
var verifyDailyReleaseMatrixEffect = (options) => Effect16.map(verifiedMatrix(options), ({ profile, appId, identity, assets }) => ({
|
|
4357
|
+
profile,
|
|
4358
|
+
appId,
|
|
4359
|
+
identity,
|
|
4360
|
+
assets
|
|
4361
|
+
}));
|
|
4362
|
+
var inspectDailyPreSigningEffect = (options, verifyPrior) => Effect16.gen(function* () {
|
|
4363
|
+
if (typeof verifyPrior !== "function")
|
|
4364
|
+
return yield* fail("Expected an independent prior verifier");
|
|
4365
|
+
const { checkedReceipts, ...payloads } = yield* verifiedMatrix(options, verifyPrior);
|
|
3874
4366
|
return {
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
4367
|
+
...payloads,
|
|
4368
|
+
receipts: checkedReceipts,
|
|
4369
|
+
descriptorSigningAuthorized: false,
|
|
4370
|
+
promotionAuthorized: false
|
|
3879
4371
|
};
|
|
3880
4372
|
});
|
|
4373
|
+
function inspectDailyPreSigning(options, verifyPrior) {
|
|
4374
|
+
return runReleaseLibrary(provideLibraryPorts()(inspectDailyPreSigningEffect(options, verifyPrior)));
|
|
4375
|
+
}
|
|
3881
4376
|
function verifyDailyReleaseMatrix(options) {
|
|
3882
4377
|
return runReleaseLibrary(provideLibraryPorts()(verifyDailyReleaseMatrixEffect(options)));
|
|
3883
4378
|
}
|
|
@@ -3903,14 +4398,14 @@ var inspectDailyBatchEffect = (options) => Effect17.gen(function* () {
|
|
|
3903
4398
|
const parsed = yield* attempt(() => parseReleaseConfig(config));
|
|
3904
4399
|
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
3905
4400
|
const receiptNames = matrix.checks.map((check) => `${check.name}.json`);
|
|
3906
|
-
const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(
|
|
4401
|
+
const receiptHashes = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
|
|
3907
4402
|
const verified = yield* verifyDailyReleaseMatrixEffect({
|
|
3908
4403
|
config,
|
|
3909
4404
|
identity,
|
|
3910
4405
|
artifacts,
|
|
3911
4406
|
receipts
|
|
3912
4407
|
});
|
|
3913
|
-
const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(
|
|
4408
|
+
const afterReceipts = yield* Effect17.forEach(receiptNames, (name) => fileIdentityEffect(join9(receipts, name), name));
|
|
3914
4409
|
const after = yield* verifyDailyReleaseMatrixEffect({ config, identity, artifacts, receipts });
|
|
3915
4410
|
if (JSON.stringify(receiptHashes) !== JSON.stringify(afterReceipts) || JSON.stringify(verified.assets) !== JSON.stringify(after.assets) || (yield* step(() => git.run(["--no-replace-objects", "rev-parse", "HEAD"]))) !== identity.sourceSha)
|
|
3916
4411
|
return yield* fail("Daily inputs changed during inspection");
|
|
@@ -4008,9 +4503,9 @@ function createDailyBatchS3Transport(client, bucket) {
|
|
|
4008
4503
|
}
|
|
4009
4504
|
async function* empty() {}
|
|
4010
4505
|
// src/library/daily-native-receipt.ts
|
|
4011
|
-
import { join as
|
|
4506
|
+
import { join as join10 } from "path";
|
|
4012
4507
|
import { Effect as Effect18 } from "effect";
|
|
4013
|
-
var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function* () {
|
|
4508
|
+
var createDailyNativeReceiptEffect = (options, worker, observedSigning) => Effect18.gen(function* () {
|
|
4014
4509
|
const { config, identity, artifacts, checkName, report } = options;
|
|
4015
4510
|
yield* attempt(() => assertDailyIdentity(identity));
|
|
4016
4511
|
const matrix = yield* attempt(() => planDailyReleaseMatrix(config, identity.tag));
|
|
@@ -4020,18 +4515,27 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function*
|
|
|
4020
4515
|
const [os, arch] = platformTargets[check.platform];
|
|
4021
4516
|
if (worker.os !== os || worker.arch !== arch)
|
|
4022
4517
|
return yield* fail(`Daily native check requires ${check.platform}`);
|
|
4518
|
+
const signing = requiresDailyInstallerSigning(matrix.profile, check) ? yield* attempt(() => installerSigningPolicy(config, check)) : undefined;
|
|
4519
|
+
if (signing && !observedSigning)
|
|
4520
|
+
return yield* fail("Expanded Daily installers require proof from the live native observer");
|
|
4023
4521
|
const fs = yield* ReleaseFs;
|
|
4024
4522
|
const dir = yield* step(() => fs.lstat(artifacts));
|
|
4025
4523
|
if (!dir.isDirectory() || dir.isSymbolicLink())
|
|
4026
4524
|
return yield* fail("Expected real native artifact directory");
|
|
4027
|
-
const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(
|
|
4525
|
+
const assets = yield* Effect18.forEach(check.assets, (name) => fileIdentityEffect(join10(artifacts, name), name));
|
|
4028
4526
|
const evidence = yield* attempt(() => validateDailyNativeEvidence(report, "framework/daily-native-job/v1", {
|
|
4029
4527
|
appId: matrix.appId,
|
|
4528
|
+
profile: matrix.profile,
|
|
4529
|
+
signing,
|
|
4030
4530
|
identity,
|
|
4031
4531
|
check,
|
|
4032
4532
|
assets,
|
|
4033
4533
|
baselineNames: (tag) => priorDailyInstallerNames(config, tag, check)
|
|
4034
4534
|
}));
|
|
4535
|
+
if (check.windowsClient && (!worker.windowsClient || worker.windowsClient.release !== evidence.host.windowsClient?.release || worker.windowsClient.build !== evidence.host.windowsClient?.build))
|
|
4536
|
+
return yield* fail("Native receipt does not match the measured Windows host");
|
|
4537
|
+
if (signing && JSON.stringify(observedSigning) !== JSON.stringify(evidence.installerSigning))
|
|
4538
|
+
return yield* fail("Native receipt does not match observed installer signing");
|
|
4035
4539
|
if ("upgrade" in evidence.observations) {
|
|
4036
4540
|
if (!options.baselineArtifacts)
|
|
4037
4541
|
return yield* fail("Daily desktop check requires the exact baseline installer");
|
|
@@ -4042,7 +4546,7 @@ var createDailyNativeReceiptEffect = (options, worker) => Effect18.gen(function*
|
|
|
4042
4546
|
const { baselineAsset, baselineOrigin } = evidence.observations.upgrade;
|
|
4043
4547
|
const proofFiles = baselineOrigin.kind === "private-from-verified-payload" ? [baselineAsset, baselineOrigin.payload] : [baselineAsset];
|
|
4044
4548
|
for (const expected of proofFiles) {
|
|
4045
|
-
const observed = yield* fileIdentityEffect(
|
|
4549
|
+
const observed = yield* fileIdentityEffect(join10(baselineDirectory, expected.name), expected.name);
|
|
4046
4550
|
if (observed.size !== expected.size || observed.digest !== expected.digest)
|
|
4047
4551
|
return yield* fail("Daily desktop baseline installer or prior payload differs from native observations");
|
|
4048
4552
|
}
|
|
@@ -4066,47 +4570,59 @@ function createDailyNativeReceipt(options) {
|
|
|
4066
4570
|
})));
|
|
4067
4571
|
}
|
|
4068
4572
|
// src/library/linux-reproducibility.ts
|
|
4069
|
-
import { createHash as
|
|
4070
|
-
import { lstat as lstat6, readFile as
|
|
4071
|
-
import { isAbsolute as isAbsolute2, join as
|
|
4573
|
+
import { createHash as createHash12 } from "crypto";
|
|
4574
|
+
import { lstat as lstat6, readFile as readFile6, readdir as readdir4, realpath } from "fs/promises";
|
|
4575
|
+
import { isAbsolute as isAbsolute2, join as join11, resolve as resolve6 } from "path";
|
|
4576
|
+
|
|
4577
|
+
// src/library/linux-package-architecture.ts
|
|
4578
|
+
var linuxPackageArchitectures = {
|
|
4579
|
+
x64: { platform: "linux-x64", debian: "amd64", appImage: "x86_64", elfMachine: 62 },
|
|
4580
|
+
arm64: { platform: "linux-arm64", debian: "arm64", appImage: "aarch64", elfMachine: 183 }
|
|
4581
|
+
};
|
|
4582
|
+
function isLinuxPackageArchitecture(value) {
|
|
4583
|
+
return value === "x64" || value === "arm64";
|
|
4584
|
+
}
|
|
4585
|
+
|
|
4586
|
+
// src/library/linux-reproducibility.ts
|
|
4072
4587
|
var sha256 = /^[a-f0-9]{64}$/;
|
|
4073
|
-
var
|
|
4588
|
+
var digest3 = /^sha256:[a-f0-9]{64}$/;
|
|
4074
4589
|
var circleciImage = /^ubuntu-2404:[0-9]{4}\.(?:0[1-9]|1[0-2])\.[0-9]+$/;
|
|
4075
4590
|
var identifier = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$/;
|
|
4076
4591
|
var filename = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/;
|
|
4077
|
-
function
|
|
4592
|
+
function check2(ok, message) {
|
|
4078
4593
|
if (!ok)
|
|
4079
4594
|
throw new Error(message);
|
|
4080
4595
|
}
|
|
4081
4596
|
async function regular(path) {
|
|
4082
|
-
|
|
4597
|
+
check2(typeof path === "string" && isAbsolute2(path), "Expected an absolute input path");
|
|
4083
4598
|
const stat = await lstat6(path);
|
|
4084
|
-
|
|
4085
|
-
|
|
4599
|
+
check2(stat.isFile() && !stat.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real regular input file");
|
|
4600
|
+
check2(Number.isSafeInteger(stat.size) && stat.size > 0, "Invalid input file size");
|
|
4086
4601
|
const result = await hashFileAt(path, stat, "Input changed during comparison");
|
|
4087
4602
|
const after = await lstat6(path);
|
|
4088
|
-
|
|
4603
|
+
check2(after.isFile() && !after.isSymbolicLink() && after.dev === stat.dev && after.ino === stat.ino && after.size === stat.size && after.mtimeMs === stat.mtimeMs && after.ctimeMs === stat.ctimeMs, "Input changed during comparison");
|
|
4089
4604
|
return { ...result, dev: stat.dev, ino: stat.ino };
|
|
4090
4605
|
}
|
|
4091
4606
|
async function outputDirectory(path, expected) {
|
|
4092
|
-
|
|
4607
|
+
check2(typeof path === "string" && isAbsolute2(path), "Expected an absolute output directory");
|
|
4093
4608
|
const info = await lstat6(path);
|
|
4094
|
-
|
|
4609
|
+
check2(info.isDirectory() && !info.isSymbolicLink() && await realpath(path) === resolve6(path), "Expected a real output directory");
|
|
4095
4610
|
const entries = await readdir4(path, { withFileTypes: true });
|
|
4096
4611
|
const names = new Set(expected);
|
|
4097
|
-
|
|
4612
|
+
check2(names.size === expected.length && entries.length === names.size && entries.every((entry) => entry.isFile() && names.has(entry.name)), "Build output must contain exactly the DEB, AppImage and producer receipt");
|
|
4098
4613
|
return { path, dev: info.dev, ino: info.ino, mtimeMs: info.mtimeMs, ctimeMs: info.ctimeMs };
|
|
4099
4614
|
}
|
|
4100
4615
|
async function directoryUnchanged(before) {
|
|
4101
4616
|
const after = await lstat6(before.path);
|
|
4102
|
-
|
|
4617
|
+
check2(after.isDirectory() && !after.isSymbolicLink() && await realpath(before.path) === resolve6(before.path) && after.dev === before.dev && after.ino === before.ino && after.mtimeMs === before.mtimeMs && after.ctimeMs === before.ctimeMs, "Build output directory changed during comparison");
|
|
4103
4618
|
}
|
|
4104
4619
|
function sameIdentity(a, b) {
|
|
4105
4620
|
return a.tag === b.tag && a.sourceSha === b.sourceSha && a.workflowSha === b.workflowSha && a.runId === b.runId && a.runAttempt === b.runAttempt;
|
|
4106
4621
|
}
|
|
4107
4622
|
async function compareLinuxReproducibility(rawInput) {
|
|
4108
4623
|
const input = structuredClone(rawInput);
|
|
4109
|
-
|
|
4624
|
+
check2(isRecord(input) && hasExactOwnKeys(input, [
|
|
4625
|
+
...Object.hasOwn(input, "architecture") ? ["architecture"] : [],
|
|
4110
4626
|
"config",
|
|
4111
4627
|
"identity",
|
|
4112
4628
|
"sourceDateEpoch",
|
|
@@ -4115,19 +4631,22 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4115
4631
|
"toolchainDigest",
|
|
4116
4632
|
"runs"
|
|
4117
4633
|
]) && isRecord(input.identity) && hasExactOwnKeys(input.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && isRecord(input.archive) && hasExactOwnKeys(input.archive, ["size", "sha256"]), "Invalid Linux comparison input");
|
|
4634
|
+
const architecture = Object.hasOwn(input, "architecture") ? input.architecture : "x64";
|
|
4635
|
+
check2(isLinuxPackageArchitecture(architecture), "Invalid Linux comparison architecture");
|
|
4636
|
+
const target = linuxPackageArchitectures[architecture];
|
|
4118
4637
|
assertDailyIdentity(input.identity);
|
|
4119
|
-
|
|
4120
|
-
|
|
4638
|
+
check2(Number.isSafeInteger(input.sourceDateEpoch) && input.sourceDateEpoch > 0 && input.sourceDateEpoch <= 4294967295 && Number.isSafeInteger(input.archive?.size) && input.archive.size > 0 && sha256.test(input.archive.sha256) && circleciImage.test(input.imageReference) && digest3.test(input.toolchainDigest), "Invalid protected Linux build identity");
|
|
4639
|
+
check2(isRecord(input.config) && typeof input.config.appId === "string", "Invalid app identity");
|
|
4121
4640
|
const requirements = parseReleaseConfig(input.config).requirements(input.identity.tag);
|
|
4122
|
-
const archiveName = requirements.platforms[
|
|
4123
|
-
|
|
4641
|
+
const archiveName = requirements.platforms[target.platform]?.[1];
|
|
4642
|
+
check2(typeof archiveName === "string" && archiveName.endsWith(".tar.zst") && filename.test(archiveName), "Invalid configured Linux archive");
|
|
4124
4643
|
const stem = archiveName.slice(0, -".tar.zst".length);
|
|
4125
4644
|
const artifacts = [`${stem}.deb`, `${stem}.AppImage`];
|
|
4126
4645
|
const outputs = [...artifacts, "linux-format-build.json"];
|
|
4127
|
-
|
|
4128
|
-
|
|
4646
|
+
check2(artifacts.every((name) => filename.test(name)) && new Set(outputs).size === outputs.length, "Invalid configured Linux output names");
|
|
4647
|
+
check2(Array.isArray(input.runs) && input.runs.length === 2, "Exactly two build runs required");
|
|
4129
4648
|
for (const run of input.runs) {
|
|
4130
|
-
|
|
4649
|
+
check2(isRecord(run) && hasExactOwnKeys(run, [
|
|
4131
4650
|
"identity",
|
|
4132
4651
|
"appId",
|
|
4133
4652
|
"sourceDateEpoch",
|
|
@@ -4137,19 +4656,19 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4137
4656
|
"toolchainDigest",
|
|
4138
4657
|
"archive",
|
|
4139
4658
|
"output"
|
|
4140
|
-
]) && isRecord(run.identity) && hasExactOwnKeys(run.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && sameIdentity(run.identity, input.identity) && run.appId === input.config.appId && run.sourceDateEpoch === input.sourceDateEpoch && typeof run.jobId === "string" && identifier.test(run.jobId) && run.platform ===
|
|
4659
|
+
]) && isRecord(run.identity) && hasExactOwnKeys(run.identity, ["tag", "sourceSha", "workflowSha", "runId", "runAttempt"]) && sameIdentity(run.identity, input.identity) && run.appId === input.config.appId && run.sourceDateEpoch === input.sourceDateEpoch && typeof run.jobId === "string" && identifier.test(run.jobId) && run.platform === `linux-${target.appImage}` && run.imageReference === input.imageReference && run.toolchainDigest === input.toolchainDigest && typeof run.archive === "string" && typeof run.output === "string", "Linux build identity mismatch");
|
|
4141
4660
|
}
|
|
4142
4661
|
const first = input.runs[0];
|
|
4143
4662
|
const second = input.runs[1];
|
|
4144
|
-
|
|
4663
|
+
check2(first.jobId !== second.jobId, "Build jobs must be distinct");
|
|
4145
4664
|
const firstDir = await outputDirectory(first.output, outputs);
|
|
4146
4665
|
const secondDir = await outputDirectory(second.output, outputs);
|
|
4147
|
-
|
|
4666
|
+
check2(firstDir.dev !== secondDir.dev || firstDir.ino !== secondDir.ino, "Build output directories must be distinct");
|
|
4148
4667
|
const firstArchive = await regular(first.archive);
|
|
4149
4668
|
const secondArchive = await regular(second.archive);
|
|
4150
4669
|
for (const archive of [firstArchive, secondArchive])
|
|
4151
|
-
|
|
4152
|
-
|
|
4670
|
+
check2(archive.size === input.archive.size && archive.sha256 === input.archive.sha256, "Build archive does not match the independently verified input");
|
|
4671
|
+
check2(firstArchive.dev !== secondArchive.dev || firstArchive.ino !== secondArchive.ino, "Build archive copies must be distinct");
|
|
4153
4672
|
const observed = [
|
|
4154
4673
|
{ path: first.archive, file: firstArchive },
|
|
4155
4674
|
{ path: second.archive, file: secondArchive }
|
|
@@ -4160,37 +4679,39 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4160
4679
|
]);
|
|
4161
4680
|
const result = [];
|
|
4162
4681
|
for (const name of artifacts) {
|
|
4163
|
-
const left = await regular(
|
|
4164
|
-
const right = await regular(
|
|
4682
|
+
const left = await regular(join11(first.output, name));
|
|
4683
|
+
const right = await regular(join11(second.output, name));
|
|
4165
4684
|
for (const file of [left, right]) {
|
|
4166
4685
|
const key = `${file.dev}:${file.ino}`;
|
|
4167
|
-
|
|
4686
|
+
check2(!seen.has(key), "Build inputs and outputs must be independent files");
|
|
4168
4687
|
seen.add(key);
|
|
4169
4688
|
}
|
|
4170
|
-
observed.push({ path:
|
|
4171
|
-
observed.push({ path:
|
|
4172
|
-
|
|
4689
|
+
observed.push({ path: join11(first.output, name), file: left });
|
|
4690
|
+
observed.push({ path: join11(second.output, name), file: right });
|
|
4691
|
+
check2(left.size === right.size && left.sha256 === right.sha256, `Linux build differs: ${name}`);
|
|
4173
4692
|
result.push({ name, size: left.size, sha256: left.sha256 });
|
|
4174
4693
|
}
|
|
4175
4694
|
for (const run of input.runs) {
|
|
4176
|
-
const path =
|
|
4695
|
+
const path = join11(run.output, "linux-format-build.json");
|
|
4177
4696
|
const file = await regular(path);
|
|
4178
4697
|
const key = `${file.dev}:${file.ino}`;
|
|
4179
|
-
|
|
4698
|
+
check2(!seen.has(key), "Build inputs and outputs must be independent files");
|
|
4180
4699
|
seen.add(key);
|
|
4181
4700
|
observed.push({ path, file });
|
|
4182
|
-
|
|
4183
|
-
const bytes = await
|
|
4184
|
-
|
|
4701
|
+
check2(file.size <= 65536, "Producer receipt is too large");
|
|
4702
|
+
const bytes = await readFile6(path);
|
|
4703
|
+
check2(bytes.length === file.size && createHash12("sha256").update(bytes).digest("hex") === file.sha256, "Producer receipt changed");
|
|
4185
4704
|
let receipt;
|
|
4186
4705
|
try {
|
|
4187
4706
|
receipt = JSON.parse(bytes.toString("utf8"));
|
|
4188
4707
|
} catch {
|
|
4189
4708
|
throw new Error("Invalid producer receipt");
|
|
4190
4709
|
}
|
|
4191
|
-
|
|
4710
|
+
check2(isRecord(receipt) && Array.isArray(receipt.artifacts), "Invalid producer receipt");
|
|
4192
4711
|
const receiptArtifacts = receipt.artifacts;
|
|
4193
|
-
|
|
4712
|
+
const workflowBound = ["workflowSha", "runId", "runAttempt"].some((field) => Object.hasOwn(receipt, field));
|
|
4713
|
+
check2((architecture === "x64" || workflowBound) && (!workflowBound || receipt.workflowSha === input.identity.workflowSha && receipt.runId === input.identity.runId && receipt.runAttempt === input.identity.runAttempt) && hasExactOwnKeys(receipt, [
|
|
4714
|
+
...workflowBound ? ["workflowSha", "runId", "runAttempt"] : [],
|
|
4194
4715
|
"schema",
|
|
4195
4716
|
"tag",
|
|
4196
4717
|
"sourceSha",
|
|
@@ -4198,17 +4719,18 @@ async function compareLinuxReproducibility(rawInput) {
|
|
|
4198
4719
|
"platform",
|
|
4199
4720
|
"updateArchiveSha256",
|
|
4200
4721
|
"artifacts"
|
|
4201
|
-
]) && receipt.schema === "linux-package-formats/v1" && receipt.tag === input.identity.tag && receipt.sourceSha === input.identity.sourceSha && receipt.sourceDateEpoch === input.sourceDateEpoch && receipt.platform ===
|
|
4722
|
+
]) && receipt.schema === "linux-package-formats/v1" && receipt.tag === input.identity.tag && receipt.sourceSha === input.identity.sourceSha && receipt.sourceDateEpoch === input.sourceDateEpoch && receipt.platform === target.platform && receipt.updateArchiveSha256 === input.archive.sha256 && receiptArtifacts.length === result.length && result.every((expected) => receiptArtifacts.some((item) => isRecord(item) && hasExactOwnKeys(item, ["name", "size", "sha256"]) && item.name === expected.name && item.size === expected.size && item.sha256 === expected.sha256)), "Producer receipt does not match the checked inputs and outputs");
|
|
4202
4723
|
}
|
|
4203
4724
|
for (const previous of observed) {
|
|
4204
4725
|
const current = await regular(previous.path);
|
|
4205
|
-
|
|
4726
|
+
check2(current.dev === previous.file.dev && current.ino === previous.file.ino && current.size === previous.file.size && current.sha256 === previous.file.sha256, "Input changed during comparison");
|
|
4206
4727
|
}
|
|
4207
4728
|
await directoryUnchanged(firstDir);
|
|
4208
4729
|
await directoryUnchanged(secondDir);
|
|
4209
4730
|
return {
|
|
4210
4731
|
schema: "framework/linux-format-byte-comparison/v1",
|
|
4211
4732
|
qualified: false,
|
|
4733
|
+
platform: target.platform,
|
|
4212
4734
|
appId: input.config.appId,
|
|
4213
4735
|
identity: input.identity,
|
|
4214
4736
|
sourceDateEpoch: input.sourceDateEpoch,
|
|
@@ -4230,7 +4752,7 @@ import {
|
|
|
4230
4752
|
rmSync,
|
|
4231
4753
|
symlinkSync
|
|
4232
4754
|
} from "fs";
|
|
4233
|
-
import { basename as basename4, dirname, join as
|
|
4755
|
+
import { basename as basename4, dirname, join as join12, resolve as resolve7 } from "path";
|
|
4234
4756
|
import { Context as Context2, Effect as Effect19 } from "effect";
|
|
4235
4757
|
|
|
4236
4758
|
// ../../src/release/macos-dmg.ts
|
|
@@ -4262,7 +4784,7 @@ function treeSize(root) {
|
|
|
4262
4784
|
logicalBytes += info.size;
|
|
4263
4785
|
else if (info.isDirectory())
|
|
4264
4786
|
for (const name of readdirSync(path))
|
|
4265
|
-
pending.push(
|
|
4787
|
+
pending.push(join12(path, name));
|
|
4266
4788
|
else if (!info.isSymbolicLink())
|
|
4267
4789
|
throw new Error("Unsupported disk image entry");
|
|
4268
4790
|
if (!Number.isSafeInteger(logicalBytes))
|
|
@@ -4288,11 +4810,11 @@ var createMacosDmgEffect = (options) => Effect19.gen(function* () {
|
|
|
4288
4810
|
const info = yield* attempt(() => lstatSync(app));
|
|
4289
4811
|
if (!app.endsWith(".app") || !info.isDirectory() || info.isSymbolicLink() || !output.endsWith(".dmg"))
|
|
4290
4812
|
return yield* fail("Invalid disk image paths");
|
|
4291
|
-
const staging = yield* Effect19.acquireRelease(attempt(() => mkdtempSync(
|
|
4292
|
-
const payload =
|
|
4813
|
+
const staging = yield* Effect19.acquireRelease(attempt(() => mkdtempSync(join12(dirname(output), ".framework-dmg-"))), (path) => Effect19.sync(() => rmSync(path, { recursive: true, force: true })));
|
|
4814
|
+
const payload = join12(staging, "payload"), image = join12(staging, "result.dmg");
|
|
4293
4815
|
yield* attempt(() => mkdirSync(payload));
|
|
4294
|
-
yield* attempt(() => host.run("/usr/bin/ditto", [app,
|
|
4295
|
-
yield* attempt(() => symlinkSync("/Applications",
|
|
4816
|
+
yield* attempt(() => host.run("/usr/bin/ditto", [app, join12(payload, basename4(app))]));
|
|
4817
|
+
yield* attempt(() => symlinkSync("/Applications", join12(payload, "Applications")));
|
|
4296
4818
|
const capacityMiB = yield* attempt(() => dmgCapacityMiB(treeSize(payload)));
|
|
4297
4819
|
yield* attempt(() => host.run("/usr/bin/hdiutil", [
|
|
4298
4820
|
"create",
|
|
@@ -4324,16 +4846,16 @@ function createMacosDmg(options) {
|
|
|
4324
4846
|
import { Effect as Effect22 } from "effect";
|
|
4325
4847
|
|
|
4326
4848
|
// src/library/local-release.ts
|
|
4327
|
-
import { createHash as
|
|
4849
|
+
import { createHash as createHash14 } from "crypto";
|
|
4328
4850
|
import { constants as constants3 } from "fs";
|
|
4329
|
-
import { dirname as dirname2, join as
|
|
4851
|
+
import { dirname as dirname2, join as join14, resolve as resolve9 } from "path";
|
|
4330
4852
|
import { Cause as Cause2, Effect as Effect21, Exit as Exit3 } from "effect";
|
|
4331
4853
|
|
|
4332
4854
|
// ../../src/native/native-rename.ts
|
|
4333
4855
|
import { randomUUID } from "crypto";
|
|
4334
|
-
import { mkdir as mkdir3, readFile as
|
|
4856
|
+
import { mkdir as mkdir3, readFile as readFile7, rm as rm4, writeFile as writeFile4 } from "fs/promises";
|
|
4335
4857
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
4336
|
-
import { join as
|
|
4858
|
+
import { join as join13 } from "path";
|
|
4337
4859
|
|
|
4338
4860
|
// ../../src/native/canonical-path.ts
|
|
4339
4861
|
import { isAbsolute as isAbsolute3, resolve as resolve8 } from "path";
|
|
@@ -4412,8 +4934,8 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
4412
4934
|
if (!isCanonicalPath(parent))
|
|
4413
4935
|
throw new Error("Invalid directory exchange probe parent");
|
|
4414
4936
|
const id = randomUUID();
|
|
4415
|
-
const first =
|
|
4416
|
-
const second =
|
|
4937
|
+
const first = join13(parent, `.framework-exchange-probe-${id}-a`);
|
|
4938
|
+
const second = join13(parent, `.framework-exchange-probe-${id}-b`);
|
|
4417
4939
|
const marker = "exchange-probe";
|
|
4418
4940
|
const firstValue = `${id}:first`;
|
|
4419
4941
|
const secondValue = `${id}:second`;
|
|
@@ -4424,21 +4946,21 @@ async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
|
4424
4946
|
firstCreated = true;
|
|
4425
4947
|
await mkdir3(second, { mode: 448 });
|
|
4426
4948
|
secondCreated = true;
|
|
4427
|
-
await
|
|
4428
|
-
await
|
|
4949
|
+
await writeFile4(join13(first, marker), firstValue, { flag: "wx", mode: 384 });
|
|
4950
|
+
await writeFile4(join13(second, marker), secondValue, { flag: "wx", mode: 384 });
|
|
4429
4951
|
exchange(first, second);
|
|
4430
4952
|
const [firstAfter, secondAfter] = await Promise.all([
|
|
4431
|
-
|
|
4432
|
-
|
|
4953
|
+
readFile7(join13(first, marker), "utf8"),
|
|
4954
|
+
readFile7(join13(second, marker), "utf8")
|
|
4433
4955
|
]);
|
|
4434
4956
|
if (firstAfter !== secondValue || secondAfter !== firstValue)
|
|
4435
4957
|
throw new Error("Directory exchange did not exchange both probe trees");
|
|
4436
4958
|
} finally {
|
|
4437
4959
|
const cleanup = [];
|
|
4438
4960
|
if (firstCreated)
|
|
4439
|
-
cleanup.push(
|
|
4961
|
+
cleanup.push(rm4(first, { recursive: true, force: true }));
|
|
4440
4962
|
if (secondCreated)
|
|
4441
|
-
cleanup.push(
|
|
4963
|
+
cleanup.push(rm4(second, { recursive: true, force: true }));
|
|
4442
4964
|
await Promise.all(cleanup);
|
|
4443
4965
|
}
|
|
4444
4966
|
}
|
|
@@ -4494,7 +5016,7 @@ function createFeedReleaseCutProvider(options) {
|
|
|
4494
5016
|
}
|
|
4495
5017
|
|
|
4496
5018
|
// src/library/feed-state.ts
|
|
4497
|
-
import { createHash as
|
|
5019
|
+
import { createHash as createHash13 } from "crypto";
|
|
4498
5020
|
import { Effect as Effect20 } from "effect";
|
|
4499
5021
|
|
|
4500
5022
|
// ../../src/shared/discard-stream.ts
|
|
@@ -4742,7 +5264,7 @@ var verifyFeedReleaseEffect = (options) => Effect20.gen(function* () {
|
|
|
4742
5264
|
if (!listed)
|
|
4743
5265
|
return yield* fail(`Missing signed descriptor: ${policy.name}`);
|
|
4744
5266
|
const bytes = yield* feedObject(feed, `${tag}/${policy.name}`, 65536);
|
|
4745
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
5267
|
+
if (!bytes || bytes.length !== listed.size || createHash13("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
4746
5268
|
return yield* fail(`Signed descriptor differs from its release: ${policy.name}`);
|
|
4747
5269
|
const verified = verifyReleaseDescriptor(json(bytes), {
|
|
4748
5270
|
appId: policy.appId,
|
|
@@ -4848,7 +5370,7 @@ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
|
|
|
4848
5370
|
const payloads = platformPayloads(local.requirements(tag), platform);
|
|
4849
5371
|
const directory = resolve9(options.directory);
|
|
4850
5372
|
yield* exactFiles(directory, payloads);
|
|
4851
|
-
const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(
|
|
5373
|
+
const assets = yield* Effect21.forEach(payloads, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
|
|
4852
5374
|
const signed = signDiscoveryDescriptors({
|
|
4853
5375
|
policies: discoveryPolicies(local.config, tag).filter((policy) => policy.platform === platform),
|
|
4854
5376
|
assets,
|
|
@@ -4866,7 +5388,7 @@ var stageLocalDescriptorsEffect = (options) => Effect21.gen(function* () {
|
|
|
4866
5388
|
privateKey: options.privateKey
|
|
4867
5389
|
});
|
|
4868
5390
|
for (const asset of assets)
|
|
4869
|
-
if (JSON.stringify(yield* fileIdentityEffect(
|
|
5391
|
+
if (JSON.stringify(yield* fileIdentityEffect(join14(directory, asset.name), asset.name)) !== JSON.stringify(asset))
|
|
4870
5392
|
return yield* fail("Staged payload changed before signing");
|
|
4871
5393
|
yield* writeDescriptorsEffect(directory, signed);
|
|
4872
5394
|
return signed.map((value) => value.name);
|
|
@@ -4886,7 +5408,7 @@ var jsonBytes = (value) => Buffer.from(JSON.stringify(value, null, 2) + `
|
|
|
4886
5408
|
var describe = (key, bytes, cacheControl) => ({
|
|
4887
5409
|
key,
|
|
4888
5410
|
size: bytes.length,
|
|
4889
|
-
sha256:
|
|
5411
|
+
sha256: createHash14("sha256").update(bytes).digest("hex"),
|
|
4890
5412
|
contentType: "application/json",
|
|
4891
5413
|
cacheControl
|
|
4892
5414
|
});
|
|
@@ -4897,11 +5419,11 @@ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* (
|
|
|
4897
5419
|
if (exists)
|
|
4898
5420
|
return yield* fail("Release output directory already exists");
|
|
4899
5421
|
yield* step(() => fs.mkdir(dirname2(root), { recursive: true, mode: 448 }));
|
|
4900
|
-
const staging = yield* step(() => fs.mkdtemp(
|
|
5422
|
+
const staging = yield* step(() => fs.mkdtemp(join14(dirname2(root), ".release-staging-")));
|
|
4901
5423
|
const exit = yield* Effect21.exit(Effect21.gen(function* () {
|
|
4902
5424
|
const objects = [];
|
|
4903
5425
|
for (const { key, path, artifact } of assets) {
|
|
4904
|
-
const target =
|
|
5426
|
+
const target = join14(staging, key);
|
|
4905
5427
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
4906
5428
|
yield* step(() => fs.copyFile(path, target, constants3.COPYFILE_EXCL));
|
|
4907
5429
|
if (JSON.stringify(yield* fileIdentityEffect(target, artifact.name)) !== JSON.stringify(artifact))
|
|
@@ -4915,13 +5437,13 @@ var writeStagedTree = (out, feed, assets, documents) => Effect21.gen(function* (
|
|
|
4915
5437
|
});
|
|
4916
5438
|
}
|
|
4917
5439
|
for (const { key, bytes } of documents) {
|
|
4918
|
-
const target =
|
|
5440
|
+
const target = join14(staging, key);
|
|
4919
5441
|
yield* step(() => fs.mkdir(dirname2(target), { recursive: true, mode: 448 }));
|
|
4920
5442
|
yield* step(() => fs.writeFile(target, bytes, { flag: "wx", mode: 384 }));
|
|
4921
5443
|
objects.push(describe(key, bytes, MUTABLE));
|
|
4922
5444
|
}
|
|
4923
5445
|
const plan = { schema: 1, base: feed.base, objects };
|
|
4924
|
-
yield* step(() => fs.writeFile(
|
|
5446
|
+
yield* step(() => fs.writeFile(join14(staging, UPLOAD_PLAN), jsonBytes(plan), { flag: "wx", mode: 384 }));
|
|
4925
5447
|
yield* attempt(() => renameExclusive(staging, root));
|
|
4926
5448
|
return plan;
|
|
4927
5449
|
}));
|
|
@@ -4969,13 +5491,13 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
|
4969
5491
|
const directory = resolve9(options.directory);
|
|
4970
5492
|
const names = [...payloads, ...policies.map((policy) => policy.name)];
|
|
4971
5493
|
yield* exactFiles(directory, names);
|
|
4972
|
-
const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(
|
|
5494
|
+
const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join14(directory, name), name), { concurrency: "unbounded" });
|
|
4973
5495
|
for (const policy of policies) {
|
|
4974
5496
|
const artifact = staged.find((asset) => asset.name === policy.name);
|
|
4975
5497
|
if (artifact.size > 65536)
|
|
4976
5498
|
return yield* fail("Signed descriptor is too large");
|
|
4977
|
-
const bytes = yield* step(() => fs.readFile(
|
|
4978
|
-
if ("sha256:" +
|
|
5499
|
+
const bytes = yield* step(() => fs.readFile(join14(directory, policy.name)));
|
|
5500
|
+
if ("sha256:" + createHash14("sha256").update(bytes).digest("hex") !== artifact.digest)
|
|
4979
5501
|
return yield* fail("Signed descriptor changed");
|
|
4980
5502
|
let parsed;
|
|
4981
5503
|
try {
|
|
@@ -5014,7 +5536,7 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
|
5014
5536
|
merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
|
|
5015
5537
|
uploads.push({
|
|
5016
5538
|
key: feedAssetKey(feed, tag, artifact.name),
|
|
5017
|
-
path:
|
|
5539
|
+
path: join14(directory, artifact.name),
|
|
5018
5540
|
artifact
|
|
5019
5541
|
});
|
|
5020
5542
|
}
|
|
@@ -5334,12 +5856,12 @@ var selectRetainedReleaseBuildEffect = (options) => Effect23.gen(function* () {
|
|
|
5334
5856
|
});
|
|
5335
5857
|
var selectRetainedReleaseBuild = (options) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(options.env, options.run) })(selectRetainedReleaseBuildEffect(options)));
|
|
5336
5858
|
// src/library/staging.ts
|
|
5337
|
-
import { createHash as
|
|
5338
|
-
import { join as
|
|
5859
|
+
import { createHash as createHash15 } from "crypto";
|
|
5860
|
+
import { join as join15, resolve as resolve10 } from "path";
|
|
5339
5861
|
import { Effect as Effect24 } from "effect";
|
|
5340
5862
|
var copyHashed = (input, output, size) => Effect24.tryPromise({
|
|
5341
5863
|
try: async (signal) => {
|
|
5342
|
-
const hash =
|
|
5864
|
+
const hash = createHash15("sha256");
|
|
5343
5865
|
let copied = 0;
|
|
5344
5866
|
for await (const chunk of input.createReadStream({
|
|
5345
5867
|
autoClose: false
|
|
@@ -5384,7 +5906,7 @@ var stageExpectedFilesEffect = (options) => Effect24.gen(function* () {
|
|
|
5384
5906
|
const before = yield* step(() => input.stat());
|
|
5385
5907
|
if (!before.isFile() || before.dev !== sourceInfo.dev || before.ino !== sourceInfo.ino || before.size !== sourceInfo.size)
|
|
5386
5908
|
return yield* fail("Staging source changed");
|
|
5387
|
-
const target =
|
|
5909
|
+
const target = join15(directory, name);
|
|
5388
5910
|
const output = yield* scopedHandle(() => fs.open(target, "wx"));
|
|
5389
5911
|
created.push(target);
|
|
5390
5912
|
const copied = yield* copyHashed(input, output, before.size);
|
|
@@ -5405,11 +5927,11 @@ var stagePlatformArtifactsEffect = (options) => Effect24.gen(function* () {
|
|
|
5405
5927
|
});
|
|
5406
5928
|
var stagePlatformArtifacts = (options) => runReleaseLibrary(provideLibraryPorts()(stagePlatformArtifactsEffect(options)));
|
|
5407
5929
|
// src/library/steps.ts
|
|
5408
|
-
import { join as
|
|
5930
|
+
import { join as join35 } from "path";
|
|
5409
5931
|
import { Effect as Effect25 } from "effect";
|
|
5410
5932
|
|
|
5411
5933
|
// ../../src/installer/installer-archive-members.ts
|
|
5412
|
-
import { createHash as
|
|
5934
|
+
import { createHash as createHash16 } from "crypto";
|
|
5413
5935
|
import { lstat as lstat7, open as open4 } from "fs/promises";
|
|
5414
5936
|
import { isAbsolute as isAbsolute4, relative as relative3, sep as sep2 } from "path";
|
|
5415
5937
|
|
|
@@ -5418,8 +5940,8 @@ async function assertNativeExecutable(file, size, platform, what) {
|
|
|
5418
5940
|
const head = Buffer.alloc(64);
|
|
5419
5941
|
if ((await file.read(head, 0, head.length, 0)).bytesRead !== head.length)
|
|
5420
5942
|
throw new Error(`Invalid ${what}`);
|
|
5421
|
-
if (platform
|
|
5422
|
-
if (head.readUInt32LE(0) !== 4277009103 || head.readUInt32LE(4) !== 16777228)
|
|
5943
|
+
if (isMacInstallerPlatform(platform)) {
|
|
5944
|
+
if (head.readUInt32LE(0) !== 4277009103 || head.readUInt32LE(4) !== (platform === "macos-arm64" ? 16777228 : 16777223))
|
|
5423
5945
|
throw new Error(`Invalid macOS ${what}`);
|
|
5424
5946
|
} else if (platform === "linux-x64" || platform === "linux-arm64") {
|
|
5425
5947
|
if (!head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) || head[4] !== 2 || head.readUInt16LE(18) !== (platform === "linux-x64" ? 62 : 183))
|
|
@@ -5516,7 +6038,7 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
5516
6038
|
const position = size - archive.size - marker.length, actual = Buffer.alloc(marker.length);
|
|
5517
6039
|
if ((await file.read(actual, 0, actual.length, position)).bytesRead !== actual.length || !actual.equals(marker))
|
|
5518
6040
|
throw new Error("Installer archive marker is missing");
|
|
5519
|
-
const hash =
|
|
6041
|
+
const hash = createHash16("sha256");
|
|
5520
6042
|
let read = 0;
|
|
5521
6043
|
for await (const chunk of file.createReadStream({
|
|
5522
6044
|
start: position + marker.length,
|
|
@@ -5533,13 +6055,13 @@ async function assertEmbeddedArchive(path, size, archive) {
|
|
|
5533
6055
|
}
|
|
5534
6056
|
|
|
5535
6057
|
// ../../src/installer/installer-identity.ts
|
|
5536
|
-
import { lstat as lstat9, mkdtemp as
|
|
5537
|
-
import { tmpdir as
|
|
5538
|
-
import { basename as basename5, join as
|
|
6058
|
+
import { lstat as lstat9, mkdtemp as mkdtemp5, readdir as readdir6, realpath as realpath2 } from "fs/promises";
|
|
6059
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
6060
|
+
import { basename as basename5, join as join17, resolve as resolve11, win32 as win322 } from "path";
|
|
5539
6061
|
|
|
5540
6062
|
// ../../src/installer/installer-image-mount.ts
|
|
5541
|
-
import { lstat as lstat8, mkdir as mkdir4, mkdtemp as
|
|
5542
|
-
import { dirname as dirname3, join as
|
|
6063
|
+
import { lstat as lstat8, mkdir as mkdir4, mkdtemp as mkdtemp4, readdir as readdir5, rm as rm5, stat } from "fs/promises";
|
|
6064
|
+
import { dirname as dirname3, join as join16 } from "path";
|
|
5543
6065
|
var FAILED_ATTACH_PROBES = 5;
|
|
5544
6066
|
var FAILED_ATTACH_PROBE_INTERVAL_MS = 500;
|
|
5545
6067
|
async function containsMountAt(path, expectedDevice) {
|
|
@@ -5549,7 +6071,7 @@ async function containsMountAt(path, expectedDevice) {
|
|
|
5549
6071
|
if (info.dev !== expectedDevice)
|
|
5550
6072
|
return true;
|
|
5551
6073
|
for (const name of await readdir5(path)) {
|
|
5552
|
-
const child =
|
|
6074
|
+
const child = join16(path, name), childInfo = await lstat8(child);
|
|
5553
6075
|
if (!childInfo.isDirectory() || childInfo.isSymbolicLink())
|
|
5554
6076
|
continue;
|
|
5555
6077
|
if (childInfo.dev !== info.dev || await containsMountAt(child, info.dev))
|
|
@@ -5575,7 +6097,7 @@ function defaultInstallerImageMountIo(run) {
|
|
|
5575
6097
|
state: installerImageMountState,
|
|
5576
6098
|
containsNestedMount,
|
|
5577
6099
|
wait: Bun.sleep,
|
|
5578
|
-
remove: (directory) =>
|
|
6100
|
+
remove: (directory) => rm5(directory, { recursive: true, force: true })
|
|
5579
6101
|
};
|
|
5580
6102
|
}
|
|
5581
6103
|
async function assertNoNestedInstallerMount(directory, io) {
|
|
@@ -5743,8 +6265,8 @@ async function withInstallerImageRetries(options) {
|
|
|
5743
6265
|
};
|
|
5744
6266
|
const priorErrors = () => failedAttempts.map((attempt) => attempt.error);
|
|
5745
6267
|
for (let attempt = 1;attempt <= maximumAttempts; attempt++) {
|
|
5746
|
-
const directory = await
|
|
5747
|
-
const mount =
|
|
6268
|
+
const directory = await mkdtemp4(join16(options.parent, options.prefix));
|
|
6269
|
+
const mount = join16(directory, "mount");
|
|
5748
6270
|
const io = options.createIo?.(directory, mount) ?? defaultInstallerImageMountIo(options.run);
|
|
5749
6271
|
let lifecycleStarted = false;
|
|
5750
6272
|
try {
|
|
@@ -5911,7 +6433,7 @@ async function runInstallerCommand(args, env, options) {
|
|
|
5911
6433
|
}
|
|
5912
6434
|
|
|
5913
6435
|
// ../../src/installer/installer-identity.ts
|
|
5914
|
-
async function
|
|
6436
|
+
async function identity2(path) {
|
|
5915
6437
|
const info = await lstat9(path);
|
|
5916
6438
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || !Number.isSafeInteger(info.size))
|
|
5917
6439
|
throw new Error("Invalid installer artifact");
|
|
@@ -5940,16 +6462,16 @@ async function verifyInstallerPayload(options) {
|
|
|
5940
6462
|
assertInstallerContext(parent, options.platform, process.platform, process.arch);
|
|
5941
6463
|
assertPortableAppName(options.appName);
|
|
5942
6464
|
const installerPath = resolve11(options.installer), archivePath = resolve11(options.archive);
|
|
5943
|
-
const before = { installer: await
|
|
6465
|
+
const before = { installer: await identity2(installerPath), archive: await identity2(archivePath) };
|
|
5944
6466
|
if (!Number.isSafeInteger(before.archive.size + 256 * 1024 * 1024))
|
|
5945
6467
|
throw new Error("Installer archive exceeds bound");
|
|
5946
6468
|
const env = environment(parent);
|
|
5947
|
-
const temporary = await
|
|
6469
|
+
const temporary = await mkdtemp5(join17(tmpdir5(), "framework-installer-inspect-"));
|
|
5948
6470
|
const cleanupIo = defaultInstallerImageMountIo(command);
|
|
5949
6471
|
try {
|
|
5950
|
-
if (options.platform
|
|
6472
|
+
if (isMacInstallerPlatform(options.platform)) {
|
|
5951
6473
|
await withInstallerImageRetries({
|
|
5952
|
-
parent:
|
|
6474
|
+
parent: tmpdir5(),
|
|
5953
6475
|
prefix: "framework-installer-inspect-attempt-",
|
|
5954
6476
|
image: installerPath,
|
|
5955
6477
|
env,
|
|
@@ -5958,21 +6480,21 @@ async function verifyInstallerPayload(options) {
|
|
|
5958
6480
|
const apps = (await readdir6(mount)).filter((name) => name.endsWith(".app"));
|
|
5959
6481
|
if (apps.length !== 1)
|
|
5960
6482
|
throw new Error("Installer application is missing or ambiguous");
|
|
5961
|
-
const resources =
|
|
5962
|
-
const actualRoot = await realpath2(mount), actualApp = await realpath2(
|
|
6483
|
+
const resources = join17(mount, apps[0], "Contents", "Resources");
|
|
6484
|
+
const actualRoot = await realpath2(mount), actualApp = await realpath2(join17(mount, apps[0])), actualResources = await realpath2(resources);
|
|
5963
6485
|
if (!isWithin(actualRoot, actualApp) || !isWithin(actualApp, actualResources))
|
|
5964
6486
|
throw new Error("Installer resources escape mounted image");
|
|
5965
|
-
const plist =
|
|
6487
|
+
const plist = join17(actualApp, "Contents", "Info.plist"), plistInfo = await lstat9(plist);
|
|
5966
6488
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
5967
6489
|
throw new Error("Invalid installer property list");
|
|
5968
6490
|
const executable = (await command(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], env)).trim();
|
|
5969
6491
|
if (!executable || executable === "." || executable === ".." || /[\\/]/.test(executable))
|
|
5970
6492
|
throw new Error("Invalid installer executable name");
|
|
5971
|
-
await assertInstallerExecutable(
|
|
6493
|
+
await assertInstallerExecutable(join17(actualApp, "Contents", "MacOS", executable), options.platform);
|
|
5972
6494
|
const archives = (await readdir6(actualResources)).filter((name) => name.endsWith(".tar.zst"));
|
|
5973
6495
|
if (archives.length !== 1)
|
|
5974
6496
|
throw new Error("Installer archive is missing or ambiguous");
|
|
5975
|
-
const embedded = await
|
|
6497
|
+
const embedded = await identity2(join17(actualResources, archives[0]));
|
|
5976
6498
|
if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
|
|
5977
6499
|
throw new Error("Installer archive differs from release archive");
|
|
5978
6500
|
}
|
|
@@ -5981,7 +6503,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5981
6503
|
const systemRoot = parent.SystemRoot;
|
|
5982
6504
|
if (options.platform === "windows-x64" && (!systemRoot || !/^[A-Za-z]:[\\/]/.test(systemRoot)))
|
|
5983
6505
|
throw new Error("Missing Windows system directory");
|
|
5984
|
-
const tar = options.platform === "windows-x64" ?
|
|
6506
|
+
const tar = options.platform === "windows-x64" ? win322.join(systemRoot, "System32", "tar.exe") : "tar";
|
|
5985
6507
|
if (options.platform === "windows-x64" && !/^bsdtar\s/i.test((await command([tar, "--version"], env)).trim()))
|
|
5986
6508
|
throw new Error("Windows installer inspection requires system bsdtar");
|
|
5987
6509
|
const names = (await command([tar, "-tf", installerPath], env)).split(/\r?\n/).filter(Boolean);
|
|
@@ -5990,7 +6512,7 @@ async function verifyInstallerPayload(options) {
|
|
|
5990
6512
|
const matches = names.filter((name) => candidates.includes(normalizeArchiveMember(name)));
|
|
5991
6513
|
if (matches.length !== 1)
|
|
5992
6514
|
throw new Error("Installer archive is missing or ambiguous");
|
|
5993
|
-
const extracted =
|
|
6515
|
+
const extracted = join17(temporary, "member");
|
|
5994
6516
|
const count = await extractArchiveMember({
|
|
5995
6517
|
tar,
|
|
5996
6518
|
archive: installerPath,
|
|
@@ -6001,7 +6523,7 @@ async function verifyInstallerPayload(options) {
|
|
|
6001
6523
|
});
|
|
6002
6524
|
if (options.platform === "windows-x64") {
|
|
6003
6525
|
const setup = findArchiveMember(names, `${options.appName}-Setup.exe`, options.platform, "Installer executable is missing or ambiguous");
|
|
6004
|
-
const executable =
|
|
6526
|
+
const executable = join17(temporary, "setup.exe");
|
|
6005
6527
|
await extractArchiveMember({
|
|
6006
6528
|
tar,
|
|
6007
6529
|
archive: installerPath,
|
|
@@ -6011,7 +6533,7 @@ async function verifyInstallerPayload(options) {
|
|
|
6011
6533
|
env
|
|
6012
6534
|
});
|
|
6013
6535
|
await assertInstallerExecutable(executable, options.platform);
|
|
6014
|
-
const embedded = await
|
|
6536
|
+
const embedded = await identity2(extracted);
|
|
6015
6537
|
if (embedded.size !== before.archive.size || embedded.digest !== before.archive.digest)
|
|
6016
6538
|
throw new Error("Installer archive differs from release archive");
|
|
6017
6539
|
} else {
|
|
@@ -6019,7 +6541,7 @@ async function verifyInstallerPayload(options) {
|
|
|
6019
6541
|
await assertEmbeddedArchive(extracted, count, before.archive);
|
|
6020
6542
|
}
|
|
6021
6543
|
}
|
|
6022
|
-
const after = { installer: await
|
|
6544
|
+
const after = { installer: await identity2(installerPath), archive: await identity2(archivePath) };
|
|
6023
6545
|
if (JSON.stringify(before) !== JSON.stringify(after))
|
|
6024
6546
|
throw new Error("Installer artifacts changed during inspection");
|
|
6025
6547
|
await cleanupInstallerDirectoryAfterFailure(temporary, undefined, cleanupIo);
|
|
@@ -6037,19 +6559,19 @@ async function verifyInstallerPayload(options) {
|
|
|
6037
6559
|
}
|
|
6038
6560
|
|
|
6039
6561
|
// ../../src/installer/installer-qualification-command.ts
|
|
6040
|
-
import { lstat as lstat19, writeFile as
|
|
6041
|
-
import { join as
|
|
6562
|
+
import { lstat as lstat19, writeFile as writeFile10 } from "fs/promises";
|
|
6563
|
+
import { join as join32, resolve as resolve14 } from "path";
|
|
6042
6564
|
|
|
6043
6565
|
// ../../src/installer/installer-observation.ts
|
|
6044
6566
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
6045
|
-
import { chmod as chmod2, mkdir as mkdir9, readFile as
|
|
6567
|
+
import { chmod as chmod2, mkdir as mkdir9, readFile as readFile11, realpath as realpath9, writeFile as writeFile9 } from "fs/promises";
|
|
6046
6568
|
import { createServer } from "net";
|
|
6047
|
-
import { delimiter, dirname as dirname12, join as
|
|
6569
|
+
import { delimiter, dirname as dirname12, join as join31 } from "path";
|
|
6048
6570
|
|
|
6049
6571
|
// ../../src/installer/installer-ci-bootstrap.ts
|
|
6050
6572
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
6051
|
-
import { lstat as lstat10, mkdir as mkdir5, mkdtemp as
|
|
6052
|
-
import { dirname as dirname4, isAbsolute as isAbsolute5, join as
|
|
6573
|
+
import { lstat as lstat10, mkdir as mkdir5, mkdtemp as mkdtemp6, realpath as realpath3, rm as rm6, writeFile as writeFile5 } from "fs/promises";
|
|
6574
|
+
import { dirname as dirname4, isAbsolute as isAbsolute5, join as join18, relative as relative4, sep as sep3 } from "path";
|
|
6053
6575
|
import { fileURLToPath } from "url";
|
|
6054
6576
|
var bootstrapModules = [
|
|
6055
6577
|
"app/value-guards.js",
|
|
@@ -6076,27 +6598,27 @@ async function prepareInstallerCiBootstrap(env = process.env) {
|
|
|
6076
6598
|
if (/\s/.test(parent) || !(await lstat10(parent)).isDirectory())
|
|
6077
6599
|
throw new Error("Runner temp cannot represent a Bun preload path");
|
|
6078
6600
|
const source = dirname4(dirname4(fileURLToPath(import.meta.url)));
|
|
6079
|
-
const directory = await
|
|
6601
|
+
const directory = await mkdtemp6(join18(parent, "framework-ci-"));
|
|
6080
6602
|
try {
|
|
6081
6603
|
for (const name of bootstrapModules) {
|
|
6082
|
-
const contents = await readBoundedFile(
|
|
6083
|
-
await mkdir5(dirname4(
|
|
6084
|
-
await
|
|
6604
|
+
const contents = await readBoundedFile(join18(source, name), 2 * 1024 * 1024, "installer bootstrap module");
|
|
6605
|
+
await mkdir5(dirname4(join18(directory, name)), { recursive: true, mode: 448 });
|
|
6606
|
+
await writeFile5(join18(directory, name), contents, { flag: "wx", mode: 384 });
|
|
6085
6607
|
}
|
|
6086
|
-
await
|
|
6608
|
+
await writeFile5(join18(directory, "package.json"), `{"type":"module"}
|
|
6087
6609
|
`, {
|
|
6088
6610
|
flag: "wx",
|
|
6089
6611
|
mode: 384
|
|
6090
6612
|
});
|
|
6091
|
-
const worker =
|
|
6613
|
+
const worker = join18(directory, "installer/installer-ci-worker.js");
|
|
6092
6614
|
return {
|
|
6093
6615
|
directory,
|
|
6094
6616
|
worker,
|
|
6095
|
-
preflight:
|
|
6617
|
+
preflight: join18(directory, "installer/installer-ci-preflight.js"),
|
|
6096
6618
|
bunOptions: `--preload=${worker}`
|
|
6097
6619
|
};
|
|
6098
6620
|
} catch (error) {
|
|
6099
|
-
await
|
|
6621
|
+
await rm6(directory, { recursive: true, force: true });
|
|
6100
6622
|
throw error;
|
|
6101
6623
|
}
|
|
6102
6624
|
}
|
|
@@ -6107,7 +6629,7 @@ async function preflightInstallerRuntime(options) {
|
|
|
6107
6629
|
throw new Error("Runtime preflight requires a disposable hosted runner");
|
|
6108
6630
|
const tempRoot = await realpath3(temp), bootstrapRoot = await realpath3(bootstrap.directory);
|
|
6109
6631
|
const relativeBootstrap = relative4(tempRoot, bootstrapRoot);
|
|
6110
|
-
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute5(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !==
|
|
6632
|
+
if (!relativeBootstrap || relativeBootstrap === ".." || relativeBootstrap.startsWith(".." + sep3) || isAbsolute5(relativeBootstrap) || /\s/.test(bootstrapRoot) || bootstrap.worker !== join18(bootstrapRoot, "installer/installer-ci-worker.js") || bootstrap.preflight !== join18(bootstrapRoot, "installer/installer-ci-preflight.js") || bootstrap.bunOptions !== `--preload=${bootstrap.worker}`)
|
|
6111
6633
|
throw new Error("Invalid installer bootstrap location");
|
|
6112
6634
|
await runInstallerPreflight({
|
|
6113
6635
|
env,
|
|
@@ -6127,7 +6649,7 @@ async function runInstallerPreflight(options) {
|
|
|
6127
6649
|
const info = await lstat10(runtime);
|
|
6128
6650
|
if (!info.isFile() || info.isSymbolicLink() || info.size < 4096)
|
|
6129
6651
|
throw new Error("Invalid candidate Bun runtime");
|
|
6130
|
-
const temporary = await
|
|
6652
|
+
const temporary = await mkdtemp6(join18(options.parent, "framework-preflight-"));
|
|
6131
6653
|
try {
|
|
6132
6654
|
const clean = {};
|
|
6133
6655
|
for (const key of [
|
|
@@ -6152,11 +6674,11 @@ async function runInstallerPreflight(options) {
|
|
|
6152
6674
|
BUN_OPTIONS: `--preload=${worker}`,
|
|
6153
6675
|
FRAMEWORK_CI_WORKER_ENTRY: preflight,
|
|
6154
6676
|
FRAMEWORK_CI_NONCE: nonce,
|
|
6155
|
-
FRAMEWORK_CI_ACK:
|
|
6156
|
-
FRAMEWORK_CI_PERMIT:
|
|
6677
|
+
FRAMEWORK_CI_ACK: join18(temporary, "ack"),
|
|
6678
|
+
FRAMEWORK_CI_PERMIT: join18(temporary, "permit"),
|
|
6157
6679
|
FRAMEWORK_CI_ORIGIN: "http://127.0.0.1:48999",
|
|
6158
|
-
FRAMEWORK_CI_OBSERVATION:
|
|
6159
|
-
FRAMEWORK_CI_UNEXPECTED:
|
|
6680
|
+
FRAMEWORK_CI_OBSERVATION: join18(temporary, "observation"),
|
|
6681
|
+
FRAMEWORK_CI_UNEXPECTED: join18(temporary, "unexpected"),
|
|
6160
6682
|
FRAMEWORK_CI_EXPECTED_READS: JSON.stringify([
|
|
6161
6683
|
"https://example.invalid/framework-ci-sentinel"
|
|
6162
6684
|
])
|
|
@@ -6191,28 +6713,28 @@ async function runInstallerPreflight(options) {
|
|
|
6191
6713
|
if (status !== 0 || !stdout.includes("framework installer preload preflight passed"))
|
|
6192
6714
|
throw new Error("Candidate Bun runtime failed installer preflight");
|
|
6193
6715
|
try {
|
|
6194
|
-
await lstat10(
|
|
6716
|
+
await lstat10(join18(temporary, "unexpected"));
|
|
6195
6717
|
throw new Error("Runtime preflight recorded unexpected activity");
|
|
6196
6718
|
} catch (error) {
|
|
6197
6719
|
if (errorCode(error) !== "ENOENT")
|
|
6198
6720
|
throw error;
|
|
6199
6721
|
}
|
|
6200
6722
|
} finally {
|
|
6201
|
-
await
|
|
6723
|
+
await rm6(temporary, { recursive: true, force: true });
|
|
6202
6724
|
}
|
|
6203
6725
|
}
|
|
6204
6726
|
|
|
6205
6727
|
// ../../src/installer/installer-extraction.ts
|
|
6206
|
-
import { chmod, lstat as lstat11, mkdir as mkdir6, mkdtemp as
|
|
6207
|
-
import { join as
|
|
6208
|
-
async function
|
|
6728
|
+
import { chmod, lstat as lstat11, mkdir as mkdir6, mkdtemp as mkdtemp7, readdir as readdir7, realpath as realpath4 } from "fs/promises";
|
|
6729
|
+
import { join as join19, resolve as resolve12, win32 as win323 } from "path";
|
|
6730
|
+
async function run2(cmd, env) {
|
|
6209
6731
|
return runInstallerCommand(cmd, env, {
|
|
6210
6732
|
outputLimit: 8 * 1024 * 1024,
|
|
6211
6733
|
overflowMessage: "Installer command output exceeds bound",
|
|
6212
6734
|
failureMessage: "Installer preparation command failed"
|
|
6213
6735
|
});
|
|
6214
6736
|
}
|
|
6215
|
-
async function
|
|
6737
|
+
async function digest4(path) {
|
|
6216
6738
|
const info = await lstat11(path);
|
|
6217
6739
|
if (!info.isFile() || info.isSymbolicLink() || !Number.isSafeInteger(info.size) || info.size < 1)
|
|
6218
6740
|
throw new Error("Invalid extracted file");
|
|
@@ -6256,50 +6778,50 @@ async function prepareInstallerExecution(options) {
|
|
|
6256
6778
|
archive: sourceArchive,
|
|
6257
6779
|
env
|
|
6258
6780
|
});
|
|
6259
|
-
const directory = await
|
|
6260
|
-
const imageIo = defaultInstallerImageMountIo(
|
|
6781
|
+
const directory = await mkdtemp7(join19(parent, "framework-installer-"));
|
|
6782
|
+
const imageIo = defaultInstallerImageMountIo(run2);
|
|
6261
6783
|
try {
|
|
6262
|
-
const profile =
|
|
6784
|
+
const profile = join19(directory, "profile"), incoming = join19(directory, "incoming");
|
|
6263
6785
|
await mkdir6(profile, { mode: 448 });
|
|
6264
6786
|
await mkdir6(incoming, { mode: 448 });
|
|
6265
6787
|
const clean = cleanEnv(env);
|
|
6266
6788
|
let executable;
|
|
6267
|
-
if (options.platform
|
|
6789
|
+
if (isMacInstallerPlatform(options.platform)) {
|
|
6268
6790
|
executable = await withInstallerImageRetries({
|
|
6269
6791
|
parent,
|
|
6270
6792
|
prefix: "framework-installer-mount-attempt-",
|
|
6271
6793
|
image: sourceInstaller,
|
|
6272
6794
|
env: clean,
|
|
6273
|
-
run,
|
|
6795
|
+
run: run2,
|
|
6274
6796
|
work: async (mount) => {
|
|
6275
6797
|
const appName = `${options.appName}.app`, apps = (await readdir7(mount)).filter((name) => name.endsWith(".app"));
|
|
6276
6798
|
if (apps.length !== 1 || apps[0] !== appName)
|
|
6277
6799
|
throw new Error("Unexpected installer application");
|
|
6278
|
-
const sourceApp = await realpath4(
|
|
6800
|
+
const sourceApp = await realpath4(join19(mount, appName)), mountRoot = await realpath4(mount);
|
|
6279
6801
|
if (!isWithin(mountRoot, sourceApp))
|
|
6280
6802
|
throw new Error("Installer application escapes image");
|
|
6281
|
-
const app =
|
|
6282
|
-
await
|
|
6283
|
-
const actualApp = await realpath4(app), resources = await realpath4(
|
|
6803
|
+
const app = join19(incoming, appName);
|
|
6804
|
+
await run2(["/usr/bin/ditto", sourceApp, app], clean);
|
|
6805
|
+
const actualApp = await realpath4(app), resources = await realpath4(join19(actualApp, "Contents", "Resources"));
|
|
6284
6806
|
if (!isWithin(await realpath4(incoming), actualApp) || !isWithin(actualApp, resources))
|
|
6285
6807
|
throw new Error("Copied installer escapes profile");
|
|
6286
|
-
const plist =
|
|
6808
|
+
const plist = join19(actualApp, "Contents", "Info.plist"), plistInfo = await lstat11(plist);
|
|
6287
6809
|
if (!plistInfo.isFile() || plistInfo.isSymbolicLink() || plistInfo.size < 1 || plistInfo.size > 1024 * 1024)
|
|
6288
6810
|
throw new Error("Invalid installer property list");
|
|
6289
|
-
const name = (await
|
|
6811
|
+
const name = (await run2(["/usr/libexec/PlistBuddy", "-c", "Print :CFBundleExecutable", plist], clean)).trim();
|
|
6290
6812
|
if (!name || name === "." || name === ".." || /[\\/]/.test(name))
|
|
6291
6813
|
throw new Error("Invalid installer executable");
|
|
6292
|
-
const appExecutable =
|
|
6293
|
-
const sourceExecutable =
|
|
6814
|
+
const appExecutable = join19(actualApp, "Contents", "MacOS", name);
|
|
6815
|
+
const sourceExecutable = join19(sourceApp, "Contents", "MacOS", name);
|
|
6294
6816
|
if (!isWithin(actualApp, await realpath4(appExecutable)) || !isWithin(sourceApp, await realpath4(sourceExecutable)))
|
|
6295
6817
|
throw new Error("Installer executable escapes application");
|
|
6296
6818
|
await assertInstallerExecutable(appExecutable, options.platform);
|
|
6297
|
-
if (JSON.stringify(await
|
|
6819
|
+
if (JSON.stringify(await digest4(sourceExecutable)) !== JSON.stringify(await digest4(appExecutable)))
|
|
6298
6820
|
throw new Error("Copied installer executable differs");
|
|
6299
6821
|
const archives = (await readdir7(resources)).filter((value) => value.endsWith(".tar.zst"));
|
|
6300
6822
|
if (archives.length !== 1)
|
|
6301
6823
|
throw new Error("Missing installer archive");
|
|
6302
|
-
const embedded = await
|
|
6824
|
+
const embedded = await digest4(join19(resources, archives[0]));
|
|
6303
6825
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
6304
6826
|
throw new Error("Copied installer archive differs");
|
|
6305
6827
|
return executable;
|
|
@@ -6309,14 +6831,14 @@ async function prepareInstallerExecution(options) {
|
|
|
6309
6831
|
const root = env.SystemRoot;
|
|
6310
6832
|
if (options.platform === "windows-x64" && (!root || !/^[A-Za-z]:[\\/]/.test(root)))
|
|
6311
6833
|
throw new Error("Missing Windows system directory");
|
|
6312
|
-
const tar = options.platform === "windows-x64" ?
|
|
6313
|
-
const names = (await
|
|
6834
|
+
const tar = options.platform === "windows-x64" ? win323.join(root, "System32", "tar.exe") : "tar";
|
|
6835
|
+
const names = (await run2([tar, "-tf", sourceInstaller], clean)).split(/\r?\n/).filter(Boolean);
|
|
6314
6836
|
assertInstallerLayout(options.platform, options.appName, names);
|
|
6315
6837
|
const find = (name) => findArchiveMember(names, name, options.platform, "Installer member missing or ambiguous");
|
|
6316
6838
|
if (options.platform === "windows-x64") {
|
|
6317
|
-
const subdirectory =
|
|
6839
|
+
const subdirectory = join19(incoming, ".installer");
|
|
6318
6840
|
await mkdir6(subdirectory);
|
|
6319
|
-
executable =
|
|
6841
|
+
executable = join19(incoming, `${options.appName}-Setup.exe`);
|
|
6320
6842
|
await extractArchiveMember({
|
|
6321
6843
|
tar,
|
|
6322
6844
|
archive: sourceInstaller,
|
|
@@ -6330,11 +6852,11 @@ async function prepareInstallerExecution(options) {
|
|
|
6330
6852
|
tar,
|
|
6331
6853
|
archive: sourceInstaller,
|
|
6332
6854
|
member: find(`.installer/${options.appName}-Setup.metadata.json`),
|
|
6333
|
-
destination:
|
|
6855
|
+
destination: join19(subdirectory, `${options.appName}-Setup.metadata.json`),
|
|
6334
6856
|
maximum: 1024 * 1024,
|
|
6335
6857
|
env: clean
|
|
6336
6858
|
});
|
|
6337
|
-
const embeddedPath =
|
|
6859
|
+
const embeddedPath = join19(subdirectory, `${options.appName}-Setup.tar.zst`);
|
|
6338
6860
|
await extractArchiveMember({
|
|
6339
6861
|
tar,
|
|
6340
6862
|
archive: sourceInstaller,
|
|
@@ -6343,11 +6865,11 @@ async function prepareInstallerExecution(options) {
|
|
|
6343
6865
|
maximum: verified.archive.size,
|
|
6344
6866
|
env: clean
|
|
6345
6867
|
});
|
|
6346
|
-
const embedded = await
|
|
6868
|
+
const embedded = await digest4(embeddedPath);
|
|
6347
6869
|
if (embedded.size !== verified.archive.size || embedded.digest !== verified.archive.digest)
|
|
6348
6870
|
throw new Error("Copied installer archive differs");
|
|
6349
6871
|
} else {
|
|
6350
|
-
executable =
|
|
6872
|
+
executable = join19(incoming, "installer");
|
|
6351
6873
|
await extractArchiveMember({
|
|
6352
6874
|
tar,
|
|
6353
6875
|
archive: sourceInstaller,
|
|
@@ -6403,10 +6925,10 @@ function assertInstallerRendererObservation(value, offline = false) {
|
|
|
6403
6925
|
}
|
|
6404
6926
|
|
|
6405
6927
|
// ../../src/installer/installed-payload.ts
|
|
6406
|
-
import { createHash as
|
|
6407
|
-
import { lstat as lstat12, open as open5, realpath as realpath5, rm as
|
|
6408
|
-
import { once } from "events";
|
|
6409
|
-
import { join as
|
|
6928
|
+
import { createHash as createHash17 } from "crypto";
|
|
6929
|
+
import { lstat as lstat12, open as open5, realpath as realpath5, rm as rm7 } from "fs/promises";
|
|
6930
|
+
import { once as once2 } from "events";
|
|
6931
|
+
import { join as join20, resolve as resolve13 } from "path";
|
|
6410
6932
|
import { createZstdDecompress } from "zlib";
|
|
6411
6933
|
import { Parser } from "tar";
|
|
6412
6934
|
function cleanEnv2(parent, forceLocal) {
|
|
@@ -6429,7 +6951,7 @@ async function command2(args, env, limit, collect) {
|
|
|
6429
6951
|
const errors = (async () => {
|
|
6430
6952
|
for await (const _part of child.stderr) {}
|
|
6431
6953
|
})();
|
|
6432
|
-
const hash =
|
|
6954
|
+
const hash = createHash17("sha256"), chunks = [];
|
|
6433
6955
|
let size = 0;
|
|
6434
6956
|
try {
|
|
6435
6957
|
for await (const part of child.stdout) {
|
|
@@ -6483,7 +7005,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
6483
7005
|
failure ??= new Error("Archive member missing or ambiguous");
|
|
6484
7006
|
return entry.resume();
|
|
6485
7007
|
}
|
|
6486
|
-
const hash =
|
|
7008
|
+
const hash = createHash17("sha256"), chunks = [];
|
|
6487
7009
|
const member = { digest: "", size: 0, bytes: Buffer.alloc(0), count: 1 };
|
|
6488
7010
|
members.set(entry.path, member);
|
|
6489
7011
|
entry.on("data", (chunk) => {
|
|
@@ -6498,7 +7020,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
6498
7020
|
});
|
|
6499
7021
|
}
|
|
6500
7022
|
});
|
|
6501
|
-
const ended =
|
|
7023
|
+
const ended = once2(parser, "end");
|
|
6502
7024
|
ended.catch(() => {
|
|
6503
7025
|
return;
|
|
6504
7026
|
});
|
|
@@ -6509,7 +7031,7 @@ async function readMembers(archive, limits, collect) {
|
|
|
6509
7031
|
parser.on("error", (error) => inflate.destroy(error));
|
|
6510
7032
|
for await (const chunk of input.pipe(inflate)) {
|
|
6511
7033
|
if (!parser.write(chunk))
|
|
6512
|
-
await
|
|
7034
|
+
await once2(parser, "drain");
|
|
6513
7035
|
}
|
|
6514
7036
|
parser.end();
|
|
6515
7037
|
await ended;
|
|
@@ -6553,7 +7075,7 @@ async function verifyInstalledPayload(options) {
|
|
|
6553
7075
|
entries,
|
|
6554
7076
|
sidecars: options.sidecars ?? []
|
|
6555
7077
|
});
|
|
6556
|
-
const mac = options.platform
|
|
7078
|
+
const mac = isMacInstallerPlatform(options.platform), prefix = mac ? `${options.appName}.app/Contents` : options.appName.replaceAll(" ", ""), suffix = options.platform === "windows-x64" ? ".exe" : "";
|
|
6557
7079
|
const bin = mac ? "MacOS" : "bin";
|
|
6558
7080
|
const files = [
|
|
6559
7081
|
`${bin}/launcher${suffix}`,
|
|
@@ -6577,7 +7099,7 @@ async function verifyInstalledPayload(options) {
|
|
|
6577
7099
|
const member = members.get(path);
|
|
6578
7100
|
if (!member || member.count !== 1)
|
|
6579
7101
|
throw new Error("Archive member missing or ambiguous");
|
|
6580
|
-
const current = await installed(
|
|
7102
|
+
const current = await installed(join20(root, name), root, limit);
|
|
6581
7103
|
if (member.size !== current.size || member.digest !== current.digest)
|
|
6582
7104
|
throw new Error(`Installed file differs from archive: ${name}`);
|
|
6583
7105
|
if (name === "Resources/version.json") {
|
|
@@ -6609,10 +7131,10 @@ async function extractCandidateRuntime(options) {
|
|
|
6609
7131
|
appName: options.appName,
|
|
6610
7132
|
entries
|
|
6611
7133
|
});
|
|
6612
|
-
const prefix = options.platform
|
|
7134
|
+
const prefix = isMacInstallerPlatform(options.platform) ? `${options.appName}.app/Contents/MacOS` : `${options.appName.replaceAll(" ", "")}/bin`, suffix = options.platform === "windows-x64" ? ".exe" : "";
|
|
6613
7135
|
const expected = `${prefix}/bun${suffix}`;
|
|
6614
7136
|
const member = findArchiveMember(entries, expected, options.platform, "Runtime archive member missing or ambiguous");
|
|
6615
|
-
const destination =
|
|
7137
|
+
const destination = join20(profile, `candidate-bun${suffix}`), output = await open5(destination, "wx", 448);
|
|
6616
7138
|
const spawn = () => Bun.spawn({
|
|
6617
7139
|
cmd: ["tar", "--zstd", "-xOf", archive, "--", member],
|
|
6618
7140
|
env: tarEnv,
|
|
@@ -6625,7 +7147,7 @@ async function extractCandidateRuntime(options) {
|
|
|
6625
7147
|
const child = spawn(), errors = (async () => {
|
|
6626
7148
|
for await (const _part of child.stderr) {}
|
|
6627
7149
|
})();
|
|
6628
|
-
const hash =
|
|
7150
|
+
const hash = createHash17("sha256");
|
|
6629
7151
|
let size = 0;
|
|
6630
7152
|
try {
|
|
6631
7153
|
for await (const part of child.stdout) {
|
|
@@ -6662,14 +7184,14 @@ async function extractCandidateRuntime(options) {
|
|
|
6662
7184
|
} finally {
|
|
6663
7185
|
await output.close();
|
|
6664
7186
|
if (!successful)
|
|
6665
|
-
await
|
|
7187
|
+
await rm7(destination, { force: true });
|
|
6666
7188
|
}
|
|
6667
7189
|
}
|
|
6668
7190
|
|
|
6669
7191
|
// ../../src/installer/installer-process-cleanup.ts
|
|
6670
|
-
import { execFile as
|
|
7192
|
+
import { execFile as execFile3 } from "child_process";
|
|
6671
7193
|
import { realpath as realpath6 } from "fs/promises";
|
|
6672
|
-
import { promisify as
|
|
7194
|
+
import { promisify as promisify3 } from "util";
|
|
6673
7195
|
|
|
6674
7196
|
// ../../src/native/windows-process.ts
|
|
6675
7197
|
import { dlopen as dlopen2, FFIType as FFIType2, ptr as ptr2 } from "bun:ffi";
|
|
@@ -6713,7 +7235,7 @@ function windowsProcessImage(pid, options) {
|
|
|
6713
7235
|
}
|
|
6714
7236
|
|
|
6715
7237
|
// ../../src/installer/installer-process-cleanup.ts
|
|
6716
|
-
var execute =
|
|
7238
|
+
var execute = promisify3(execFile3);
|
|
6717
7239
|
async function terminateGuardedWorker(options) {
|
|
6718
7240
|
const { pid, runtime, platform } = options;
|
|
6719
7241
|
assertInstallerContext(options.env, platform, process.platform, process.arch);
|
|
@@ -6745,7 +7267,7 @@ async function terminateGuardedWorker(options) {
|
|
|
6745
7267
|
}
|
|
6746
7268
|
const deadline = performance.now() + 5000;
|
|
6747
7269
|
while (performance.now() < deadline) {
|
|
6748
|
-
if (platform
|
|
7270
|
+
if (isMacInstallerPlatform(platform) ? await macosWorkerExited(() => readMacosState(pid, env)) : await runningExecutable(pid, platform, env) === undefined)
|
|
6749
7271
|
return;
|
|
6750
7272
|
await Bun.sleep(100);
|
|
6751
7273
|
}
|
|
@@ -6790,7 +7312,7 @@ async function runningExecutable(pid, platform, env) {
|
|
|
6790
7312
|
return;
|
|
6791
7313
|
throw error;
|
|
6792
7314
|
});
|
|
6793
|
-
if (platform
|
|
7315
|
+
if (isMacInstallerPlatform(platform)) {
|
|
6794
7316
|
const listed = await execute("/bin/ps", ["-p", String(pid), "-o", "stat=", "-o", "comm="], {
|
|
6795
7317
|
env,
|
|
6796
7318
|
timeout: 5000,
|
|
@@ -6818,8 +7340,8 @@ async function windowsRunningExecutable(pid) {
|
|
|
6818
7340
|
}
|
|
6819
7341
|
|
|
6820
7342
|
// ../../src/updates/install/update-swap-stage.ts
|
|
6821
|
-
import { lstat as lstat18, mkdtemp as
|
|
6822
|
-
import { join as
|
|
7343
|
+
import { lstat as lstat18, mkdtemp as mkdtemp9, readFile as readFile10, realpath as realpath8, rm as rm9 } from "fs/promises";
|
|
7344
|
+
import { join as join30 } from "path";
|
|
6823
7345
|
|
|
6824
7346
|
// ../../src/updates/install/update-handoff-plan.ts
|
|
6825
7347
|
import { basename as basename6 } from "path";
|
|
@@ -6838,13 +7360,14 @@ function planUpdateHandoff(options) {
|
|
|
6838
7360
|
assertPortableAppName(appName);
|
|
6839
7361
|
const expected = {
|
|
6840
7362
|
"macos-arm64": ["darwin", "arm64"],
|
|
7363
|
+
"macos-x64": ["darwin", "x64"],
|
|
6841
7364
|
"windows-x64": ["win32", "x64"],
|
|
6842
7365
|
"linux-x64": ["linux", "x64"],
|
|
6843
7366
|
"linux-arm64": ["linux", "arm64"]
|
|
6844
7367
|
};
|
|
6845
7368
|
if (!expected[platform] || !["native", "cef"].includes(renderer) || !isVerifiedReleaseForTrust(descriptor, trust) || descriptor.platform !== expected[platform][0] || descriptor.arch !== expected[platform][1] || approved !== true || approvedVersion !== descriptor.version || !isReleaseVersion(currentVersion) || !versionLessThan(currentVersion, descriptor.version))
|
|
6846
7369
|
throw new Error("Invalid approved update");
|
|
6847
|
-
const name = platform
|
|
7370
|
+
const name = isMacInstallerPlatform(platform) ? `${appName}.app` : "app";
|
|
6848
7371
|
if (!isCanonicalPath(target) || basename6(target) !== name)
|
|
6849
7372
|
throw new Error("Invalid update target");
|
|
6850
7373
|
return Object.freeze({
|
|
@@ -6858,10 +7381,10 @@ function planUpdateHandoff(options) {
|
|
|
6858
7381
|
}
|
|
6859
7382
|
|
|
6860
7383
|
// ../../src/updates/install/update-extraction.ts
|
|
6861
|
-
import { createHash as
|
|
7384
|
+
import { createHash as createHash18 } from "crypto";
|
|
6862
7385
|
import { constants as constants4 } from "fs";
|
|
6863
|
-
import { lstat as lstat13, mkdir as mkdir7, mkdtemp as
|
|
6864
|
-
import { isAbsolute as isAbsolute6, join as
|
|
7386
|
+
import { lstat as lstat13, mkdir as mkdir7, mkdtemp as mkdtemp8, open as open6, readFile as readFile8, realpath as realpath7, rm as rm8, symlink } from "fs/promises";
|
|
7387
|
+
import { isAbsolute as isAbsolute6, join as join21 } from "path";
|
|
6865
7388
|
import { Transform } from "stream";
|
|
6866
7389
|
import { pipeline } from "stream/promises";
|
|
6867
7390
|
import { createZstdDecompress as createZstdDecompress2 } from "zlib";
|
|
@@ -6882,19 +7405,26 @@ function isLinuxCefLibraryLink(path, target) {
|
|
|
6882
7405
|
}
|
|
6883
7406
|
|
|
6884
7407
|
// ../../src/updates/install/update-extraction.ts
|
|
7408
|
+
var expectedPlatform = {
|
|
7409
|
+
"macos-arm64": ["darwin", "arm64"],
|
|
7410
|
+
"macos-x64": ["darwin", "x64"],
|
|
7411
|
+
"windows-x64": ["win32", "x64"],
|
|
7412
|
+
"linux-x64": ["linux", "x64"],
|
|
7413
|
+
"linux-arm64": ["linux", "arm64"]
|
|
7414
|
+
};
|
|
6885
7415
|
async function extractVerifiedUpdate(options) {
|
|
6886
|
-
const { descriptor,
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
};
|
|
6893
|
-
if (!
|
|
7416
|
+
const { descriptor, platform } = options;
|
|
7417
|
+
if (!isVerifiedRelease(descriptor) || !expectedPlatform[platform] || descriptor.platform !== expectedPlatform[platform][0] || descriptor.arch !== expectedPlatform[platform][1])
|
|
7418
|
+
throw new Error("Invalid update extraction context");
|
|
7419
|
+
return extractBoundArchive(options, descriptor, async (file) => verifyReleaseStream(file.createReadStream({ autoClose: false, start: 0 }), descriptor));
|
|
7420
|
+
}
|
|
7421
|
+
async function extractBoundArchive(options, descriptor, verifyBeforeExtraction) {
|
|
7422
|
+
const { archive, platform, renderer, appName, maxCompressedBytes, maxExpandedBytes } = options;
|
|
7423
|
+
if (!isAbsolute6(archive) || !isAbsolute6(options.directory) || !Number.isSafeInteger(maxCompressedBytes) || maxCompressedBytes < 1 || !Number.isSafeInteger(descriptor.asset.size) || descriptor.asset.size < 1 || descriptor.asset.size > maxCompressedBytes || !/^[a-f0-9]{64}$/.test(descriptor.asset.sha256) || !Number.isSafeInteger(maxExpandedBytes) || maxExpandedBytes < 1)
|
|
6894
7424
|
throw new Error("Invalid update extraction context");
|
|
6895
7425
|
assertPortableAppName(appName);
|
|
6896
7426
|
const sidecars = assertSidecarNames(options.sidecars ?? [], platform);
|
|
6897
|
-
const archiveRoot = platform
|
|
7427
|
+
const archiveRoot = isMacInstallerPlatform(platform) ? `${appName}.app` : appName.replaceAll(" ", "");
|
|
6898
7428
|
const info = await lstat13(archive);
|
|
6899
7429
|
if (!info.isFile() || info.isSymbolicLink() || info.size !== descriptor.asset.size)
|
|
6900
7430
|
throw new Error("Invalid update archive");
|
|
@@ -6902,13 +7432,13 @@ async function extractVerifiedUpdate(options) {
|
|
|
6902
7432
|
let directory;
|
|
6903
7433
|
try {
|
|
6904
7434
|
const before = await file.stat();
|
|
6905
|
-
if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || !await
|
|
7435
|
+
if (!before.isFile() || before.dev !== info.dev || before.ino !== info.ino || before.size !== info.size || verifyBeforeExtraction && !await verifyBeforeExtraction(file))
|
|
6906
7436
|
throw new Error("Update archive verification failed");
|
|
6907
7437
|
const parent = await realpath7(options.directory);
|
|
6908
7438
|
if (!(await lstat13(parent)).isDirectory())
|
|
6909
7439
|
throw new Error("Invalid update staging directory");
|
|
6910
|
-
directory = await
|
|
6911
|
-
const payloadRoot =
|
|
7440
|
+
directory = await mkdtemp8(join21(parent, "framework-update-extract-"));
|
|
7441
|
+
const payloadRoot = join21(directory, "payload"), decompressed = join21(directory, "payload.tar");
|
|
6912
7442
|
await mkdir7(payloadRoot, { mode: 448 });
|
|
6913
7443
|
const entries = [], links = [], seen = new Set, fold = platform === "windows-x64";
|
|
6914
7444
|
let invalid = false;
|
|
@@ -6926,7 +7456,7 @@ async function extractVerifiedUpdate(options) {
|
|
|
6926
7456
|
done(null, chunk);
|
|
6927
7457
|
}
|
|
6928
7458
|
});
|
|
6929
|
-
const hash =
|
|
7459
|
+
const hash = createHash18("sha256");
|
|
6930
7460
|
let compressedBytes = 0;
|
|
6931
7461
|
const verifyInput = new Transform({
|
|
6932
7462
|
transform(chunk, _encoding, done) {
|
|
@@ -7026,27 +7556,27 @@ async function extractVerifiedUpdate(options) {
|
|
|
7026
7556
|
if (invalid)
|
|
7027
7557
|
throw new Error("Unsafe or unsupported update archive entry");
|
|
7028
7558
|
if (links.length) {
|
|
7029
|
-
const bin =
|
|
7030
|
-
for (const path of [
|
|
7559
|
+
const bin = join21(payloadRoot, archiveRoot, "bin"), cef = join21(bin, "cef");
|
|
7560
|
+
for (const path of [join21(payloadRoot, archiveRoot), bin, cef]) {
|
|
7031
7561
|
const value = await lstat13(path);
|
|
7032
7562
|
if (!value.isDirectory() || value.isSymbolicLink())
|
|
7033
7563
|
throw new Error("Invalid CEF link directory");
|
|
7034
7564
|
}
|
|
7035
7565
|
for (const link of links) {
|
|
7036
|
-
const destination =
|
|
7566
|
+
const destination = join21(payloadRoot, link.path), target = join21(bin, link.target), value = await lstat13(target);
|
|
7037
7567
|
if (!value.isFile() || value.isSymbolicLink())
|
|
7038
7568
|
throw new Error("Invalid CEF link target");
|
|
7039
7569
|
await symlink(link.target, destination);
|
|
7040
7570
|
}
|
|
7041
7571
|
}
|
|
7042
|
-
await
|
|
7572
|
+
await rm8(decompressed);
|
|
7043
7573
|
assertPayloadLayout({ platform, renderer, appName, entries, sidecars });
|
|
7044
|
-
const prefix = platform
|
|
7045
|
-
const resources =
|
|
7046
|
-
const bin = platform
|
|
7574
|
+
const prefix = isMacInstallerPlatform(platform) ? join21(`${appName}.app`, "Contents") : appName.replaceAll(" ", "");
|
|
7575
|
+
const resources = join21(payloadRoot, prefix, "Resources");
|
|
7576
|
+
const bin = isMacInstallerPlatform(platform) ? "MacOS" : "bin", suffix = platform === "windows-x64" ? ".exe" : "";
|
|
7047
7577
|
const executables = [
|
|
7048
|
-
|
|
7049
|
-
|
|
7578
|
+
join21(bin, `launcher${suffix}`),
|
|
7579
|
+
join21(bin, `bun${suffix}`),
|
|
7050
7580
|
...sidecars.map((name) => sidecarBundlePath(name, platform))
|
|
7051
7581
|
];
|
|
7052
7582
|
const critical = [
|
|
@@ -7056,25 +7586,25 @@ async function extractVerifiedUpdate(options) {
|
|
|
7056
7586
|
"Resources/app/client/index.html"
|
|
7057
7587
|
];
|
|
7058
7588
|
for (const path of critical) {
|
|
7059
|
-
const item = await lstat13(
|
|
7589
|
+
const item = await lstat13(join21(payloadRoot, prefix, path));
|
|
7060
7590
|
if (!item.isFile() || item.isSymbolicLink() || item.size < 1 || platform !== "windows-x64" && process.platform !== "win32" && executables.includes(path) && !(item.mode & 64))
|
|
7061
7591
|
throw new Error("Invalid critical update file");
|
|
7062
7592
|
}
|
|
7063
7593
|
for (const name of ["version.json", "build.json"]) {
|
|
7064
|
-
const metadata = await lstat13(
|
|
7594
|
+
const metadata = await lstat13(join21(resources, name));
|
|
7065
7595
|
if (!metadata.isFile() || metadata.isSymbolicLink() || metadata.size < 1 || metadata.size > 1048576)
|
|
7066
7596
|
throw new Error("Invalid update metadata");
|
|
7067
7597
|
}
|
|
7068
|
-
if (JSON.parse(await
|
|
7598
|
+
if (JSON.parse(await readFile8(join21(resources, "version.json"), "utf8")).version !== descriptor.version)
|
|
7069
7599
|
throw new Error("Update version mismatch");
|
|
7070
|
-
assertBuildMetadata(JSON.parse(await
|
|
7600
|
+
assertBuildMetadata(JSON.parse(await readFile8(join21(resources, "build.json"), "utf8")), renderer);
|
|
7071
7601
|
return {
|
|
7072
7602
|
directory,
|
|
7073
|
-
payload:
|
|
7603
|
+
payload: join21(payloadRoot, isMacInstallerPlatform(platform) ? `${appName}.app` : prefix)
|
|
7074
7604
|
};
|
|
7075
7605
|
} catch (error) {
|
|
7076
7606
|
if (directory)
|
|
7077
|
-
await
|
|
7607
|
+
await rm8(directory, { recursive: true, force: true });
|
|
7078
7608
|
throw error;
|
|
7079
7609
|
} finally {
|
|
7080
7610
|
await file.close();
|
|
@@ -7082,19 +7612,19 @@ async function extractVerifiedUpdate(options) {
|
|
|
7082
7612
|
}
|
|
7083
7613
|
|
|
7084
7614
|
// ../../src/updates/install/update-swap.ts
|
|
7085
|
-
import { createHash as
|
|
7615
|
+
import { createHash as createHash19 } from "crypto";
|
|
7086
7616
|
import { constants as constants7 } from "fs";
|
|
7087
|
-
import { lstat as lstat14, open as open9, readdir as readdir8, readFile as
|
|
7088
|
-
import { basename as basename8, dirname as dirname6, join as
|
|
7617
|
+
import { lstat as lstat14, open as open9, readdir as readdir8, readFile as readFile9, readlink as readlink2 } from "fs/promises";
|
|
7618
|
+
import { basename as basename8, dirname as dirname6, join as join24 } from "path";
|
|
7089
7619
|
|
|
7090
7620
|
// ../../src/updates/update-state-store.ts
|
|
7091
7621
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
7092
7622
|
import { constants as constants6 } from "fs";
|
|
7093
|
-
import { open as open8, rename, unlink, writeFile as
|
|
7094
|
-
import { join as
|
|
7623
|
+
import { open as open8, rename, unlink, writeFile as writeFile6 } from "fs/promises";
|
|
7624
|
+
import { join as join23 } from "path";
|
|
7095
7625
|
|
|
7096
7626
|
// ../../src/updates/locks/update-lock.ts
|
|
7097
|
-
import { basename as basename7, dirname as dirname5, join as
|
|
7627
|
+
import { basename as basename7, dirname as dirname5, join as join22 } from "path";
|
|
7098
7628
|
|
|
7099
7629
|
// ../../src/updates/locks/native-file-lock.ts
|
|
7100
7630
|
import { constants as constants5 } from "fs";
|
|
@@ -7262,7 +7792,7 @@ async function tryAcquireWindows(path, mode) {
|
|
|
7262
7792
|
function updateLockPath(target) {
|
|
7263
7793
|
if (!isCanonicalPath(target))
|
|
7264
7794
|
throw new Error("Invalid update lock target");
|
|
7265
|
-
return
|
|
7795
|
+
return join22(dirname5(target), `.${basename7(target)}.framework-update.lock`);
|
|
7266
7796
|
}
|
|
7267
7797
|
async function tryAcquireUpdateLock(target) {
|
|
7268
7798
|
return tryAcquireNativeFileLock(updateLockPath(target), "exclusive");
|
|
@@ -7327,7 +7857,7 @@ function parseState(value) {
|
|
|
7327
7857
|
return Object.freeze(record);
|
|
7328
7858
|
}
|
|
7329
7859
|
async function readUpdateStageState(staging) {
|
|
7330
|
-
const text = await readSmallStateFile(
|
|
7860
|
+
const text = await readSmallStateFile(join23(staging, "state.json"), 4096, "Invalid update staging state");
|
|
7331
7861
|
return text === undefined ? undefined : parseState(JSON.parse(text));
|
|
7332
7862
|
}
|
|
7333
7863
|
async function writeUpdateStageState(staging, state) {
|
|
@@ -7336,8 +7866,8 @@ async function writeUpdateStageState(staging, state) {
|
|
|
7336
7866
|
async function replaceUpdateStageState(staging, state, durable) {
|
|
7337
7867
|
if (typeof state.generation !== "string" || !isUuid(state.generation))
|
|
7338
7868
|
throw new Error("Invalid update staging state");
|
|
7339
|
-
const path =
|
|
7340
|
-
const temporary =
|
|
7869
|
+
const path = join23(staging, "state.json");
|
|
7870
|
+
const temporary = join23(staging, `.state-${state.generation}-${randomUUID2()}.tmp`);
|
|
7341
7871
|
const contents = JSON.stringify(state) + `
|
|
7342
7872
|
`;
|
|
7343
7873
|
let renamed = false;
|
|
@@ -7351,7 +7881,7 @@ async function replaceUpdateStageState(staging, state, durable) {
|
|
|
7351
7881
|
await file.close();
|
|
7352
7882
|
}
|
|
7353
7883
|
} else
|
|
7354
|
-
await
|
|
7884
|
+
await writeFile6(temporary, contents, { flag: "wx", mode: 384 });
|
|
7355
7885
|
await rename(temporary, path);
|
|
7356
7886
|
renamed = true;
|
|
7357
7887
|
if (durable)
|
|
@@ -7375,12 +7905,12 @@ async function withUpdateLock(target, operation) {
|
|
|
7375
7905
|
function updateStagingFor(target) {
|
|
7376
7906
|
if (!isCanonicalPath(target))
|
|
7377
7907
|
throw new Error("Invalid update target");
|
|
7378
|
-
return
|
|
7908
|
+
return join24(dirname6(target), `.${basename8(target)}.framework-update`);
|
|
7379
7909
|
}
|
|
7380
7910
|
async function readUpdateTreeVersion(tree) {
|
|
7381
|
-
const versionPath =
|
|
7911
|
+
const versionPath = join24(tree, ...process.platform === "darwin" ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
7382
7912
|
try {
|
|
7383
|
-
const value = JSON.parse(await
|
|
7913
|
+
const value = JSON.parse(await readFile9(versionPath, "utf8"));
|
|
7384
7914
|
if (typeof value !== "object" || value === null || typeof value.version !== "string")
|
|
7385
7915
|
return;
|
|
7386
7916
|
return value.version;
|
|
@@ -7438,7 +7968,7 @@ async function readTreeFileBytes(file, buffer, length, position) {
|
|
|
7438
7968
|
}
|
|
7439
7969
|
async function readUpdateTreeDigest(tree, options = {}) {
|
|
7440
7970
|
const allowHardLinkedFiles = options.allowHardLinkedFiles === true;
|
|
7441
|
-
const hash =
|
|
7971
|
+
const hash = createHash19("sha256");
|
|
7442
7972
|
hash.update("adea-framework-update-tree\x00v1\x00", "utf8");
|
|
7443
7973
|
const root = await lstat14(tree, { bigint: true });
|
|
7444
7974
|
if (!root.isDirectory() || root.isSymbolicLink())
|
|
@@ -7472,7 +8002,7 @@ async function readUpdateTreeDigest(tree, options = {}) {
|
|
|
7472
8002
|
if (before.isDirectory()) {
|
|
7473
8003
|
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);
|
|
7474
8004
|
const children = await Promise.all(names.map(async (name) => {
|
|
7475
|
-
const childPath =
|
|
8005
|
+
const childPath = join24(path, name);
|
|
7476
8006
|
return list(childPath, relative ? `${relative}/${name}` : name, await limit(() => lstat14(childPath, { bigint: true })));
|
|
7477
8007
|
}));
|
|
7478
8008
|
return [{ kind: "directory", path, relative, before }, ...children.flat()];
|
|
@@ -7615,8 +8145,8 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
7615
8145
|
const { target, staging } = options;
|
|
7616
8146
|
if (dirname6(staging) !== dirname6(target) || staging === target)
|
|
7617
8147
|
throw new Error("Invalid update swap context");
|
|
7618
|
-
const candidate =
|
|
7619
|
-
const legacyOld =
|
|
8148
|
+
const candidate = join24(staging, "candidate");
|
|
8149
|
+
const legacyOld = join24(staging, "old");
|
|
7620
8150
|
if (await pathExists(legacyOld))
|
|
7621
8151
|
throw new Error("A legacy update tree requires recovery before another swap");
|
|
7622
8152
|
await assertDirectory(target);
|
|
@@ -7646,10 +8176,10 @@ async function swapUpdateTreeWhileLocked(options, exchangeOperation = exchangeDi
|
|
|
7646
8176
|
|
|
7647
8177
|
// ../../src/updates/retention/retirement-inventory.ts
|
|
7648
8178
|
import { lstat as lstat16, readdir as readdir10 } from "fs/promises";
|
|
7649
|
-
import { basename as basename12, dirname as dirname10, join as
|
|
8179
|
+
import { basename as basename12, dirname as dirname10, join as join28 } from "path";
|
|
7650
8180
|
|
|
7651
8181
|
// ../../src/updates/retention/update-retention-marker.ts
|
|
7652
|
-
import { basename as basename9, dirname as dirname7, join as
|
|
8182
|
+
import { basename as basename9, dirname as dirname7, join as join25 } from "path";
|
|
7653
8183
|
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}$/;
|
|
7654
8184
|
var IDENTITY_COMPONENT = /^[1-9]\d{0,19}$/;
|
|
7655
8185
|
function assertCanonicalTarget(target) {
|
|
@@ -7668,28 +8198,28 @@ function isTreeIdentity(value) {
|
|
|
7668
8198
|
function updateRetentionIntentPath(target, generation) {
|
|
7669
8199
|
assertCanonicalTarget(target);
|
|
7670
8200
|
assertGeneration(generation);
|
|
7671
|
-
return
|
|
8201
|
+
return join25(dirname7(target), `.${basename9(target)}.framework-prune-${generation}.json`);
|
|
7672
8202
|
}
|
|
7673
8203
|
|
|
7674
8204
|
// ../../src/updates/retention/retention-prune-progress.ts
|
|
7675
|
-
import { basename as basename11, dirname as dirname9, join as
|
|
8205
|
+
import { basename as basename11, dirname as dirname9, join as join27 } from "path";
|
|
7676
8206
|
|
|
7677
8207
|
// ../../src/updates/retention/retirement-records.ts
|
|
7678
|
-
import { lstat as lstat15, readdir as readdir9, writeFile as
|
|
7679
|
-
import { basename as basename10, dirname as dirname8, join as
|
|
8208
|
+
import { lstat as lstat15, readdir as readdir9, writeFile as writeFile7 } from "fs/promises";
|
|
8209
|
+
import { basename as basename10, dirname as dirname8, join as join26 } from "path";
|
|
7680
8210
|
function updateRetirementPaths(target, generation) {
|
|
7681
8211
|
if (!isCanonicalPath(target) || !isUuid(generation))
|
|
7682
8212
|
throw new Error("Invalid update retirement identity");
|
|
7683
8213
|
const prefix = `.${basename10(target)}.framework-retired-${generation}`;
|
|
7684
|
-
const container =
|
|
8214
|
+
const container = join26(dirname8(target), prefix);
|
|
7685
8215
|
return Object.freeze({
|
|
7686
8216
|
container,
|
|
7687
|
-
tree:
|
|
7688
|
-
healthReceipt:
|
|
8217
|
+
tree: join26(container, "tree"),
|
|
8218
|
+
healthReceipt: join26(container, "healthy.json"),
|
|
7689
8219
|
healthTemporaryPrefix: ".healthy-",
|
|
7690
|
-
claim:
|
|
8220
|
+
claim: join26(dirname8(target), `${prefix}.claim.json`),
|
|
7691
8221
|
claimTemporaryPrefix: `${prefix}.claim-`,
|
|
7692
|
-
cleanupMarker:
|
|
8222
|
+
cleanupMarker: join26(dirname8(target), `.${basename10(target)}.framework-update-cleanup.json`),
|
|
7693
8223
|
cleanupMarkerTemporaryPrefix: `.${basename10(target)}.framework-update-cleanup-`
|
|
7694
8224
|
});
|
|
7695
8225
|
}
|
|
@@ -7792,11 +8322,11 @@ async function assertNoUpdateRetentionPruneArtifactsWhileLocked(target) {
|
|
|
7792
8322
|
}
|
|
7793
8323
|
|
|
7794
8324
|
// ../../src/updates/retention/update-retirement.ts
|
|
7795
|
-
import { lstat as lstat17, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as
|
|
7796
|
-
import { basename as basename13, dirname as dirname11, join as
|
|
8325
|
+
import { lstat as lstat17, mkdir as mkdir8, readdir as readdir11, rmdir, unlink as unlink2, writeFile as writeFile8 } from "fs/promises";
|
|
8326
|
+
import { basename as basename13, dirname as dirname11, join as join29 } from "path";
|
|
7797
8327
|
async function reconcileRetirementCleanupMarkerWhileLocked(options) {
|
|
7798
8328
|
const { target, staging, currentVersion } = options;
|
|
7799
|
-
const markerPath =
|
|
8329
|
+
const markerPath = join29(dirname11(target), `.${basename13(target)}.framework-update-cleanup.json`);
|
|
7800
8330
|
const markerInfo = await pathInfo(markerPath);
|
|
7801
8331
|
if (!markerInfo)
|
|
7802
8332
|
return "none";
|
|
@@ -7837,17 +8367,18 @@ async function assertInstalledVersion(options) {
|
|
|
7837
8367
|
const info = await lstat18(options.target);
|
|
7838
8368
|
if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(options.target) !== options.target)
|
|
7839
8369
|
throw new Error("Invalid update install target");
|
|
7840
|
-
const versionFile =
|
|
8370
|
+
const versionFile = join30(options.target, ...isMacInstallerPlatform(options.platform) ? ["Contents", "Resources"] : ["Resources"], "version.json");
|
|
7841
8371
|
const versionInfo = await lstat18(versionFile);
|
|
7842
8372
|
if (!versionInfo.isFile() || versionInfo.size > 1024 * 1024)
|
|
7843
8373
|
throw new Error("Installed update version mismatch");
|
|
7844
|
-
if (JSON.parse(await
|
|
8374
|
+
if (JSON.parse(await readFile10(versionFile, "utf8")).version !== options.version)
|
|
7845
8375
|
throw new Error("Installed update version mismatch");
|
|
7846
8376
|
}
|
|
7847
8377
|
async function stageUpdateSwap(options) {
|
|
7848
8378
|
const plan = planUpdateHandoff(options);
|
|
7849
8379
|
const expectedHost = {
|
|
7850
8380
|
"macos-arm64": "darwin/arm64",
|
|
8381
|
+
"macos-x64": "darwin/x64",
|
|
7851
8382
|
"windows-x64": "win32/x64",
|
|
7852
8383
|
"linux-x64": "linux/x64",
|
|
7853
8384
|
"linux-arm64": "linux/arm64"
|
|
@@ -7860,8 +8391,8 @@ async function stageUpdateSwap(options) {
|
|
|
7860
8391
|
version: plan.currentVersion
|
|
7861
8392
|
});
|
|
7862
8393
|
const staging = updateStagingFor(plan.target);
|
|
7863
|
-
const preparing = await
|
|
7864
|
-
const candidate =
|
|
8394
|
+
const preparing = await mkdtemp9(`${staging}.preparing-`);
|
|
8395
|
+
const candidate = join30(staging, "candidate");
|
|
7865
8396
|
let published = false;
|
|
7866
8397
|
try {
|
|
7867
8398
|
const extracted = await extractVerifiedUpdate({
|
|
@@ -7875,12 +8406,12 @@ async function stageUpdateSwap(options) {
|
|
|
7875
8406
|
maxExpandedBytes: options.maxExpandedBytes,
|
|
7876
8407
|
...options.sidecars === undefined ? {} : { sidecars: options.sidecars }
|
|
7877
8408
|
});
|
|
7878
|
-
renameExclusive(extracted.payload,
|
|
7879
|
-
await
|
|
7880
|
-
const candidateTreeIdentity = await readUpdateTreeIdentity(
|
|
8409
|
+
renameExclusive(extracted.payload, join30(preparing, "candidate"));
|
|
8410
|
+
await rm9(extracted.directory, { recursive: true, force: true });
|
|
8411
|
+
const candidateTreeIdentity = await readUpdateTreeIdentity(join30(preparing, "candidate"));
|
|
7881
8412
|
if (!candidateTreeIdentity)
|
|
7882
8413
|
throw new Error("Update candidate tree identity could not be read");
|
|
7883
|
-
const candidateTreeDigest = await readUpdateTreeDigest(
|
|
8414
|
+
const candidateTreeDigest = await readUpdateTreeDigest(join30(preparing, "candidate"));
|
|
7884
8415
|
await writeUpdateStageState(preparing, newUpdateStageState({
|
|
7885
8416
|
version: plan.version,
|
|
7886
8417
|
previousVersion: options.currentVersion,
|
|
@@ -7938,7 +8469,7 @@ async function stageUpdateSwap(options) {
|
|
|
7938
8469
|
return result;
|
|
7939
8470
|
} finally {
|
|
7940
8471
|
if (!published)
|
|
7941
|
-
await
|
|
8472
|
+
await rm9(preparing, { recursive: true, force: true });
|
|
7942
8473
|
}
|
|
7943
8474
|
}
|
|
7944
8475
|
|
|
@@ -7965,11 +8496,11 @@ function isolatedEnv(parent, profile, platform) {
|
|
|
7965
8496
|
RUNNER_ENVIRONMENT: "github-hosted",
|
|
7966
8497
|
HOME: profile,
|
|
7967
8498
|
USERPROFILE: profile,
|
|
7968
|
-
LOCALAPPDATA:
|
|
7969
|
-
XDG_DATA_HOME:
|
|
7970
|
-
TMP:
|
|
7971
|
-
TEMP:
|
|
7972
|
-
TMPDIR:
|
|
8499
|
+
LOCALAPPDATA: join31(profile, "LocalAppData"),
|
|
8500
|
+
XDG_DATA_HOME: join31(profile, ".local", "share"),
|
|
8501
|
+
TMP: join31(profile, "tmp"),
|
|
8502
|
+
TEMP: join31(profile, "tmp"),
|
|
8503
|
+
TMPDIR: join31(profile, "tmp"),
|
|
7973
8504
|
ELECTROBUN_INSTALLER_UI_AUTOCLOSE: "1"
|
|
7974
8505
|
});
|
|
7975
8506
|
if (platform === "windows-x64")
|
|
@@ -8006,7 +8537,7 @@ async function boundedStderr(stream, limit = 64 * 1024) {
|
|
|
8006
8537
|
return text.slice(-limit);
|
|
8007
8538
|
}
|
|
8008
8539
|
function shouldLaunchInstalledApp(state) {
|
|
8009
|
-
return state.platform
|
|
8540
|
+
return isMacInstallerPlatform(state.platform) && state.ready && !state.launched && !state.acknowledged && state.installerExit === 0;
|
|
8010
8541
|
}
|
|
8011
8542
|
var shim = `#!/bin/sh
|
|
8012
8543
|
umask 077
|
|
@@ -8064,15 +8595,15 @@ async function observeInstalledApp(options) {
|
|
|
8064
8595
|
await preflightInstallerRuntime({ env: parent, runtime: candidate.path, bootstrap });
|
|
8065
8596
|
stage("runtime-preflight-passed");
|
|
8066
8597
|
for (const path of [
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8598
|
+
join31(prepared.profile, "LocalAppData"),
|
|
8599
|
+
join31(prepared.profile, ".local", "share"),
|
|
8600
|
+
join31(prepared.profile, "tmp")
|
|
8070
8601
|
])
|
|
8071
8602
|
await mkdir9(path, { recursive: true, mode: 448 });
|
|
8072
|
-
const mac = options.platform
|
|
8073
|
-
const installedRoot = mac ?
|
|
8074
|
-
const resources =
|
|
8075
|
-
const worker =
|
|
8603
|
+
const mac = isMacInstallerPlatform(options.platform), windows = options.platform === "windows-x64";
|
|
8604
|
+
const installedRoot = mac ? join31(prepared.incoming, `${options.appName}.app`, "Contents") : join31(prepared.profile, windows ? "LocalAppData" : ".local/share", options.appId, "stable", "app");
|
|
8605
|
+
const resources = join31(installedRoot, "Resources"), binary = join31(installedRoot, mac ? "MacOS" : "bin"), launcher = join31(binary, windows ? "launcher.exe" : "launcher"), runtime = join31(binary, windows ? "bun.exe" : "bun");
|
|
8606
|
+
const worker = join31(resources, "app", "bun", "index.js");
|
|
8076
8607
|
const sidecars = options.sidecars ?? [];
|
|
8077
8608
|
let foreignHits = 0;
|
|
8078
8609
|
const sentinel = policy ? Bun.serve({
|
|
@@ -8123,7 +8654,7 @@ async function observeInstalledApp(options) {
|
|
|
8123
8654
|
throw new Error("Foreign network sentinel unavailable");
|
|
8124
8655
|
foreignHits = 0;
|
|
8125
8656
|
const nonce = randomBytes3(24).toString("hex");
|
|
8126
|
-
const ack =
|
|
8657
|
+
const ack = join31(run.directory, "ack"), permit = join31(run.directory, "permit"), observation = join31(run.directory, "observation"), unexpected = join31(run.directory, "unexpected"), pidRecord = join31(run.directory, "worker-pid");
|
|
8127
8658
|
const env = {
|
|
8128
8659
|
...baseEnv,
|
|
8129
8660
|
FRAMEWORK_CI_NONCE: nonce,
|
|
@@ -8136,13 +8667,13 @@ async function observeInstalledApp(options) {
|
|
|
8136
8667
|
};
|
|
8137
8668
|
let launchRecord, expectedApp;
|
|
8138
8669
|
if (mac && viaInstaller) {
|
|
8139
|
-
const shimDir =
|
|
8670
|
+
const shimDir = join31(run.directory, "launch-shim");
|
|
8140
8671
|
await mkdir9(shimDir, { mode: 448 });
|
|
8141
|
-
const path =
|
|
8142
|
-
await
|
|
8672
|
+
const path = join31(shimDir, "open");
|
|
8673
|
+
await writeFile9(path, shim, { flag: "wx", mode: 448 });
|
|
8143
8674
|
await chmod2(path, 448);
|
|
8144
|
-
expectedApp =
|
|
8145
|
-
launchRecord =
|
|
8675
|
+
expectedApp = join31(await realpath9(prepared.incoming), `${options.appName}.app`);
|
|
8676
|
+
launchRecord = join31(run.directory, "launch-record");
|
|
8146
8677
|
Object.assign(env, {
|
|
8147
8678
|
PATH: shimDir + delimiter + (env.PATH ?? ""),
|
|
8148
8679
|
FRAMEWORK_CI_EXPECTED_APP: expectedApp,
|
|
@@ -8178,7 +8709,7 @@ async function observeInstalledApp(options) {
|
|
|
8178
8709
|
const error = installerErrorName(await Promise.race([installerStderr, Bun.sleep(2000).then(() => "")]));
|
|
8179
8710
|
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"})`);
|
|
8180
8711
|
}
|
|
8181
|
-
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(
|
|
8712
|
+
const ready = await pathExists(worker) && await pathExists(launcher) && await pathExists(join31(resources, "version.json"));
|
|
8182
8713
|
if (installer && shouldLaunchInstalledApp({
|
|
8183
8714
|
platform: options.platform,
|
|
8184
8715
|
ready,
|
|
@@ -8186,17 +8717,17 @@ async function observeInstalledApp(options) {
|
|
|
8186
8717
|
acknowledged: await pathExists(ack),
|
|
8187
8718
|
installerExit: installer.exitCode
|
|
8188
8719
|
})) {
|
|
8189
|
-
if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await
|
|
8720
|
+
if (!launchRecord || !expectedApp || !await pathExists(launchRecord) || await readFile11(launchRecord, "utf8") !== expectedApp + `
|
|
8190
8721
|
`)
|
|
8191
8722
|
throw new Error("Installer launch request mismatch");
|
|
8192
8723
|
app = spawnApp();
|
|
8193
8724
|
}
|
|
8194
8725
|
if (await pathExists(ack) && !granted) {
|
|
8195
8726
|
stage("worker-acknowledged");
|
|
8196
|
-
if (await
|
|
8727
|
+
if (await readFile11(ack, "utf8") !== nonce + `
|
|
8197
8728
|
`)
|
|
8198
8729
|
throw new Error("Worker guard acknowledgement mismatch");
|
|
8199
|
-
const record = await
|
|
8730
|
+
const record = await readFile11(pidRecord, "utf8"), match = /^([a-f0-9]{48})\n([1-9]\d{0,9})\n$/.exec(record);
|
|
8200
8731
|
if (!match || match[1] !== nonce || Number(match[2]) < 2 || Number(match[2]) === process.pid)
|
|
8201
8732
|
throw new Error("Worker process identity mismatch");
|
|
8202
8733
|
guardedPid = Number(match[2]);
|
|
@@ -8204,7 +8735,7 @@ async function observeInstalledApp(options) {
|
|
|
8204
8735
|
if (viaInstaller)
|
|
8205
8736
|
await installerUnchanged();
|
|
8206
8737
|
stage("installed-files-verified");
|
|
8207
|
-
await
|
|
8738
|
+
await writeFile9(permit, nonce + `
|
|
8208
8739
|
`, { flag: "wx", mode: 384 });
|
|
8209
8740
|
granted = true;
|
|
8210
8741
|
deadline = performance.now() + 90000;
|
|
@@ -8354,7 +8885,7 @@ async function observeInstalledApp(options) {
|
|
|
8354
8885
|
await swapAfterExit(target, staged.staging);
|
|
8355
8886
|
stage("update-swapped");
|
|
8356
8887
|
await preflightInstallerRuntime({ env: parent, runtime, bootstrap });
|
|
8357
|
-
const directory =
|
|
8888
|
+
const directory = join31(prepared.directory, "update");
|
|
8358
8889
|
await mkdir9(directory, { mode: 448 });
|
|
8359
8890
|
const updated = await observeRun({
|
|
8360
8891
|
directory,
|
|
@@ -8393,7 +8924,7 @@ async function swapAfterExit(target, staging) {
|
|
|
8393
8924
|
// ../../src/installer/installer-qualification-command.ts
|
|
8394
8925
|
async function qualifyInstallerCommand(options) {
|
|
8395
8926
|
const { env, config, tag, platform, renderer } = options;
|
|
8396
|
-
if (!
|
|
8927
|
+
if (!isInstallerPlatform(platform) || !["native", "cef"].includes(renderer) || typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string" || typeof config.appId !== "string")
|
|
8397
8928
|
throw new Error("Invalid installer qualification context");
|
|
8398
8929
|
if (env.RELEASE_TAG !== tag)
|
|
8399
8930
|
throw new Error("Installer release tag mismatch");
|
|
@@ -8403,7 +8934,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
8403
8934
|
const parsed = parseReleaseConfig(config), requirements = parsed.requirements(tag), policy = requirements.offlinePolicy, names = requirements.platforms[platform];
|
|
8404
8935
|
if (!policy || !names || names.length !== 2)
|
|
8405
8936
|
throw new Error("Installer qualification requires an explicit offline policy and payloads");
|
|
8406
|
-
const directory = resolve14(options.directory), destination =
|
|
8937
|
+
const directory = resolve14(options.directory), destination = join32(directory, `installer-test-${platform}.json`);
|
|
8407
8938
|
try {
|
|
8408
8939
|
await lstat19(destination);
|
|
8409
8940
|
throw new Error("Installer receipt already exists");
|
|
@@ -8419,8 +8950,8 @@ async function qualifyInstallerCommand(options) {
|
|
|
8419
8950
|
appName: app.appName,
|
|
8420
8951
|
appId: app.appId,
|
|
8421
8952
|
version: plan.version,
|
|
8422
|
-
installer:
|
|
8423
|
-
archive:
|
|
8953
|
+
installer: join32(directory, names[0]),
|
|
8954
|
+
archive: join32(directory, names[1]),
|
|
8424
8955
|
expectedReads: parsed.expectedReads,
|
|
8425
8956
|
offlinePolicy: policy,
|
|
8426
8957
|
sidecars: parsed.sidecars
|
|
@@ -8445,17 +8976,17 @@ async function qualifyInstallerCommand(options) {
|
|
|
8445
8976
|
assets: result.artifacts
|
|
8446
8977
|
};
|
|
8447
8978
|
validateInstallerReceipt(identity, receipt, platform, names, result.artifacts, policy);
|
|
8448
|
-
await
|
|
8979
|
+
await writeFile10(destination, JSON.stringify(receipt, null, 2) + `
|
|
8449
8980
|
`, { flag: "wx", mode: 384 });
|
|
8450
8981
|
return receipt;
|
|
8451
8982
|
}
|
|
8452
8983
|
|
|
8453
8984
|
// ../../src/installer/installer-upgrade-command.ts
|
|
8454
|
-
import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as
|
|
8455
|
-
import { join as
|
|
8985
|
+
import { lstat as lstat20, mkdir as mkdir10, rename as rename2, writeFile as writeFile11 } from "fs/promises";
|
|
8986
|
+
import { join as join34, resolve as resolve16 } from "path";
|
|
8456
8987
|
|
|
8457
8988
|
// ../../src/installer/upgrade-asset-download.ts
|
|
8458
|
-
import { createHash as
|
|
8989
|
+
import { createHash as createHash20 } from "crypto";
|
|
8459
8990
|
import { open as open10, unlink as unlink3 } from "fs/promises";
|
|
8460
8991
|
|
|
8461
8992
|
// ../../src/installer/write-all.ts
|
|
@@ -8493,7 +9024,7 @@ async function downloadAsset(options) {
|
|
|
8493
9024
|
discardStream(response.body);
|
|
8494
9025
|
throw error;
|
|
8495
9026
|
}
|
|
8496
|
-
const hash =
|
|
9027
|
+
const hash = createHash20("sha256");
|
|
8497
9028
|
let completed = false;
|
|
8498
9029
|
try {
|
|
8499
9030
|
let size = 0;
|
|
@@ -8533,7 +9064,7 @@ async function downloadAsset(options) {
|
|
|
8533
9064
|
}
|
|
8534
9065
|
|
|
8535
9066
|
// ../../src/updates/feed/update-discovery.ts
|
|
8536
|
-
import { createHash as
|
|
9067
|
+
import { createHash as createHash21 } from "crypto";
|
|
8537
9068
|
var MAX_POINTER_BYTES = 262144;
|
|
8538
9069
|
var MAX_LEDGER_BYTES2 = 1024 * 1024;
|
|
8539
9070
|
async function discoverSignedRelease(options) {
|
|
@@ -8569,7 +9100,7 @@ async function discoverSignedRelease(options) {
|
|
|
8569
9100
|
throw new Error("No qualified channel descriptor is available");
|
|
8570
9101
|
const { tag } = selected;
|
|
8571
9102
|
const bytes = await readReleaseBytes(await get(`${tag}/${discoveryName}`), 65536);
|
|
8572
|
-
if (bytes.length !== listed.size ||
|
|
9103
|
+
if (bytes.length !== listed.size || createHash21("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
8573
9104
|
throw new Error("Channel descriptor differs from its release");
|
|
8574
9105
|
let signed;
|
|
8575
9106
|
try {
|
|
@@ -8587,8 +9118,8 @@ async function discoverSignedRelease(options) {
|
|
|
8587
9118
|
}
|
|
8588
9119
|
|
|
8589
9120
|
// ../../src/updates/install/update-download.ts
|
|
8590
|
-
import { mkdtemp as
|
|
8591
|
-
import { basename as basename14, dirname as dirname13, join as
|
|
9121
|
+
import { mkdtemp as mkdtemp10, open as open11, realpath as realpath10, rm as rm10 } from "fs/promises";
|
|
9122
|
+
import { basename as basename14, dirname as dirname13, join as join33, resolve as resolve15 } from "path";
|
|
8592
9123
|
async function downloadVerifiedRelease(options) {
|
|
8593
9124
|
const { descriptor, maxBytes } = options;
|
|
8594
9125
|
const timeout = options.timeoutMs ?? 120000;
|
|
@@ -8621,12 +9152,12 @@ async function downloadVerifiedRelease(options) {
|
|
|
8621
9152
|
throw new Error("Release download size mismatch");
|
|
8622
9153
|
}
|
|
8623
9154
|
const root = options.createTemporaryDirectory ? await realpath10(resolve15(options.directory)) : resolve15(options.directory);
|
|
8624
|
-
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await
|
|
9155
|
+
const allocated = options.createTemporaryDirectory ? await options.createTemporaryDirectory(root) : await mkdtemp10(join33(root, "framework-update-"));
|
|
8625
9156
|
const temporaryDirectory = resolve15(allocated);
|
|
8626
9157
|
if (dirname13(temporaryDirectory) !== root || !basename14(temporaryDirectory).startsWith("framework-update-"))
|
|
8627
9158
|
throw new Error("Invalid update download directory");
|
|
8628
9159
|
temporary = temporaryDirectory;
|
|
8629
|
-
const path =
|
|
9160
|
+
const path = join33(temporary, "archive");
|
|
8630
9161
|
const file = await open11(path, "wx", 384);
|
|
8631
9162
|
try {
|
|
8632
9163
|
async function* writeChunks() {
|
|
@@ -8683,7 +9214,7 @@ async function downloadVerifiedRelease(options) {
|
|
|
8683
9214
|
return { path, directory: temporary };
|
|
8684
9215
|
} catch (error) {
|
|
8685
9216
|
if (temporary)
|
|
8686
|
-
await
|
|
9217
|
+
await rm10(temporary, { recursive: true, force: true });
|
|
8687
9218
|
throw error;
|
|
8688
9219
|
} finally {
|
|
8689
9220
|
clearTimeout(stallTimer);
|
|
@@ -8700,6 +9231,7 @@ var MAX_COMPRESSED_BYTES2 = 1024 * 1024 * 1024;
|
|
|
8700
9231
|
var MAX_EXPANDED_BYTES2 = 4 * 1024 * 1024 * 1024;
|
|
8701
9232
|
var targets = {
|
|
8702
9233
|
"macos-arm64": ["darwin", "arm64"],
|
|
9234
|
+
"macos-x64": ["darwin", "x64"],
|
|
8703
9235
|
"windows-x64": ["win32", "x64"],
|
|
8704
9236
|
"linux-x64": ["linux", "x64"],
|
|
8705
9237
|
"linux-arm64": ["linux", "arm64"]
|
|
@@ -8729,7 +9261,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8729
9261
|
const parsed = parseReleaseConfig(config), feed = feedUrl(parsed.feed), requirements = parsed.requirements(tag), names = requirements.platforms[platform];
|
|
8730
9262
|
if (!requirements.offlinePolicy || !names || names.length !== 2)
|
|
8731
9263
|
throw new Error("Upgrade qualification requires an explicit offline policy and payloads");
|
|
8732
|
-
const directory = resolve16(options.directory), destination =
|
|
9264
|
+
const directory = resolve16(options.directory), destination = join34(directory, `upgrade-test-${platform}.json`);
|
|
8733
9265
|
try {
|
|
8734
9266
|
await lstat20(destination);
|
|
8735
9267
|
throw new Error("Upgrade receipt already exists");
|
|
@@ -8752,7 +9284,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8752
9284
|
const channel = "daily";
|
|
8753
9285
|
const trust = { ...base, channel };
|
|
8754
9286
|
const discovery = discoveryName(config, channel, platform);
|
|
8755
|
-
const signed = await readJsonFile(
|
|
9287
|
+
const signed = await readJsonFile(join34(directory, discovery), 65536, "staged descriptor");
|
|
8756
9288
|
const verified = verifyReleaseDescriptor(signed, trust);
|
|
8757
9289
|
if (!verified.ok || verified.descriptor.tag !== tag || verified.descriptor.asset.name !== names[1])
|
|
8758
9290
|
throw new Error("Untrusted staged descriptor");
|
|
@@ -8775,7 +9307,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8775
9307
|
return null;
|
|
8776
9308
|
if (previous.tag === tag || !versionLessThan(previous.version, descriptor.version))
|
|
8777
9309
|
throw new Error("Previous release is not older than this release");
|
|
8778
|
-
const work =
|
|
9310
|
+
const work = join34(directory, `upgrade-${platform}`);
|
|
8779
9311
|
await mkdir10(work, { mode: 448 });
|
|
8780
9312
|
const downloaded = await downloadVerifiedRelease({
|
|
8781
9313
|
descriptor: previous,
|
|
@@ -8784,12 +9316,12 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8784
9316
|
timeoutMs: 600000,
|
|
8785
9317
|
fetch: fetcher
|
|
8786
9318
|
});
|
|
8787
|
-
const previousArchive =
|
|
9319
|
+
const previousArchive = join34(work, previous.asset.name);
|
|
8788
9320
|
await rename2(downloaded.path, previousArchive);
|
|
8789
9321
|
const installerName = parsed.requirements(previous.tag).platforms[platform]?.[0];
|
|
8790
9322
|
if (!installerName)
|
|
8791
9323
|
throw new Error("Previous release has no installer for this platform");
|
|
8792
|
-
const previousInstaller =
|
|
9324
|
+
const previousInstaller = join34(work, installerName);
|
|
8793
9325
|
await downloadAsset({
|
|
8794
9326
|
feed,
|
|
8795
9327
|
tag: previous.tag,
|
|
@@ -8813,7 +9345,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8813
9345
|
update: {
|
|
8814
9346
|
descriptor,
|
|
8815
9347
|
trust,
|
|
8816
|
-
archive:
|
|
9348
|
+
archive: join34(directory, names[1]),
|
|
8817
9349
|
maxCompressedBytes: MAX_COMPRESSED_BYTES2,
|
|
8818
9350
|
maxExpandedBytes: MAX_EXPANDED_BYTES2
|
|
8819
9351
|
}
|
|
@@ -8830,7 +9362,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
8830
9362
|
updated: true,
|
|
8831
9363
|
rendererEvidence: result.updated.evidence
|
|
8832
9364
|
};
|
|
8833
|
-
await
|
|
9365
|
+
await writeFile11(destination, JSON.stringify(receipt, null, 2) + `
|
|
8834
9366
|
`, { flag: "wx", mode: 384 });
|
|
8835
9367
|
return receipt;
|
|
8836
9368
|
}
|
|
@@ -8850,9 +9382,8 @@ function stepRenderer(env) {
|
|
|
8850
9382
|
}
|
|
8851
9383
|
|
|
8852
9384
|
// ../../src/release/release-steps.ts
|
|
8853
|
-
var PLATFORMS = ["macos-arm64", "windows-x64", "linux-x64"];
|
|
8854
9385
|
function releasePlatform(value) {
|
|
8855
|
-
if (!
|
|
9386
|
+
if (!isInstallerPlatform(value))
|
|
8856
9387
|
throw new Error("Expected a release platform");
|
|
8857
9388
|
return value;
|
|
8858
9389
|
}
|
|
@@ -8861,6 +9392,7 @@ function electrobunArtifacts(appName, platform) {
|
|
|
8861
9392
|
const bundle = appName.replaceAll(" ", "");
|
|
8862
9393
|
return {
|
|
8863
9394
|
"macos-arm64": [`macos-arm64-${bundle}.dmg`, `stable-macos-arm64-${bundle}.app.tar.zst`],
|
|
9395
|
+
"macos-x64": [`macos-x64-${bundle}.dmg`, `stable-macos-x64-${bundle}.app.tar.zst`],
|
|
8864
9396
|
"windows-x64": [`win-x64-${bundle}-Setup.zip`, `stable-win-x64-${bundle}.tar.zst`],
|
|
8865
9397
|
"linux-x64": [`linux-x64-${bundle}-Setup.tar.gz`, `stable-linux-x64-${bundle}.tar.zst`],
|
|
8866
9398
|
"linux-arm64": [`linux-arm64-${bundle}-Setup.tar.gz`, `stable-linux-arm64-${bundle}.tar.zst`]
|
|
@@ -8883,18 +9415,20 @@ runId=${result.runId}
|
|
|
8883
9415
|
var stageBuildStepEffect = (context, directory, artifacts = "artifacts") => Effect25.gen(function* () {
|
|
8884
9416
|
const fs = yield* ReleaseFs;
|
|
8885
9417
|
const [installerAsset, archiveAsset] = platformAssets(context);
|
|
9418
|
+
if (context.platform === "windows-x64" && !installerAsset.toLowerCase().endsWith(".zip"))
|
|
9419
|
+
return yield* fail("Electrobun Setup ZIP cannot produce the configured Windows installer");
|
|
8886
9420
|
const [installer, archive] = electrobunArtifacts(context.config.appName, context.platform);
|
|
8887
9421
|
const parsed = parseReleaseConfig(context.config);
|
|
8888
9422
|
const requirements = parsed.requirements(context.tag);
|
|
8889
9423
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
8890
9424
|
const packed = yield* scopedTempDirectory("framework-command-pack-");
|
|
8891
9425
|
const sources = {
|
|
8892
|
-
[installerAsset]:
|
|
8893
|
-
[archiveAsset]:
|
|
9426
|
+
[installerAsset]: join35(artifacts, installer),
|
|
9427
|
+
[archiveAsset]: join35(artifacts, archive)
|
|
8894
9428
|
};
|
|
8895
9429
|
for (const policy of parsed.commandArtifacts) {
|
|
8896
9430
|
const name = requirements.commandArtifacts[policy.kind][context.platform];
|
|
8897
|
-
sources[name] =
|
|
9431
|
+
sources[name] = join35(packed, name);
|
|
8898
9432
|
yield* step(() => packCommandArtifact({
|
|
8899
9433
|
source: policy.build,
|
|
8900
9434
|
archive: sources[name],
|
|
@@ -8912,10 +9446,10 @@ var inspectStagedStepEffect = (context, directory) => Effect25.gen(function* ()
|
|
|
8912
9446
|
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
8913
9447
|
if (entries.length !== assets.length || entries.some((entry) => !entry.isFile() || !assets.includes(entry.name)))
|
|
8914
9448
|
return yield* fail("Staged platform directory contains unexpected files");
|
|
8915
|
-
const [installer, archive] = platformAssets(context).map((name) =>
|
|
9449
|
+
const [installer, archive] = platformAssets(context).map((name) => join35(directory, name));
|
|
8916
9450
|
for (const policy of parsed.commandArtifacts)
|
|
8917
9451
|
yield* step(() => readCommandArtifact({
|
|
8918
|
-
archive:
|
|
9452
|
+
archive: join35(directory, requirements.commandArtifacts[policy.kind][context.platform]),
|
|
8919
9453
|
executable: policy.executable,
|
|
8920
9454
|
platform: context.platform
|
|
8921
9455
|
}));
|
|
@@ -8940,31 +9474,31 @@ var qualifyUpgradeStepEffect = (context, directory, onStage) => Effect25.suspend
|
|
|
8940
9474
|
const renderer = stepRenderer(context.env);
|
|
8941
9475
|
return step(() => qualifyUpgradeCommand({ ...context, renderer, directory, ...onStage ? { onStage } : {} }));
|
|
8942
9476
|
});
|
|
8943
|
-
var
|
|
8944
|
-
var selectRetainedStep = (context) =>
|
|
8945
|
-
var stageBuildStep = (context, directory, artifacts) =>
|
|
8946
|
-
var inspectStagedStep = (context, directory) =>
|
|
8947
|
-
var qualifyStep = (context, directory) =>
|
|
8948
|
-
var qualifyUpgradeStep = (context, directory, onStage) =>
|
|
9477
|
+
var run3 = (context, effect) => runReleaseLibrary(provideLibraryPorts({ run: planGitHubRun(context.env) })(effect));
|
|
9478
|
+
var selectRetainedStep = (context) => run3(context, selectRetainedStepEffect(context));
|
|
9479
|
+
var stageBuildStep = (context, directory, artifacts) => run3(context, stageBuildStepEffect(context, directory, artifacts));
|
|
9480
|
+
var inspectStagedStep = (context, directory) => run3(context, inspectStagedStepEffect(context, directory));
|
|
9481
|
+
var qualifyStep = (context, directory) => run3(context, qualifyStepEffect(context, directory));
|
|
9482
|
+
var qualifyUpgradeStep = (context, directory, onStage) => run3(context, qualifyUpgradeStepEffect(context, directory, onStage));
|
|
8949
9483
|
// src/library/linux-package-pair.ts
|
|
8950
|
-
import { execFile as
|
|
9484
|
+
import { execFile as execFile4 } from "child_process";
|
|
8951
9485
|
import {
|
|
8952
9486
|
chmod as chmod3,
|
|
8953
9487
|
link,
|
|
8954
9488
|
mkdir as mkdir11,
|
|
8955
|
-
mkdtemp as
|
|
9489
|
+
mkdtemp as mkdtemp11,
|
|
8956
9490
|
open as open12,
|
|
8957
|
-
readFile as
|
|
9491
|
+
readFile as readFile12,
|
|
8958
9492
|
realpath as realpath11,
|
|
8959
|
-
rm as
|
|
8960
|
-
writeFile as
|
|
9493
|
+
rm as rm11,
|
|
9494
|
+
writeFile as writeFile12
|
|
8961
9495
|
} from "fs/promises";
|
|
8962
|
-
import { dirname as dirname14, join as
|
|
8963
|
-
import { promisify as
|
|
9496
|
+
import { dirname as dirname14, join as join36, resolve as resolve17 } from "path";
|
|
9497
|
+
import { promisify as promisify4 } from "util";
|
|
8964
9498
|
var shasum = /^[a-f0-9]{64}$/;
|
|
8965
9499
|
var basename15 = /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
8966
9500
|
var validTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/;
|
|
8967
|
-
var exec =
|
|
9501
|
+
var exec = promisify4(execFile4);
|
|
8968
9502
|
function requireThat2(condition, message) {
|
|
8969
9503
|
if (!condition)
|
|
8970
9504
|
throw new Error(message);
|
|
@@ -8993,9 +9527,9 @@ var inspectWithNativeTools = async (tool, args) => {
|
|
|
8993
9527
|
throw new Error(`${tool} could not inspect Linux package candidate`, { cause: error });
|
|
8994
9528
|
}
|
|
8995
9529
|
};
|
|
8996
|
-
function parseDebianIdentity(text, packageName, version) {
|
|
9530
|
+
function parseDebianIdentity(text, packageName, version, arch) {
|
|
8997
9531
|
const fields = text.trimEnd().split(/\r?\n/);
|
|
8998
|
-
requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`,
|
|
9532
|
+
requireThat2(fields.length === 3 && new Set(fields).size === 3 && [`Package: ${packageName}`, `Version: ${version}`, `Architecture: ${arch}`].every((value) => fields.includes(value)), "Debian package name, version or architecture does not match the release policy");
|
|
8999
9533
|
}
|
|
9000
9534
|
function requireRegularDesktopEntry(listing, id) {
|
|
9001
9535
|
const lines = listing.trimEnd().split(/\r?\n/);
|
|
@@ -9049,11 +9583,11 @@ function digestWindow(runtime) {
|
|
|
9049
9583
|
requireThat2(matches.length === 1, "Expected one pinned AppImage runtime digest section");
|
|
9050
9584
|
return matches[0];
|
|
9051
9585
|
}
|
|
9052
|
-
function
|
|
9053
|
-
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) ===
|
|
9586
|
+
function type2(bytes, elfMachine) {
|
|
9587
|
+
return bytes.length >= 64 && bytes.toString("hex", 0, 6) === "7f454c460201" && bytes.toString("hex", 8, 11) === "414902" && bytes.readUInt16LE(18) === elfMachine;
|
|
9054
9588
|
}
|
|
9055
|
-
async function verifyEmbeddedRuntime(path, runtime) {
|
|
9056
|
-
requireThat2(
|
|
9589
|
+
async function verifyEmbeddedRuntime(path, runtime, elfMachine) {
|
|
9590
|
+
requireThat2(type2(runtime, elfMachine), "Expected a pinned native Type 2 AppImage runtime");
|
|
9057
9591
|
const ignored = digestWindow(runtime);
|
|
9058
9592
|
const fd = await open12(path, "r");
|
|
9059
9593
|
try {
|
|
@@ -9065,7 +9599,7 @@ async function verifyEmbeddedRuntime(path, runtime) {
|
|
|
9065
9599
|
throw new Error("Incomplete embedded AppImage runtime or SquashFS header");
|
|
9066
9600
|
filled += bytesRead;
|
|
9067
9601
|
}
|
|
9068
|
-
requireThat2(
|
|
9602
|
+
requireThat2(type2(prefix, elfMachine), "Expected a native Type 2 AppImage");
|
|
9069
9603
|
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");
|
|
9070
9604
|
requireThat2(prefix.toString("ascii", runtime.length) === "hsqs", "Missing embedded SquashFS at the pinned runtime offset");
|
|
9071
9605
|
} finally {
|
|
@@ -9074,11 +9608,14 @@ async function verifyEmbeddedRuntime(path, runtime) {
|
|
|
9074
9608
|
}
|
|
9075
9609
|
async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
9076
9610
|
const { expected, sources } = options;
|
|
9611
|
+
const architecture = expected.architecture === undefined ? "x64" : expected.architecture;
|
|
9612
|
+
requireThat2(isLinuxPackageArchitecture(architecture), "Invalid trusted Linux package architecture");
|
|
9613
|
+
const target = linuxPackageArchitectures[architecture];
|
|
9077
9614
|
const receipt = record2(options.producer);
|
|
9078
9615
|
const archive = validIdentity(expected.archive);
|
|
9079
9616
|
const runtime = validIdentity(expected.runtime);
|
|
9080
9617
|
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");
|
|
9081
|
-
requireThat2(receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform ===
|
|
9618
|
+
requireThat2(receipt.releaseAuthorized !== false && receipt.schema !== "private-linux-package-formats/v1" && receipt.tag === expected.tag && receipt.sourceSha === expected.sourceSha && receipt.platform === target.platform && receipt.updateArchiveSha256 === archive.sha256 && Array.isArray(receipt.artifacts) && receipt.artifacts.length === 2, "Package producer receipt names a different source, tag, platform or update archive");
|
|
9082
9619
|
const names = [expected.debName, expected.appImageName];
|
|
9083
9620
|
const artifacts = receipt.artifacts.map(validIdentity);
|
|
9084
9621
|
const trustedArtifacts = expected.artifacts.map(validIdentity);
|
|
@@ -9089,7 +9626,7 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
9089
9626
|
}), "Package producer receipt must describe exactly the protected DEB and AppImage");
|
|
9090
9627
|
const destination = resolve17(options.output);
|
|
9091
9628
|
const parent = await realpath11(dirname14(destination));
|
|
9092
|
-
const work = await
|
|
9629
|
+
const work = await mkdtemp11(join36(parent, ".linux-package-pair-"));
|
|
9093
9630
|
try {
|
|
9094
9631
|
const files = await runReleaseLibrary(provideLibraryPorts()(stageExpectedFilesEffect({
|
|
9095
9632
|
directory: work,
|
|
@@ -9097,11 +9634,11 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
9097
9634
|
sources
|
|
9098
9635
|
})));
|
|
9099
9636
|
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");
|
|
9100
|
-
const deb =
|
|
9101
|
-
const image =
|
|
9637
|
+
const deb = join36(work, expected.debName);
|
|
9638
|
+
const image = join36(work, expected.appImageName);
|
|
9102
9639
|
const version = expected.tag.slice(1);
|
|
9103
|
-
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version);
|
|
9104
|
-
await verifyEmbeddedRuntime(image, await
|
|
9640
|
+
parseDebianIdentity(await inspect("dpkg-deb", ["--field", deb, "Package", "Version", "Architecture"]), expected.debPackage, version, target.debian);
|
|
9641
|
+
await verifyEmbeddedRuntime(image, await readFile12(join36(work, runtime.name)), target.elfMachine);
|
|
9105
9642
|
const offset = String(runtime.size);
|
|
9106
9643
|
requireRegularDesktopEntry(await inspect("unsquashfs", [
|
|
9107
9644
|
"-offset",
|
|
@@ -9124,30 +9661,30 @@ async function stageLinuxPackagePairWithInspection(options, inspect) {
|
|
|
9124
9661
|
schema: "linux-package-pair/v1",
|
|
9125
9662
|
tag: expected.tag,
|
|
9126
9663
|
sourceSha: expected.sourceSha,
|
|
9127
|
-
platform:
|
|
9664
|
+
platform: target.platform,
|
|
9128
9665
|
updateArchiveSha256: archive.sha256,
|
|
9129
9666
|
artifacts: names.map((name) => artifacts.find((file) => file.name === name))
|
|
9130
9667
|
};
|
|
9131
9668
|
await mkdir11(destination);
|
|
9132
9669
|
try {
|
|
9133
9670
|
for (const name of names)
|
|
9134
|
-
await link(
|
|
9135
|
-
await
|
|
9671
|
+
await link(join36(work, name), join36(destination, name));
|
|
9672
|
+
await writeFile12(join36(destination, "linux-package-pair.json"), JSON.stringify(staged) + `
|
|
9136
9673
|
`, {
|
|
9137
9674
|
flag: "wx"
|
|
9138
9675
|
});
|
|
9139
9676
|
} catch (error) {
|
|
9140
|
-
await
|
|
9677
|
+
await rm11(destination, { recursive: true, force: true });
|
|
9141
9678
|
throw error;
|
|
9142
9679
|
}
|
|
9143
9680
|
return staged;
|
|
9144
9681
|
} finally {
|
|
9145
|
-
await
|
|
9682
|
+
await rm11(work, { recursive: true, force: true });
|
|
9146
9683
|
}
|
|
9147
9684
|
}
|
|
9148
9685
|
var stageLinuxPackagePair = (options) => stageLinuxPackagePairWithInspection(options, inspectWithNativeTools);
|
|
9149
9686
|
// src/library/linux-format-producer.ts
|
|
9150
|
-
import { createHash as
|
|
9687
|
+
import { createHash as createHash22 } from "crypto";
|
|
9151
9688
|
import { createReadStream as createReadStream2, createWriteStream } from "fs";
|
|
9152
9689
|
import {
|
|
9153
9690
|
chmod as chmod4,
|
|
@@ -9155,89 +9692,90 @@ import {
|
|
|
9155
9692
|
lstat as lstat21,
|
|
9156
9693
|
lutimes,
|
|
9157
9694
|
mkdir as mkdir12,
|
|
9158
|
-
mkdtemp as
|
|
9695
|
+
mkdtemp as mkdtemp12,
|
|
9159
9696
|
open as open13,
|
|
9160
9697
|
readdir as readdir12,
|
|
9161
9698
|
readlink as readlink3,
|
|
9162
9699
|
realpath as realpath12,
|
|
9163
|
-
rm as
|
|
9700
|
+
rm as rm12,
|
|
9164
9701
|
symlink as symlink2,
|
|
9165
9702
|
utimes,
|
|
9166
|
-
writeFile as
|
|
9703
|
+
writeFile as writeFile13
|
|
9167
9704
|
} from "fs/promises";
|
|
9168
|
-
import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as
|
|
9705
|
+
import { basename as basename16, dirname as dirname15, isAbsolute as isAbsolute7, join as join37, relative as relative5, resolve as resolve18 } from "path";
|
|
9169
9706
|
import { pipeline as pipeline2 } from "stream/promises";
|
|
9170
9707
|
var component = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
9171
9708
|
var commandName = /^[a-z0-9][a-z0-9@+._-]{0,63}$/;
|
|
9709
|
+
var debDependencyAtom = /^[a-z0-9][a-z0-9+.-]{0,63}(?: \(>= (?:0|[1-9]\d{0,8})(?:\.(?:0|[1-9]\d{0,8})){1,3}\))?$/;
|
|
9172
9710
|
var sha2562 = /^[a-f0-9]{64}$/;
|
|
9173
9711
|
var sum = async (path) => {
|
|
9174
|
-
const hash =
|
|
9712
|
+
const hash = createHash22("sha256");
|
|
9175
9713
|
for await (const chunk of createReadStream2(path))
|
|
9176
9714
|
hash.update(chunk);
|
|
9177
9715
|
return hash.digest("hex");
|
|
9178
9716
|
};
|
|
9179
9717
|
var relativeFiles = (value) => value.split("/").every((part) => component.test(part));
|
|
9180
9718
|
var text2 = (v) => v.length > 0 && v.length <= 250 && !/[\r\n]/.test(v);
|
|
9181
|
-
function
|
|
9719
|
+
function check3(ok, message) {
|
|
9182
9720
|
if (!ok)
|
|
9183
9721
|
throw new Error(message);
|
|
9184
9722
|
}
|
|
9185
9723
|
async function exactCopy(pin, to) {
|
|
9186
|
-
|
|
9724
|
+
check3(sha2562.test(pin.sha256), "Missing protected input digest");
|
|
9187
9725
|
const before = await lstat21(pin.path);
|
|
9188
|
-
|
|
9726
|
+
check3(before.isFile() && !before.isSymbolicLink() && before.size > 0, "Expected a regular pinned input");
|
|
9189
9727
|
const input = await open13(pin.path, "r");
|
|
9190
9728
|
try {
|
|
9191
9729
|
const after = await input.stat();
|
|
9192
|
-
|
|
9730
|
+
check3(after.dev === before.dev && after.ino === before.ino && after.size === before.size, "Pinned input changed");
|
|
9193
9731
|
await pipeline2(input.createReadStream({ autoClose: false, start: 0, end: before.size - 1 }), createWriteStream(to, { flags: "wx", mode: 384 }));
|
|
9194
9732
|
} finally {
|
|
9195
9733
|
await input.close();
|
|
9196
9734
|
}
|
|
9197
|
-
|
|
9735
|
+
check3((await lstat21(to)).size === before.size && await sum(to) === pin.sha256, "Pinned input digest mismatch");
|
|
9198
9736
|
}
|
|
9199
9737
|
async function regular2(root, path) {
|
|
9200
|
-
const file =
|
|
9201
|
-
|
|
9738
|
+
const file = join37(root, path);
|
|
9739
|
+
check3((await lstat21(file)).isFile() && await realpath12(file) === file, "Required bundle member is not a regular file");
|
|
9202
9740
|
return file;
|
|
9203
9741
|
}
|
|
9204
|
-
async function elf(path, appImage = false) {
|
|
9742
|
+
async function elf(path, machine, appImage = false) {
|
|
9205
9743
|
const input = await open13(path, "r");
|
|
9206
9744
|
try {
|
|
9207
9745
|
const h = Buffer.alloc(20);
|
|
9208
9746
|
const { bytesRead } = await input.read(h, 0, h.length, 0);
|
|
9209
|
-
|
|
9747
|
+
check3(bytesRead === 20 && h.toString("hex", 0, 6) === "7f454c460201" && h.readUInt16LE(18) === machine && (!appImage || h.toString("hex", 8, 11) === "414902"), "Expected a native Linux executable matching the requested architecture");
|
|
9210
9748
|
} finally {
|
|
9211
9749
|
await input.close();
|
|
9212
9750
|
}
|
|
9213
9751
|
}
|
|
9214
9752
|
async function normalizeTree(root, dir = root) {
|
|
9215
9753
|
for (const name of await readdir12(dir)) {
|
|
9216
|
-
const file =
|
|
9754
|
+
const file = join37(dir, name);
|
|
9217
9755
|
const st = await lstat21(file);
|
|
9218
9756
|
if (st.isSymbolicLink()) {
|
|
9219
|
-
|
|
9757
|
+
check3(!isAbsolute7(await readlink3(file)), "Absolute bundle symlink");
|
|
9220
9758
|
const target = relative5(root, await realpath12(file));
|
|
9221
|
-
|
|
9759
|
+
check3(target !== ".." && !target.startsWith("../") && !isAbsolute7(target), "Escaping bundle symlink");
|
|
9222
9760
|
} else if (st.isDirectory()) {
|
|
9223
9761
|
await chmod4(file, 493);
|
|
9224
9762
|
await normalizeTree(root, file);
|
|
9225
9763
|
} else {
|
|
9226
|
-
|
|
9764
|
+
check3(st.isFile(), "Unsupported bundle entry");
|
|
9227
9765
|
await chmod4(file, st.mode & 73 ? 493 : 420);
|
|
9228
9766
|
}
|
|
9229
9767
|
}
|
|
9230
9768
|
}
|
|
9231
9769
|
async function normalizeBuildTimes(directory, epoch) {
|
|
9232
9770
|
for (const name of (await readdir12(directory)).toSorted()) {
|
|
9233
|
-
const path =
|
|
9771
|
+
const path = join37(directory, name);
|
|
9234
9772
|
const info = await lstat21(path);
|
|
9235
9773
|
if (info.isSymbolicLink()) {
|
|
9236
9774
|
await lutimes(path, epoch, epoch);
|
|
9237
9775
|
} else if (info.isDirectory()) {
|
|
9238
9776
|
await normalizeBuildTimes(path, epoch);
|
|
9239
9777
|
} else {
|
|
9240
|
-
|
|
9778
|
+
check3(info.isFile(), "Unsupported packaging entry");
|
|
9241
9779
|
await utimes(path, epoch, epoch);
|
|
9242
9780
|
}
|
|
9243
9781
|
}
|
|
@@ -9245,53 +9783,56 @@ async function normalizeBuildTimes(directory, epoch) {
|
|
|
9245
9783
|
await utimes(directory, epoch, epoch);
|
|
9246
9784
|
}
|
|
9247
9785
|
async function write(root, path, value, mode = 420) {
|
|
9248
|
-
const target =
|
|
9786
|
+
const target = join37(root, path);
|
|
9249
9787
|
await mkdir12(dirname15(target), { recursive: true });
|
|
9250
|
-
await
|
|
9788
|
+
await writeFile13(target, value, { flag: "wx", mode });
|
|
9251
9789
|
await chmod4(target, mode);
|
|
9252
9790
|
}
|
|
9253
9791
|
function validatePolicy(policy) {
|
|
9254
9792
|
const executable = policy.executable ?? policy.packageName;
|
|
9255
9793
|
const links = policy.links ?? [];
|
|
9256
|
-
|
|
9257
|
-
|
|
9794
|
+
check3([policy.bundleRoot, policy.artifactStem, policy.desktopId].every((n) => component.test(n)) && /^[a-z0-9][a-z0-9+.-]+$/.test(policy.packageName) && typeof executable === "string" && commandName.test(executable) && Array.isArray(links) && links.every((link) => link && typeof link.name === "string" && commandName.test(link.name) && typeof link.target === "string" && relativeFiles(link.target) && link.name !== executable) && new Set(links.map((link) => link.name)).size === links.length && [policy.launcher, policy.icon, ...policy.debSetuid.map((item) => item.path)].every(relativeFiles) && policy.debSetuid.every((item) => sha2562.test(item.sha256)) && new Set(policy.debSetuid.map((item) => item.path)).size === policy.debSetuid.length && /^[A-Z][A-Z0-9_]*_LINUX_PACKAGE_FORMAT$/.test(policy.formatEnvironment) && policy.mimeTypes.every((x) => /^x-scheme-handler\/[a-z][a-z0-9+.-]*$/.test(x)) && [policy.name, policy.description, policy.maintainer, policy.homepage].every(text2) && policy.categories.every((x) => /^[A-Za-z0-9]+$/.test(x)) && policy.dependencies.every((x) => x.length <= 256 && x === x.trim() && x.split(" | ").every((atom) => debDependencyAtom.test(atom))), "Invalid app Linux packaging policy");
|
|
9795
|
+
check3(new URL(policy.homepage).protocol === "https:", "Expected HTTPS homepage");
|
|
9258
9796
|
}
|
|
9259
9797
|
async function buildLinuxFormats(input, host) {
|
|
9260
9798
|
const { tag, sourceSha, expectedSourceSha, sourceDateEpoch, policy } = input;
|
|
9261
9799
|
const checkAbort = () => host.signal?.throwIfAborted();
|
|
9262
9800
|
checkAbort();
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9801
|
+
const architecture = input.architecture === undefined ? "x64" : input.architecture;
|
|
9802
|
+
check3(isLinuxPackageArchitecture(architecture), "Unsupported Linux package architecture");
|
|
9803
|
+
check3(host.os === "linux" && host.arch === architecture, `Requires native Linux ${architecture}`);
|
|
9804
|
+
const target = linuxPackageArchitectures[architecture];
|
|
9805
|
+
check3(/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) && /^[a-f0-9]{40}$/.test(sourceSha) && sourceSha === expectedSourceSha, "Wrong protected build source or tag");
|
|
9806
|
+
check3(Number.isSafeInteger(sourceDateEpoch) && sourceDateEpoch > 0 && sourceDateEpoch <= 4294967295, "Expected valid protected SOURCE_DATE_EPOCH");
|
|
9266
9807
|
if (input.identity)
|
|
9267
|
-
|
|
9808
|
+
check3(input.identity.workflowSha === sourceSha && /^[1-9]\d{0,19}$/.test(input.identity.runId) && Number.isSafeInteger(input.identity.runAttempt) && input.identity.runAttempt > 0, "Invalid Linux build workflow identity");
|
|
9268
9809
|
const env = { SOURCE_DATE_EPOCH: String(sourceDateEpoch), LC_ALL: "C", TZ: "UTC" };
|
|
9269
9810
|
validatePolicy(policy);
|
|
9270
9811
|
const requested = resolve18(input.output);
|
|
9271
9812
|
const parent = await realpath12(dirname15(requested));
|
|
9272
|
-
const output =
|
|
9273
|
-
const work = await
|
|
9813
|
+
const output = join37(parent, basename16(requested));
|
|
9814
|
+
const work = await mkdtemp12(join37(parent, ".linux-formats-"));
|
|
9274
9815
|
let outputOwned = false;
|
|
9275
9816
|
try {
|
|
9276
|
-
const archive =
|
|
9277
|
-
const tool =
|
|
9278
|
-
const runtime =
|
|
9817
|
+
const archive = join37(work, "payload.tar.zst");
|
|
9818
|
+
const tool = join37(work, "appimagetool");
|
|
9819
|
+
const runtime = join37(work, "runtime");
|
|
9279
9820
|
for (const [pin, dest] of [
|
|
9280
9821
|
[input.archive, archive],
|
|
9281
9822
|
[input.tool, tool],
|
|
9282
9823
|
[input.runtime, runtime]
|
|
9283
9824
|
])
|
|
9284
9825
|
await exactCopy(pin, dest);
|
|
9285
|
-
await elf(tool, true);
|
|
9286
|
-
await elf(runtime, true);
|
|
9826
|
+
await elf(tool, target.elfMachine, true);
|
|
9827
|
+
await elf(runtime, target.elfMachine, true);
|
|
9287
9828
|
await chmod4(tool, 448);
|
|
9288
|
-
const extracted =
|
|
9829
|
+
const extracted = join37(work, "extract");
|
|
9289
9830
|
await mkdir12(extracted);
|
|
9290
9831
|
if (host.extractVerifiedAppArchive) {
|
|
9291
9832
|
await host.extractVerifiedAppArchive(archive, extracted);
|
|
9292
9833
|
} else {
|
|
9293
9834
|
await host.inspectAppArchive(archive);
|
|
9294
|
-
|
|
9835
|
+
check3((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app inspection");
|
|
9295
9836
|
await host.run("tar", [
|
|
9296
9837
|
"--zstd",
|
|
9297
9838
|
"--extract",
|
|
@@ -9303,28 +9844,28 @@ async function buildLinuxFormats(input, host) {
|
|
|
9303
9844
|
"--no-same-permissions"
|
|
9304
9845
|
], { env });
|
|
9305
9846
|
}
|
|
9306
|
-
|
|
9847
|
+
check3((await lstat21(archive)).isFile() && await sum(archive) === input.archive.sha256, "Payload changed during app extraction");
|
|
9307
9848
|
checkAbort();
|
|
9308
|
-
const source =
|
|
9309
|
-
|
|
9849
|
+
const source = join37(extracted, policy.bundleRoot);
|
|
9850
|
+
check3((await lstat21(source)).isDirectory() && await realpath12(source) === source, "Wrong extracted app root");
|
|
9310
9851
|
await chmod4(source, 493);
|
|
9311
9852
|
await normalizeTree(source);
|
|
9312
|
-
await elf(await regular2(source, policy.launcher));
|
|
9853
|
+
await elf(await regular2(source, policy.launcher), target.elfMachine);
|
|
9313
9854
|
for (const link of policy.links ?? []) {
|
|
9314
|
-
const
|
|
9315
|
-
|
|
9855
|
+
const linkTarget = await regular2(source, link.target);
|
|
9856
|
+
check3(((await lstat21(linkTarget)).mode & 73) !== 0, "CLI link target is not executable");
|
|
9316
9857
|
}
|
|
9317
9858
|
for (const pin of policy.debSetuid) {
|
|
9318
9859
|
const file = await regular2(source, pin.path);
|
|
9319
|
-
await elf(file);
|
|
9320
|
-
|
|
9860
|
+
await elf(file, target.elfMachine);
|
|
9861
|
+
check3(await sum(file) === pin.sha256, "DEB setuid helper differs from trusted pin");
|
|
9321
9862
|
}
|
|
9322
9863
|
const icon = await regular2(source, policy.icon);
|
|
9323
|
-
|
|
9324
|
-
const stem = `${policy.artifactStem}-${tag}
|
|
9864
|
+
check3(policy.icon.endsWith(".svg"), "Expected an SVG application icon");
|
|
9865
|
+
const stem = `${policy.artifactStem}-${tag}-${target.platform}`;
|
|
9325
9866
|
const debName = `${stem}.deb`;
|
|
9326
9867
|
const imageName = `${stem}.AppImage`;
|
|
9327
|
-
const dest =
|
|
9868
|
+
const dest = join37(work, "result");
|
|
9328
9869
|
await mkdir12(dest);
|
|
9329
9870
|
const version = tag.slice(1);
|
|
9330
9871
|
const installed = `usr/lib/${policy.packageName}`;
|
|
@@ -9345,23 +9886,23 @@ async function buildLinuxFormats(input, host) {
|
|
|
9345
9886
|
`);
|
|
9346
9887
|
for (const format of ["deb", "appimage"]) {
|
|
9347
9888
|
checkAbort();
|
|
9348
|
-
const tree =
|
|
9349
|
-
await mkdir12(
|
|
9350
|
-
const bundle =
|
|
9889
|
+
const tree = join37(work, format);
|
|
9890
|
+
await mkdir12(join37(tree, "usr", "lib"), { recursive: true });
|
|
9891
|
+
const bundle = join37(tree, installed);
|
|
9351
9892
|
await cp(source, bundle, { recursive: true, verbatimSymlinks: true });
|
|
9352
9893
|
await normalizeTree(bundle);
|
|
9353
|
-
const appDirectory =
|
|
9354
|
-
|
|
9894
|
+
const appDirectory = join37(bundle, "Resources", "app");
|
|
9895
|
+
check3((await lstat21(appDirectory)).isDirectory() && await realpath12(appDirectory) === appDirectory, "Expected a real packaged app directory");
|
|
9355
9896
|
await write(bundle, "Resources/app/.adea-linux-package", `${format}
|
|
9356
9897
|
`);
|
|
9357
9898
|
await write(tree, `usr/share/applications/${desktopFile}`, desktop);
|
|
9358
|
-
const iconDest =
|
|
9899
|
+
const iconDest = join37(tree, `usr/share/icons/hicolor/scalable/apps/${policy.desktopId}.svg`);
|
|
9359
9900
|
await mkdir12(dirname15(iconDest), { recursive: true });
|
|
9360
9901
|
await cp(icon, iconDest, { force: false, errorOnExist: true });
|
|
9361
9902
|
await chmod4(iconDest, 420);
|
|
9362
|
-
await mkdir12(
|
|
9903
|
+
await mkdir12(join37(tree, "usr", "bin"), { recursive: true });
|
|
9363
9904
|
for (const link of policy.links ?? [])
|
|
9364
|
-
await symlink2(`../lib/${policy.packageName}/${link.target}`,
|
|
9905
|
+
await symlink2(`../lib/${policy.packageName}/${link.target}`, join37(tree, "usr", "bin", link.name));
|
|
9365
9906
|
if (format === "deb") {
|
|
9366
9907
|
for (const pin of policy.debSetuid)
|
|
9367
9908
|
await chmod4(await regular2(bundle, pin.path), 2541);
|
|
@@ -9372,7 +9913,7 @@ exec '/${installed}/${policy.launcher}' "$@"
|
|
|
9372
9913
|
await write(tree, "DEBIAN/control", [
|
|
9373
9914
|
`Package: ${policy.packageName}`,
|
|
9374
9915
|
`Version: ${version}`,
|
|
9375
|
-
|
|
9916
|
+
`Architecture: ${target.debian}`,
|
|
9376
9917
|
`Maintainer: ${policy.maintainer}`,
|
|
9377
9918
|
`Description: ${policy.description}`,
|
|
9378
9919
|
`Homepage: ${policy.homepage}`,
|
|
@@ -9381,7 +9922,7 @@ exec '/${installed}/${policy.launcher}' "$@"
|
|
|
9381
9922
|
].join(`
|
|
9382
9923
|
`));
|
|
9383
9924
|
await normalizeBuildTimes(tree, sourceDateEpoch);
|
|
9384
|
-
await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree,
|
|
9925
|
+
await host.run("dpkg-deb", ["--root-owner-group", "--threads-max=1", "-Zxz", "--build", tree, join37(dest, debName)], { env });
|
|
9385
9926
|
} else {
|
|
9386
9927
|
await write(tree, `usr/bin/${executable}`, `#!/bin/sh
|
|
9387
9928
|
set -eu
|
|
@@ -9389,7 +9930,7 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
|
|
|
9389
9930
|
export ${policy.formatEnvironment}=appimage
|
|
9390
9931
|
exec "$root/${installed}/${policy.launcher}" "$@"
|
|
9391
9932
|
`, 493);
|
|
9392
|
-
const rootIcon =
|
|
9933
|
+
const rootIcon = join37(tree, `${policy.desktopId}.svg`);
|
|
9393
9934
|
await cp(icon, rootIcon, { force: false, errorOnExist: true });
|
|
9394
9935
|
await chmod4(rootIcon, 420);
|
|
9395
9936
|
await write(tree, desktopFile, desktop);
|
|
@@ -9403,9 +9944,9 @@ exec "$root/${installed}/${policy.launcher}" "$@"
|
|
|
9403
9944
|
].join(`
|
|
9404
9945
|
`), 493);
|
|
9405
9946
|
await normalizeBuildTimes(tree, sourceDateEpoch);
|
|
9406
|
-
await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree,
|
|
9947
|
+
await host.run("appimagetool", ["--no-appstream", "--runtime-file", runtime, tree, join37(dest, imageName)], {
|
|
9407
9948
|
executable: tool,
|
|
9408
|
-
env: { ...env, ARCH:
|
|
9949
|
+
env: { ...env, ARCH: target.appImage, VERSION: version, APPIMAGE_EXTRACT_AND_RUN: "1" }
|
|
9409
9950
|
});
|
|
9410
9951
|
}
|
|
9411
9952
|
}
|
|
@@ -9413,34 +9954,43 @@ exec "$root/${installed}/${policy.launcher}" "$@"
|
|
|
9413
9954
|
for (const name of [debName, imageName]) {
|
|
9414
9955
|
const path = await regular2(dest, name);
|
|
9415
9956
|
const size = (await lstat21(path)).size;
|
|
9416
|
-
|
|
9957
|
+
check3(size > 0, "Empty produced artifact");
|
|
9417
9958
|
artifacts.push({ name, size, sha256: await sum(path) });
|
|
9418
9959
|
}
|
|
9419
9960
|
const receipt = {
|
|
9420
|
-
schema: "linux-package-formats/v1",
|
|
9961
|
+
schema: input.privateCandidate ? "private-linux-package-formats/v1" : "linux-package-formats/v1",
|
|
9962
|
+
...input.privateCandidate ? {
|
|
9963
|
+
releaseAuthorized: false,
|
|
9964
|
+
appName: input.privateCandidate.appName,
|
|
9965
|
+
updateArchive: {
|
|
9966
|
+
name: input.privateCandidate.archiveName,
|
|
9967
|
+
size: input.privateCandidate.archiveSize,
|
|
9968
|
+
sha256: input.archive.sha256
|
|
9969
|
+
}
|
|
9970
|
+
} : {},
|
|
9421
9971
|
tag,
|
|
9422
9972
|
sourceSha,
|
|
9423
9973
|
sourceDateEpoch,
|
|
9424
9974
|
...input.identity,
|
|
9425
|
-
platform:
|
|
9975
|
+
platform: target.platform,
|
|
9426
9976
|
updateArchiveSha256: input.archive.sha256,
|
|
9427
9977
|
artifacts
|
|
9428
9978
|
};
|
|
9429
9979
|
checkAbort();
|
|
9430
|
-
await mkdir12(output);
|
|
9980
|
+
await mkdir12(output, input.privateCandidate ? { mode: 448 } : undefined);
|
|
9431
9981
|
outputOwned = true;
|
|
9432
9982
|
try {
|
|
9433
9983
|
for (const item of artifacts)
|
|
9434
|
-
await cp(
|
|
9984
|
+
await cp(join37(dest, item.name), join37(output, basename16(item.name)), {
|
|
9435
9985
|
force: false,
|
|
9436
9986
|
errorOnExist: true
|
|
9437
9987
|
});
|
|
9438
9988
|
checkAbort();
|
|
9439
|
-
await write(output, "linux-format-build.json", JSON.stringify(receipt) + `
|
|
9989
|
+
await write(output, input.privateCandidate ? "private-linux-format-build.json" : "linux-format-build.json", JSON.stringify(receipt) + `
|
|
9440
9990
|
`);
|
|
9441
9991
|
checkAbort();
|
|
9442
9992
|
} catch (error) {
|
|
9443
|
-
await
|
|
9993
|
+
await rm12(output, { recursive: true, force: true });
|
|
9444
9994
|
outputOwned = false;
|
|
9445
9995
|
throw error;
|
|
9446
9996
|
}
|
|
@@ -9448,20 +9998,334 @@ exec "$root/${installed}/${policy.launcher}" "$@"
|
|
|
9448
9998
|
} finally {
|
|
9449
9999
|
let cleanupComplete = false;
|
|
9450
10000
|
try {
|
|
9451
|
-
await
|
|
10001
|
+
await rm12(work, { recursive: true, force: true });
|
|
9452
10002
|
await host.afterWorkCleanup?.();
|
|
9453
10003
|
cleanupComplete = true;
|
|
9454
10004
|
} finally {
|
|
9455
10005
|
if ((!cleanupComplete || host.signal?.aborted) && outputOwned) {
|
|
9456
|
-
await
|
|
10006
|
+
await rm12(output, { recursive: true, force: true });
|
|
9457
10007
|
host.signal?.throwIfAborted();
|
|
9458
10008
|
}
|
|
9459
10009
|
}
|
|
9460
10010
|
}
|
|
9461
10011
|
}
|
|
10012
|
+
// src/library/windows-standalone.ts
|
|
10013
|
+
import { execFile as execFile5 } from "child_process";
|
|
10014
|
+
import { createHash as createHash23 } from "crypto";
|
|
10015
|
+
import { constants as constants8 } from "fs";
|
|
10016
|
+
import { copyFile as copyFile2, lstat as lstat22, mkdtemp as mkdtemp13, open as open14, readFile as readFile13, readdir as readdir13, rm as rm13, writeFile as writeFile14 } from "fs/promises";
|
|
10017
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
10018
|
+
import { basename as basename17, isAbsolute as isAbsolute8, join as join38, resolve as resolve19 } from "path";
|
|
10019
|
+
import { promisify as promisify5 } from "util";
|
|
10020
|
+
|
|
10021
|
+
// src/library/windows-standalone-bootstrap.ts
|
|
10022
|
+
var windowsBootstrapSource = String.raw`
|
|
10023
|
+
#define WIN32_LEAN_AND_MEAN
|
|
10024
|
+
#include <windows.h>
|
|
10025
|
+
#include <bcrypt.h>
|
|
10026
|
+
#include <sddl.h>
|
|
10027
|
+
#include <stdint.h>
|
|
10028
|
+
#include <wchar.h>
|
|
10029
|
+
#include "app.h"
|
|
10030
|
+
|
|
10031
|
+
extern const unsigned char setup_bytes[], metadata_bytes[], archive_bytes[];
|
|
10032
|
+
|
|
10033
|
+
static BOOL join_path(wchar_t *out, const wchar_t *dir, const wchar_t *name) {
|
|
10034
|
+
int n = swprintf(out, MAX_PATH, L"%ls\\%ls", dir, name);
|
|
10035
|
+
return n > 0 && n < MAX_PATH;
|
|
10036
|
+
}
|
|
10037
|
+
|
|
10038
|
+
static BOOL create_private_dir(const wchar_t *path) {
|
|
10039
|
+
HANDLE token = NULL;
|
|
10040
|
+
TOKEN_USER *user = NULL;
|
|
10041
|
+
LPWSTR sid = NULL;
|
|
10042
|
+
PSECURITY_DESCRIPTOR descriptor = NULL;
|
|
10043
|
+
DWORD size = 0;
|
|
10044
|
+
wchar_t policy[256];
|
|
10045
|
+
BOOL result = FALSE;
|
|
10046
|
+
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) goto done;
|
|
10047
|
+
if (GetTokenInformation(token, TokenUser, NULL, 0, &size) ||
|
|
10048
|
+
GetLastError() != ERROR_INSUFFICIENT_BUFFER || !size || size > 65536) goto done;
|
|
10049
|
+
user = LocalAlloc(LPTR, size);
|
|
10050
|
+
if (!user || !GetTokenInformation(token, TokenUser, user, size, &size) ||
|
|
10051
|
+
!ConvertSidToStringSidW(user->User.Sid, &sid)) goto done;
|
|
10052
|
+
int n = swprintf(policy, 256, L"D:P(A;OICI;FA;;;%ls)(A;OICI;FA;;;SY)", sid);
|
|
10053
|
+
if (n <= 0 || n >= 256 || !ConvertStringSecurityDescriptorToSecurityDescriptorW(
|
|
10054
|
+
policy, SDDL_REVISION_1, &descriptor, NULL)) goto done;
|
|
10055
|
+
SECURITY_ATTRIBUTES security = { sizeof(security), descriptor, FALSE };
|
|
10056
|
+
result = CreateDirectoryW(path, &security);
|
|
10057
|
+
done:
|
|
10058
|
+
if (descriptor) LocalFree(descriptor);
|
|
10059
|
+
if (sid) LocalFree(sid);
|
|
10060
|
+
if (user) LocalFree(user);
|
|
10061
|
+
if (token) CloseHandle(token);
|
|
10062
|
+
return result;
|
|
10063
|
+
}
|
|
10064
|
+
|
|
10065
|
+
static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWORD size) {
|
|
10066
|
+
HANDLE file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_NEW,
|
|
10067
|
+
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
|
10068
|
+
if (file == INVALID_HANDLE_VALUE) return FALSE;
|
|
10069
|
+
BOOL ok = TRUE;
|
|
10070
|
+
while (size != 0) {
|
|
10071
|
+
DWORD sent = 0;
|
|
10072
|
+
DWORD chunk = size > 1048576 ? 1048576 : size;
|
|
10073
|
+
if (!WriteFile(file, bytes, chunk, &sent, NULL) || !sent) { ok = FALSE; break; }
|
|
10074
|
+
bytes += sent;
|
|
10075
|
+
size -= sent;
|
|
10076
|
+
}
|
|
10077
|
+
return CloseHandle(file) && ok;
|
|
10078
|
+
}
|
|
10079
|
+
|
|
10080
|
+
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
|
|
10081
|
+
(void)instance; (void)previous; (void)show;
|
|
10082
|
+
// No undocumented silent or arbitrary installer arguments are forwarded.
|
|
10083
|
+
if (command[0]) {
|
|
10084
|
+
MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
|
|
10085
|
+
return 2;
|
|
10086
|
+
}
|
|
10087
|
+
wchar_t base[MAX_PATH], work[MAX_PATH], child[MAX_PATH], hidden[MAX_PATH];
|
|
10088
|
+
wchar_t meta[MAX_PATH], archive[MAX_PATH], child_command[MAX_PATH+3];
|
|
10089
|
+
DWORD n = GetTempPathW(MAX_PATH, base), code = 2;
|
|
10090
|
+
if (!n || n >= MAX_PATH || base[n-1] != L'\\') goto fail;
|
|
10091
|
+
DWORD attributes = GetFileAttributesW(base);
|
|
10092
|
+
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
10093
|
+
|| (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) goto fail;
|
|
10094
|
+
if (n + 36 >= MAX_PATH) goto fail;
|
|
10095
|
+
uint32_t random[4];
|
|
10096
|
+
if (BCryptGenRandom(NULL, (PUCHAR)random, sizeof random, BCRYPT_USE_SYSTEM_PREFERRED_RNG) < 0) goto fail;
|
|
10097
|
+
if (swprintf(work, MAX_PATH, L"%lsaf-%08lx%08lx%08lx%08lx", base,
|
|
10098
|
+
(unsigned long)random[0], (unsigned long)random[1],
|
|
10099
|
+
(unsigned long)random[2], (unsigned long)random[3]) <= 0) goto fail;
|
|
10100
|
+
if (!join_path(child, work, APP_NAME L"-Setup.exe") ||
|
|
10101
|
+
!join_path(hidden, work, L".installer") ||
|
|
10102
|
+
!join_path(meta, hidden, APP_NAME L"-Setup.metadata.json") ||
|
|
10103
|
+
!join_path(archive, hidden, APP_NAME L"-Setup.tar.zst") ||
|
|
10104
|
+
swprintf(child_command, MAX_PATH+3, L"\"%ls\"", child) <= 0) goto fail;
|
|
10105
|
+
|
|
10106
|
+
// Use a fixed current-user/SYSTEM ACL and prevent replacement through a shared parent.
|
|
10107
|
+
if (!create_private_dir(work)) goto fail;
|
|
10108
|
+
HANDLE guard = CreateFileW(work, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
|
10109
|
+
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
|
|
10110
|
+
if (guard == INVALID_HANDLE_VALUE) goto fail;
|
|
10111
|
+
FILE_ATTRIBUTE_TAG_INFO tag = {0};
|
|
10112
|
+
if (!GetFileInformationByHandleEx(guard, FileAttributeTagInfo, &tag, sizeof tag) ||
|
|
10113
|
+
!(tag.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
|
|
10114
|
+
(tag.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
|
|
10115
|
+
CloseHandle(guard);
|
|
10116
|
+
goto fail;
|
|
10117
|
+
}
|
|
10118
|
+
if (!CreateDirectoryW(hidden, NULL) ||
|
|
10119
|
+
!write_exclusive(child, setup_bytes, SETUP_SIZE) ||
|
|
10120
|
+
!write_exclusive(meta, metadata_bytes, METADATA_SIZE) ||
|
|
10121
|
+
!write_exclusive(archive, archive_bytes, ARCHIVE_SIZE)) goto cleanup;
|
|
10122
|
+
|
|
10123
|
+
PROCESS_INFORMATION pi = {0};
|
|
10124
|
+
STARTUPINFOW si = {0};
|
|
10125
|
+
si.cb = sizeof si;
|
|
10126
|
+
if (CreateProcessW(child, child_command, NULL, NULL, FALSE, 0, NULL, work, &si, &pi)) {
|
|
10127
|
+
CloseHandle(pi.hThread);
|
|
10128
|
+
if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_OBJECT_0 ||
|
|
10129
|
+
!GetExitCodeProcess(pi.hProcess, &code)) code = 2;
|
|
10130
|
+
CloseHandle(pi.hProcess);
|
|
10131
|
+
}
|
|
10132
|
+
cleanup:
|
|
10133
|
+
DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
|
|
10134
|
+
RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
|
|
10135
|
+
if (code == 0) return 0;
|
|
10136
|
+
fail:
|
|
10137
|
+
MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
|
|
10138
|
+
return (int)code;
|
|
10139
|
+
}
|
|
10140
|
+
`;
|
|
10141
|
+
|
|
10142
|
+
// src/library/windows-standalone.ts
|
|
10143
|
+
var MAX_ARCHIVE = 1024 * 1024 * 1024;
|
|
10144
|
+
var marker = Buffer.from("ADEA-WIN-SETUP01");
|
|
10145
|
+
var zigVersion = "0.15.2";
|
|
10146
|
+
var execute2 = promisify5(execFile5);
|
|
10147
|
+
async function identity3(path, limit) {
|
|
10148
|
+
const stat = await lstat22(path);
|
|
10149
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size <= 0 || stat.size > limit)
|
|
10150
|
+
throw new Error("Invalid Windows installer input");
|
|
10151
|
+
return hashFileAt(path, stat, "Windows installer input changed");
|
|
10152
|
+
}
|
|
10153
|
+
function equal(first, second) {
|
|
10154
|
+
return first.size === second.size && first.sha256 === second.sha256;
|
|
10155
|
+
}
|
|
10156
|
+
async function copySnapshot(source, destination, limit) {
|
|
10157
|
+
const expected = await identity3(source, limit);
|
|
10158
|
+
await copyFile2(source, destination, constants8.COPYFILE_EXCL);
|
|
10159
|
+
if (!equal(expected, await identity3(destination, limit)) || !equal(expected, await identity3(source, limit)))
|
|
10160
|
+
throw new Error("Windows installer input changed during staging");
|
|
10161
|
+
return expected;
|
|
10162
|
+
}
|
|
10163
|
+
var exact = async (directory, expected) => {
|
|
10164
|
+
const names = await readdir13(directory);
|
|
10165
|
+
if (names.length !== expected.length || expected.some((name) => !names.includes(name)))
|
|
10166
|
+
throw new Error("Unexpected Windows installer staging members");
|
|
10167
|
+
};
|
|
10168
|
+
async function assertStandaloneWindowsPayload(exe, members) {
|
|
10169
|
+
if (members.length !== 3 || members.some((part) => !Number.isSafeInteger(part.size) || part.size < 1 || part.size > MAX_ARCHIVE || !/^[0-9a-f]{64}$/.test(part.sha256)))
|
|
10170
|
+
throw new Error("Invalid Windows installer member identity");
|
|
10171
|
+
const info = await identity3(exe, 2 * MAX_ARCHIVE);
|
|
10172
|
+
const file = await open14(exe, "r");
|
|
10173
|
+
async function read(position, length) {
|
|
10174
|
+
const buffer = Buffer.alloc(length);
|
|
10175
|
+
if (position < 0 || position + length > info.size || (await file.read(buffer, 0, length, position)).bytesRead !== length)
|
|
10176
|
+
throw new Error("Malformed standalone Windows executable");
|
|
10177
|
+
return buffer;
|
|
10178
|
+
}
|
|
10179
|
+
try {
|
|
10180
|
+
await assertNativeExecutable(file, info.size, "windows-x64", "standalone installer");
|
|
10181
|
+
const pe = (await read(60, 4)).readUInt32LE(0);
|
|
10182
|
+
const coff = await read(pe + 4, 20);
|
|
10183
|
+
const count = coff.readUInt16LE(2);
|
|
10184
|
+
const headers = pe + 24 + coff.readUInt16LE(16);
|
|
10185
|
+
if (count === 0 || count > 96)
|
|
10186
|
+
throw new Error("Malformed Windows PE sections");
|
|
10187
|
+
const payloads = [];
|
|
10188
|
+
for (let i = 0;i < count; i++) {
|
|
10189
|
+
const section = await read(headers + i * 40, 40);
|
|
10190
|
+
if (section.subarray(0, 8).toString() === ".afsetup")
|
|
10191
|
+
payloads.push(section);
|
|
10192
|
+
}
|
|
10193
|
+
if (payloads.length !== 1)
|
|
10194
|
+
throw new Error("Missing unique Windows setup payload section");
|
|
10195
|
+
const section = payloads[0];
|
|
10196
|
+
const length = section.readUInt32LE(8);
|
|
10197
|
+
const rawLength = section.readUInt32LE(16);
|
|
10198
|
+
const offset = section.readUInt32LE(20);
|
|
10199
|
+
const expected = marker.length + members.reduce((total, part) => total + part.size, 0);
|
|
10200
|
+
if (length !== expected || rawLength < length || rawLength - length > 4096 || offset < headers + count * 40 || offset + rawLength > info.size || !(section.readUInt32LE(36) & 1073741824) || section.readUInt32LE(36) & 2684354560)
|
|
10201
|
+
throw new Error("Invalid Windows setup payload section bounds");
|
|
10202
|
+
if (!(await read(offset, marker.length)).equals(marker))
|
|
10203
|
+
throw new Error("Invalid Windows setup payload marker");
|
|
10204
|
+
let cursor = offset + marker.length;
|
|
10205
|
+
for (const member of members) {
|
|
10206
|
+
const hash = createHash23("sha256");
|
|
10207
|
+
const end = cursor + member.size;
|
|
10208
|
+
while (cursor < end) {
|
|
10209
|
+
const bytes = await read(cursor, Math.min(end - cursor, 1048576));
|
|
10210
|
+
hash.update(bytes);
|
|
10211
|
+
cursor += bytes.length;
|
|
10212
|
+
}
|
|
10213
|
+
if (hash.digest("hex") !== member.sha256)
|
|
10214
|
+
throw new Error("Windows setup payload differs");
|
|
10215
|
+
}
|
|
10216
|
+
if ((await read(cursor, rawLength - length)).some((byte) => byte !== 0))
|
|
10217
|
+
throw new Error("Unexpected trailing Windows setup section bytes");
|
|
10218
|
+
} finally {
|
|
10219
|
+
await file.close();
|
|
10220
|
+
}
|
|
10221
|
+
if (!equal(info, await identity3(exe, 2 * MAX_ARCHIVE)))
|
|
10222
|
+
throw new Error("Windows executable changed during inspection");
|
|
10223
|
+
}
|
|
10224
|
+
async function buildStandaloneWindowsExe(options) {
|
|
10225
|
+
const { appName, appId, zig, zigSha256 } = options;
|
|
10226
|
+
if (!/^[A-Za-z0-9]+(?:[ -][A-Za-z0-9]+)*$/.test(appName) || appName.length > 64 || !/^[A-Za-z0-9]+(?:[.-][A-Za-z0-9]+)+$/.test(appId) || appId.length > 128)
|
|
10227
|
+
throw new Error("Invalid Windows installer application identity");
|
|
10228
|
+
if (!isAbsolute8(zig) || !/^[0-9a-f]{64}$/.test(zigSha256))
|
|
10229
|
+
throw new Error("Expected an absolute pinned Zig compiler path");
|
|
10230
|
+
const compilerIdentity = await identity3(zig, 512 * 1024 * 1024);
|
|
10231
|
+
if (compilerIdentity.sha256 !== zigSha256)
|
|
10232
|
+
throw new Error("Pinned Zig compiler SHA-256 mismatch");
|
|
10233
|
+
const output = resolve19(options.output);
|
|
10234
|
+
if (!basename17(output).endsWith("-Setup.exe"))
|
|
10235
|
+
throw new Error("Expected final Windows Setup EXE filename");
|
|
10236
|
+
const root = resolve19(options.hutchMembers);
|
|
10237
|
+
const hidden = join38(root, ".installer");
|
|
10238
|
+
for (const directory of [root, hidden]) {
|
|
10239
|
+
const info = await lstat22(directory);
|
|
10240
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
10241
|
+
throw new Error("Invalid Windows installer input directory");
|
|
10242
|
+
}
|
|
10243
|
+
const app = appName + "-Setup";
|
|
10244
|
+
await exact(root, [app + ".exe", ".installer"]);
|
|
10245
|
+
await exact(hidden, [app + ".metadata.json", app + ".tar.zst"]);
|
|
10246
|
+
const work = await mkdtemp13(join38(tmpdir6(), "adea-windows-setup-"));
|
|
10247
|
+
try {
|
|
10248
|
+
const setupPath = join38(work, "setup.bin");
|
|
10249
|
+
const setup = await copySnapshot(join38(root, app + ".exe"), setupPath, 256 * 1024 * 1024);
|
|
10250
|
+
const handle = await open14(setupPath, "r");
|
|
10251
|
+
try {
|
|
10252
|
+
await assertNativeExecutable(handle, setup.size, "windows-x64", "Hutch installer");
|
|
10253
|
+
} finally {
|
|
10254
|
+
await handle.close();
|
|
10255
|
+
}
|
|
10256
|
+
const metadataPath = join38(work, "metadata.bin");
|
|
10257
|
+
const metadata = await copySnapshot(join38(hidden, app + ".metadata.json"), metadataPath, 1024 * 1024);
|
|
10258
|
+
const text = await readFile13(metadataPath, "utf8");
|
|
10259
|
+
const parsed = JSON.parse(text);
|
|
10260
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
10261
|
+
throw new Error("Invalid Hutch metadata");
|
|
10262
|
+
const fields = parsed;
|
|
10263
|
+
if (Object.keys(fields).length !== 4 || fields.name !== appName || fields.identifier !== appId || fields.channel !== "stable" || typeof fields.hash !== "string" || !/^[0-9a-z]{1,13}$/.test(fields.hash))
|
|
10264
|
+
throw new Error("Hutch metadata does not name the configured stable application");
|
|
10265
|
+
if (text.trim() !== JSON.stringify({ identifier: appId, name: appName, channel: "stable", hash: fields.hash }, null, 2))
|
|
10266
|
+
throw new Error("Noncanonical Hutch installer metadata");
|
|
10267
|
+
const archive = await copySnapshot(join38(hidden, app + ".tar.zst"), join38(work, "archive.bin"), MAX_ARCHIVE);
|
|
10268
|
+
if (!equal(archive, await identity3(resolve19(options.updateArchive), MAX_ARCHIVE)))
|
|
10269
|
+
throw new Error("Hutch payload differs from update archive");
|
|
10270
|
+
const version = await execute2(zig, ["version"], { cwd: work, timeout: 15000 });
|
|
10271
|
+
if (version.stdout.trim() !== zigVersion)
|
|
10272
|
+
throw new Error("Unexpected pinned Zig compiler version");
|
|
10273
|
+
await writeFile14(join38(work, "app.h"), [
|
|
10274
|
+
`#define APP_NAME L"${appName}"`,
|
|
10275
|
+
`#define SETUP_SIZE ${setup.size}u`,
|
|
10276
|
+
`#define METADATA_SIZE ${metadata.size}u`,
|
|
10277
|
+
`#define ARCHIVE_SIZE ${archive.size}u`
|
|
10278
|
+
].join(`
|
|
10279
|
+
`) + `
|
|
10280
|
+
`, { flag: "wx" });
|
|
10281
|
+
await writeFile14(join38(work, "bootstrap.c"), windowsBootstrapSource, { flag: "wx" });
|
|
10282
|
+
await writeFile14(join38(work, "payload.s"), [
|
|
10283
|
+
'.section .afsetup,"dr"',
|
|
10284
|
+
`.ascii "${marker.toString()}"`,
|
|
10285
|
+
".globl setup_bytes",
|
|
10286
|
+
"setup_bytes:",
|
|
10287
|
+
'.incbin "setup.bin"',
|
|
10288
|
+
".globl metadata_bytes",
|
|
10289
|
+
"metadata_bytes:",
|
|
10290
|
+
'.incbin "metadata.bin"',
|
|
10291
|
+
".globl archive_bytes",
|
|
10292
|
+
"archive_bytes:",
|
|
10293
|
+
'.incbin "archive.bin"'
|
|
10294
|
+
].join(`
|
|
10295
|
+
`) + `
|
|
10296
|
+
`, { flag: "wx" });
|
|
10297
|
+
const exe = join38(work, "standalone.exe");
|
|
10298
|
+
await execute2(zig, [
|
|
10299
|
+
"cc",
|
|
10300
|
+
"-target",
|
|
10301
|
+
"x86_64-windows-gnu",
|
|
10302
|
+
"-O2",
|
|
10303
|
+
"-municode",
|
|
10304
|
+
"-mwindows",
|
|
10305
|
+
"-fno-ident",
|
|
10306
|
+
"bootstrap.c",
|
|
10307
|
+
"payload.s",
|
|
10308
|
+
"-lbcrypt",
|
|
10309
|
+
"-ladvapi32",
|
|
10310
|
+
"-luser32",
|
|
10311
|
+
"-o",
|
|
10312
|
+
exe
|
|
10313
|
+
], { cwd: work, timeout: 300000 });
|
|
10314
|
+
await assertStandaloneWindowsPayload(exe, [setup, metadata, archive]);
|
|
10315
|
+
if (!equal(await identity3(zig, 512 * 1024 * 1024), compilerIdentity))
|
|
10316
|
+
throw new Error("Pinned Zig compiler changed during build");
|
|
10317
|
+
await copyFile2(exe, output, constants8.COPYFILE_EXCL);
|
|
10318
|
+
} finally {
|
|
10319
|
+
await rm13(work, { recursive: true, force: true });
|
|
10320
|
+
}
|
|
10321
|
+
}
|
|
9462
10322
|
export {
|
|
10323
|
+
assertStandaloneWindowsPayload,
|
|
9463
10324
|
buildLinuxFormats,
|
|
10325
|
+
buildStandaloneWindowsExe,
|
|
9464
10326
|
compareLinuxReproducibility,
|
|
10327
|
+
createAptR2Store,
|
|
10328
|
+
createAptSignatureVerifier,
|
|
9465
10329
|
createDailyBatchR2Client,
|
|
9466
10330
|
createDailyBatchR2Store,
|
|
9467
10331
|
createDailyBatchS3Transport,
|
|
@@ -9470,14 +10334,17 @@ export {
|
|
|
9470
10334
|
createGitHubReleasePublisher,
|
|
9471
10335
|
createMacosDmg,
|
|
9472
10336
|
desktopDailyProfile,
|
|
10337
|
+
expandedDesktopDailyProfile,
|
|
9473
10338
|
fileIdentity2 as fileIdentity,
|
|
9474
10339
|
finalizeReleasePleaseDraft,
|
|
9475
10340
|
inspectDailyBatch,
|
|
10341
|
+
inspectDailyPreSigning,
|
|
9476
10342
|
inspectStagedStep,
|
|
9477
10343
|
planDailyReleaseMatrix,
|
|
9478
10344
|
planQualificationRun2 as planQualificationRun,
|
|
9479
10345
|
planReleaseAssets2 as planReleaseAssets,
|
|
9480
10346
|
promoteDailyBatch,
|
|
10347
|
+
publishAptRepository,
|
|
9481
10348
|
publishFrameworkPackage,
|
|
9482
10349
|
publishQualifiedRelease,
|
|
9483
10350
|
qualifyGitHubRelease,
|