@adea-ai/app-framework-release-tools 0.10.0 → 0.11.1
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/README.md +7 -1
- package/dist/circleci/circleci-daily-workspace.js +1 -1
- package/dist/cli.js +539 -125
- package/dist/index.js +163 -28
- package/dist/release-tools-source.json +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -80,20 +80,26 @@ import { Effect as Effect32 } from "effect";
|
|
|
80
80
|
// ../../src/installer/hosted-runner.ts
|
|
81
81
|
import { isAbsolute } from "path";
|
|
82
82
|
var JOB_NUMBER = /^[1-9]\d{0,19}$/;
|
|
83
|
-
function
|
|
83
|
+
function hostedRunnerRefusal(env) {
|
|
84
84
|
if (env.CI !== "true")
|
|
85
|
-
return
|
|
85
|
+
return "CI is not true";
|
|
86
86
|
if (env.GITHUB_ACTIONS === "true")
|
|
87
|
-
return env.RUNNER_ENVIRONMENT === "github-hosted";
|
|
87
|
+
return env.RUNNER_ENVIRONMENT === "github-hosted" ? undefined : "RUNNER_ENVIRONMENT is not github-hosted";
|
|
88
88
|
if (env.FRAMEWORK_DISPOSABLE_RUNNER !== "true")
|
|
89
|
-
return
|
|
89
|
+
return "FRAMEWORK_DISPOSABLE_RUNNER is not true";
|
|
90
90
|
if (env.GITLAB_CI === "true")
|
|
91
|
-
return JOB_NUMBER.test(env.CI_JOB_ID ?? "");
|
|
92
|
-
|
|
91
|
+
return JOB_NUMBER.test(env.CI_JOB_ID ?? "") ? undefined : "CI_JOB_ID is not a job number";
|
|
92
|
+
if (env.CIRCLECI !== "true")
|
|
93
|
+
return "neither GITLAB_CI nor CIRCLECI is true";
|
|
94
|
+
return JOB_NUMBER.test(env.CIRCLE_BUILD_NUM ?? "") ? undefined : "CIRCLE_BUILD_NUM is not a job number";
|
|
95
|
+
}
|
|
96
|
+
function isHostedRunner(env) {
|
|
97
|
+
return hostedRunnerRefusal(env) === undefined;
|
|
93
98
|
}
|
|
94
99
|
function assertHostedRunner(env, subject) {
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
const refusal = hostedRunnerRefusal(env);
|
|
101
|
+
if (refusal !== undefined)
|
|
102
|
+
throw new Error(`${subject} requires a disposable hosted runner (${refusal})`);
|
|
97
103
|
}
|
|
98
104
|
function runnerTemp(env) {
|
|
99
105
|
const path = env.GITHUB_ACTIONS === "true" ? env.RUNNER_TEMP : env.TMPDIR;
|
|
@@ -1080,6 +1086,10 @@ import { Cause, Data, Effect, Exit } from "effect";
|
|
|
1080
1086
|
|
|
1081
1087
|
class ReleaseFailure extends Data.TaggedError("ReleaseFailure") {
|
|
1082
1088
|
}
|
|
1089
|
+
|
|
1090
|
+
class PublicReleaseError extends Error {
|
|
1091
|
+
name = "PublicReleaseError";
|
|
1092
|
+
}
|
|
1083
1093
|
var refuse = (reason, message) => Effect.fail(new ReleaseFailure({ reason, message }));
|
|
1084
1094
|
var fail = (message) => refuse("refused", message);
|
|
1085
1095
|
var stepFailure = (error) => new ReleaseFailure({
|
|
@@ -3718,11 +3728,24 @@ async function promoteDailyBatch(store, candidate, signer, keys) {
|
|
|
3718
3728
|
throw new Error("Daily promotion could not be read back");
|
|
3719
3729
|
return selected;
|
|
3720
3730
|
}
|
|
3731
|
+
async function readDailyBatchByDigest(store, target, manifestDigest) {
|
|
3732
|
+
if (!app.test(target.appId) || !feedApp.test(target.feedApp) || !hex2.test(manifestDigest))
|
|
3733
|
+
throw new Error("Invalid Daily batch target");
|
|
3734
|
+
const bytes = await readSmall(await store.readObject(`${prefix(target.feedApp, manifestDigest)}/manifest.json`), 262144);
|
|
3735
|
+
if (hash(bytes) !== manifestDigest)
|
|
3736
|
+
throw new Error("Daily batch manifest changed");
|
|
3737
|
+
const manifest = parseManifest(parseJson(bytes));
|
|
3738
|
+
if (manifest.identity.appId !== target.appId || manifest.identity.feedApp !== target.feedApp)
|
|
3739
|
+
throw new Error("Daily batch app mismatch");
|
|
3740
|
+
return Object.freeze({ version: "", sequence: 0, manifestDigest, manifest });
|
|
3741
|
+
}
|
|
3721
3742
|
async function rollbackDailyBatch(store, current, target, signer, keys) {
|
|
3722
3743
|
const appId = current.manifest.identity.appId;
|
|
3723
3744
|
const slug = current.manifest.identity.feedApp;
|
|
3724
3745
|
if (target.manifest.identity.appId !== appId || target.manifest.identity.feedApp !== slug || !hex2.test(target.manifestDigest))
|
|
3725
3746
|
throw new Error("Invalid rollback target");
|
|
3747
|
+
if (target.manifestDigest === current.manifestDigest)
|
|
3748
|
+
throw new Error("Rollback target is the current Daily batch");
|
|
3726
3749
|
const selected = await readDailyBatch(store, { appId, feedApp: slug }, keys);
|
|
3727
3750
|
if (!selected || selected.version !== current.version)
|
|
3728
3751
|
throw new Error("Daily pointer changed during rollback");
|
|
@@ -5936,6 +5959,72 @@ var stageLocalReleaseEffect = (options) => Effect21.gen(function* () {
|
|
|
5936
5959
|
};
|
|
5937
5960
|
return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
|
|
5938
5961
|
});
|
|
5962
|
+
var linuxPackageFormats = [
|
|
5963
|
+
{
|
|
5964
|
+
extension: ".deb",
|
|
5965
|
+
magic: (head) => head.subarray(0, 8).toString("latin1") === `!<arch>
|
|
5966
|
+
`
|
|
5967
|
+
},
|
|
5968
|
+
{
|
|
5969
|
+
extension: ".AppImage",
|
|
5970
|
+
magic: (head) => head.subarray(0, 4).equals(Buffer.from([127, 69, 76, 70])) && head.subarray(8, 11).equals(Buffer.from([65, 73, 2]))
|
|
5971
|
+
}
|
|
5972
|
+
];
|
|
5973
|
+
var stageLocalPackagesEffect = (options) => Effect21.gen(function* () {
|
|
5974
|
+
const fs = yield* ReleaseFs;
|
|
5975
|
+
const { tag, sourceSha } = options;
|
|
5976
|
+
const local = localConfig(options.config);
|
|
5977
|
+
const feed = local.feed;
|
|
5978
|
+
const requirements = local.requirements(tag);
|
|
5979
|
+
const allowed = new Map;
|
|
5980
|
+
for (const platform of ["linux-x64", "linux-arm64"])
|
|
5981
|
+
for (const archive of requirements.platforms[platform] ?? [])
|
|
5982
|
+
if (archive.endsWith(".tar.zst"))
|
|
5983
|
+
for (const { extension } of linuxPackageFormats)
|
|
5984
|
+
allowed.set(archive.slice(0, -".tar.zst".length) + extension, archive);
|
|
5985
|
+
const directory = resolve9(options.directory);
|
|
5986
|
+
const entries = yield* step(() => fs.readdir(directory, { withFileTypes: true }));
|
|
5987
|
+
if (!entries.length || entries.some((entry) => !entry.isFile() || !allowed.has(entry.name)))
|
|
5988
|
+
return yield* fail("Staged directory holds files that are not this tag's Linux packages");
|
|
5989
|
+
const names = entries.map((entry) => entry.name).toSorted();
|
|
5990
|
+
const staged = yield* Effect21.forEach(names, (name) => fileIdentityEffect(join15(directory, name), name), { concurrency: "unbounded" });
|
|
5991
|
+
for (const name of names) {
|
|
5992
|
+
const format = linuxPackageFormats.find(({ extension }) => name.endsWith(extension));
|
|
5993
|
+
const head = Buffer.alloc(16);
|
|
5994
|
+
const file = yield* step(() => fs.open(join15(directory, name), "r"));
|
|
5995
|
+
yield* step(() => file.read(head, 0, 16, 0)).pipe(Effect21.ensuring(Effect21.promise(() => file.close().catch(() => {
|
|
5996
|
+
return;
|
|
5997
|
+
}))));
|
|
5998
|
+
if (!format.magic(head))
|
|
5999
|
+
return yield* fail(`Not a ${format.extension} package: ${name}`);
|
|
6000
|
+
}
|
|
6001
|
+
const [ledger, remote] = yield* Effect21.all([readFeedLedgerEffect(feed), readFeedReleaseEffect(feed, tag)], { concurrency: "unbounded" });
|
|
6002
|
+
const entry = ledger.releases.find((item) => item.tag === tag);
|
|
6003
|
+
if (!entry || !remote || entry.kind !== remote.channel || Date.parse(entry.publishedAt) !== Date.parse(remote.publishedAt))
|
|
6004
|
+
return yield* fail("The feed has not published this tag; publish its release first");
|
|
6005
|
+
if (entry.sourceSha !== sourceSha)
|
|
6006
|
+
return yield* fail("The feed publishes this tag from another source commit");
|
|
6007
|
+
const merged = [...remote.assets];
|
|
6008
|
+
const uploads = [];
|
|
6009
|
+
for (const artifact of staged) {
|
|
6010
|
+
if (!merged.some((asset) => asset.name === allowed.get(artifact.name)))
|
|
6011
|
+
return yield* fail(`The feed has no ${allowed.get(artifact.name)} for ${artifact.name}`);
|
|
6012
|
+
const existing = merged.find((asset) => asset.name === artifact.name);
|
|
6013
|
+
if (existing) {
|
|
6014
|
+
if (existing.size !== artifact.size || "sha256:" + existing.sha256 !== artifact.digest)
|
|
6015
|
+
return yield* fail(`Immutable asset conflict: ${artifact.name}`);
|
|
6016
|
+
continue;
|
|
6017
|
+
}
|
|
6018
|
+
merged.push({ name: artifact.name, size: artifact.size, sha256: artifact.digest.slice(7) });
|
|
6019
|
+
uploads.push({
|
|
6020
|
+
key: feedAssetKey(feed, tag, artifact.name),
|
|
6021
|
+
path: join15(directory, artifact.name),
|
|
6022
|
+
artifact
|
|
6023
|
+
});
|
|
6024
|
+
}
|
|
6025
|
+
const release = { ...remote, assets: merged };
|
|
6026
|
+
return yield* writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, ledger, release));
|
|
6027
|
+
});
|
|
5939
6028
|
function stablePlatforms(config) {
|
|
5940
6029
|
const value = isRecord(config) ? config.stablePlatforms : undefined;
|
|
5941
6030
|
if (value === undefined)
|
|
@@ -10367,6 +10456,7 @@ import { basename as basename17, isAbsolute as isAbsolute8, join as join39, reso
|
|
|
10367
10456
|
import { promisify as promisify5 } from "util";
|
|
10368
10457
|
|
|
10369
10458
|
// src/library/windows-standalone-bootstrap.ts
|
|
10459
|
+
var WINDOWS_PACKAGE_MANAGER_SWITCH = "--package-manager=winget";
|
|
10370
10460
|
var windowsBootstrapSource = String.raw`
|
|
10371
10461
|
#define WIN32_LEAN_AND_MEAN
|
|
10372
10462
|
#include <windows.h>
|
|
@@ -10425,10 +10515,28 @@ static BOOL write_exclusive(const wchar_t *path, const unsigned char *bytes, DWO
|
|
|
10425
10515
|
return CloseHandle(file) && ok;
|
|
10426
10516
|
}
|
|
10427
10517
|
|
|
10518
|
+
// Marks the installed app root as package-manager owned. The root must already exist as a real
|
|
10519
|
+
// directory (the inner Setup created it); the marker is replaced, never followed through a link.
|
|
10520
|
+
static BOOL write_package_manager_marker(void) {
|
|
10521
|
+
wchar_t local[MAX_PATH], root[MAX_PATH], marker[MAX_PATH];
|
|
10522
|
+
DWORD n = GetEnvironmentVariableW(L"LOCALAPPDATA", local, MAX_PATH);
|
|
10523
|
+
if (!n || n >= MAX_PATH) return FALSE;
|
|
10524
|
+
int m = swprintf(root, MAX_PATH, L"%ls\\%ls\\stable\\app", local, APP_ID);
|
|
10525
|
+
if (m <= 0 || m >= MAX_PATH || !join_path(marker, root, L".package-manager")) return FALSE;
|
|
10526
|
+
DWORD attributes = GetFileAttributesW(root);
|
|
10527
|
+
if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
10528
|
+
|| (attributes & FILE_ATTRIBUTE_REPARSE_POINT)) return FALSE;
|
|
10529
|
+
DeleteFileW(marker);
|
|
10530
|
+
static const unsigned char owner[] = "winget\n";
|
|
10531
|
+
return write_exclusive(marker, owner, sizeof owner - 1);
|
|
10532
|
+
}
|
|
10533
|
+
|
|
10428
10534
|
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int show) {
|
|
10429
10535
|
(void)instance; (void)previous; (void)show;
|
|
10430
|
-
// No undocumented silent or arbitrary installer arguments are forwarded.
|
|
10431
|
-
|
|
10536
|
+
// No undocumented silent or arbitrary installer arguments are forwarded. The only option is
|
|
10537
|
+
// the exact package-manager switch, which is not forwarded either: it marks the install.
|
|
10538
|
+
BOOL package_manager = wcscmp(command, L"${WINDOWS_PACKAGE_MANAGER_SWITCH}") == 0;
|
|
10539
|
+
if (command[0] && !package_manager) {
|
|
10432
10540
|
MessageBoxW(NULL, L"This installer accepts no command-line options.", APP_NAME, MB_OK | MB_ICONERROR);
|
|
10433
10541
|
return 2;
|
|
10434
10542
|
}
|
|
@@ -10480,6 +10588,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous, LPWSTR command, int
|
|
|
10480
10588
|
cleanup:
|
|
10481
10589
|
DeleteFileW(archive); DeleteFileW(meta); DeleteFileW(child);
|
|
10482
10590
|
RemoveDirectoryW(hidden); CloseHandle(guard); RemoveDirectoryW(work);
|
|
10591
|
+
if (code == 0 && package_manager && !write_package_manager_marker()) code = 2;
|
|
10483
10592
|
if (code == 0) return 0;
|
|
10484
10593
|
fail:
|
|
10485
10594
|
MessageBoxW(NULL, L"Installation did not complete.", APP_NAME, MB_OK | MB_ICONERROR);
|
|
@@ -10620,6 +10729,7 @@ async function buildStandaloneWindowsExe(options) {
|
|
|
10620
10729
|
throw new Error("Unexpected pinned Zig compiler version");
|
|
10621
10730
|
await writeFile14(join39(work, "app.h"), [
|
|
10622
10731
|
`#define APP_NAME L"${appName}"`,
|
|
10732
|
+
`#define APP_ID L"${appId}"`,
|
|
10623
10733
|
`#define SETUP_SIZE ${setup.size}u`,
|
|
10624
10734
|
`#define METADATA_SIZE ${metadata.size}u`,
|
|
10625
10735
|
`#define ARCHIVE_SIZE ${archive.size}u`
|
|
@@ -10667,6 +10777,26 @@ async function buildStandaloneWindowsExe(options) {
|
|
|
10667
10777
|
await rm13(work, { recursive: true, force: true });
|
|
10668
10778
|
}
|
|
10669
10779
|
}
|
|
10780
|
+
// src/library/homebrew-cask.ts
|
|
10781
|
+
var ruby = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
|
|
10782
|
+
var DEFAULT_HOMEBREW_MINIMUM_MACOS = "sonoma";
|
|
10783
|
+
var MACOS_CODENAMES = ["ventura", "sonoma", "sequoia", "tahoe"];
|
|
10784
|
+
function homebrewMinimumMacos(value) {
|
|
10785
|
+
if (value === undefined)
|
|
10786
|
+
return DEFAULT_HOMEBREW_MINIMUM_MACOS;
|
|
10787
|
+
if (typeof value !== "string" || !MACOS_CODENAMES.includes(value))
|
|
10788
|
+
throw new Error(`Invalid Homebrew minimum macOS (one of ${MACOS_CODENAMES.join(", ")})`);
|
|
10789
|
+
return value;
|
|
10790
|
+
}
|
|
10791
|
+
function homebrewRequirements(options) {
|
|
10792
|
+
return [
|
|
10793
|
+
...options.conflictsWith ? [` conflicts_with cask: ${ruby(options.conflictsWith)}`] : [],
|
|
10794
|
+
...options.arm64Only ? [" depends_on arch: :arm64"] : [],
|
|
10795
|
+
` depends_on macos: ">= :${options.minimumMacos}"`
|
|
10796
|
+
].join(`
|
|
10797
|
+
`);
|
|
10798
|
+
}
|
|
10799
|
+
|
|
10670
10800
|
// src/library/package-channels.ts
|
|
10671
10801
|
var packageChannelNames = [
|
|
10672
10802
|
"homebrew",
|
|
@@ -10710,7 +10840,7 @@ var packagePattern = /^[a-z0-9][a-z0-9+.-]{0,62}$/;
|
|
|
10710
10840
|
var reverseDns = /^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*){2,}$/;
|
|
10711
10841
|
var relativePath2 = /^[A-Za-z0-9][A-Za-z0-9._-]*(\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;
|
|
10712
10842
|
var quoted = JSON.stringify;
|
|
10713
|
-
var
|
|
10843
|
+
var ruby2 = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
|
|
10714
10844
|
var shell = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
10715
10845
|
function parseAsset(value) {
|
|
10716
10846
|
const row = object(value, "manifest asset");
|
|
@@ -10783,7 +10913,8 @@ function stageInput(context, asset) {
|
|
|
10783
10913
|
};
|
|
10784
10914
|
}
|
|
10785
10915
|
function homebrew(context, row) {
|
|
10786
|
-
keys2(row, "homebrew", ["tap", "token", "bundle", "artifact"]);
|
|
10916
|
+
keys2(row, "homebrew", ["tap", "token", "bundle", "artifact"], ["minimumMacos"]);
|
|
10917
|
+
const minimumMacos = homebrewMinimumMacos(row.minimumMacos);
|
|
10787
10918
|
const tap = text3(row.tap, "Homebrew tap", /^[A-Za-z0-9][A-Za-z0-9-]*\/homebrew-[a-z0-9][a-z0-9-]*$/);
|
|
10788
10919
|
const stableToken = text3(row.token, "cask token", /^[a-z0-9]+(?:-[a-z0-9]+)*$/);
|
|
10789
10920
|
const bundle = text3(row.bundle, "app bundle", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.app$/);
|
|
@@ -10800,19 +10931,22 @@ function homebrew(context, row) {
|
|
|
10800
10931
|
files: [
|
|
10801
10932
|
{
|
|
10802
10933
|
path: `Casks/${token}.rb`,
|
|
10803
|
-
contents: `cask ${
|
|
10804
|
-
version ${
|
|
10805
|
-
sha256 ${
|
|
10934
|
+
contents: `cask ${ruby2(token)} do
|
|
10935
|
+
version ${ruby2(context.version)}
|
|
10936
|
+
sha256 ${ruby2(asset.sha256)}
|
|
10806
10937
|
|
|
10807
|
-
url ${
|
|
10808
|
-
name ${
|
|
10809
|
-
desc ${
|
|
10810
|
-
homepage ${
|
|
10938
|
+
url ${ruby2(asset.url)}
|
|
10939
|
+
name ${ruby2(stable ? name : `${name} Daily`)}
|
|
10940
|
+
desc ${ruby2(description)}
|
|
10941
|
+
homepage ${ruby2(homepage)}
|
|
10811
10942
|
|
|
10812
|
-
|
|
10813
|
-
|
|
10943
|
+
${homebrewRequirements({
|
|
10944
|
+
conflictsWith: stable ? `${stableToken}@daily` : stableToken,
|
|
10945
|
+
arm64Only: true,
|
|
10946
|
+
minimumMacos
|
|
10947
|
+
})}
|
|
10814
10948
|
|
|
10815
|
-
app ${
|
|
10949
|
+
app ${ruby2(bundle)}
|
|
10816
10950
|
end
|
|
10817
10951
|
`
|
|
10818
10952
|
}
|
|
@@ -10821,16 +10955,17 @@ end
|
|
|
10821
10955
|
};
|
|
10822
10956
|
}
|
|
10823
10957
|
function winget(context, row) {
|
|
10824
|
-
keys2(row, "winget", ["identifier", "publisher", "artifact", "
|
|
10958
|
+
keys2(row, "winget", ["identifier", "publisher", "artifact"], ["nestedInstaller", "silent", "silentWithProgress"]);
|
|
10825
10959
|
const stableId = text3(row.identifier, "WinGet package identifier", /^[A-Za-z0-9][A-Za-z0-9-]*(\.[A-Za-z0-9][A-Za-z0-9-]*)+$/);
|
|
10826
10960
|
const publisher = text3(row.publisher, "WinGet publisher");
|
|
10827
10961
|
const asset = exact2(context, row.artifact, "WinGet", [".exe", ".zip"]);
|
|
10828
10962
|
const direct = asset.name.endsWith(".exe");
|
|
10829
10963
|
ensure(direct === (row.nestedInstaller === undefined), direct ? "A direct .exe installer takes no nestedInstaller" : "A .zip installer needs nestedInstaller");
|
|
10830
10964
|
const nested = direct ? undefined : text3(row.nestedInstaller, "nested executable", /^[A-Za-z0-9][A-Za-z0-9 ._-]*\.exe$/i);
|
|
10965
|
+
ensure(!direct || row.silent === undefined && row.silentWithProgress === undefined, "A direct .exe installer takes the package-manager switch, not silent flags");
|
|
10831
10966
|
const flags = /^[-/][a-zA-Z0-9_-]+(?: [-/][a-zA-Z0-9_-]+)*$/;
|
|
10832
|
-
const silent = text3(row.silent, "silent flags", flags);
|
|
10833
|
-
const progress = text3(row.silentWithProgress, "silent progress flags", flags);
|
|
10967
|
+
const silent = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silent, "silent flags", flags);
|
|
10968
|
+
const progress = direct ? WINDOWS_PACKAGE_MANAGER_SWITCH : text3(row.silentWithProgress, "silent progress flags", flags);
|
|
10834
10969
|
const stable = context.manifest.channel === "stable";
|
|
10835
10970
|
const id = stable ? stableId : `${stableId}.Daily`;
|
|
10836
10971
|
const { name, description, homepage, license } = context.common;
|
|
@@ -11555,6 +11690,46 @@ var stageDailyBatchEffect = (options) => Effect27.gen(function* () {
|
|
|
11555
11690
|
}));
|
|
11556
11691
|
return { directory, ...manifest };
|
|
11557
11692
|
}).pipe(Effect27.scoped);
|
|
11693
|
+
var stagedDailyBatchManifestEffect = (options) => Effect27.gen(function* () {
|
|
11694
|
+
const fs = yield* ReleaseFs;
|
|
11695
|
+
const directory = resolve21(options.directory);
|
|
11696
|
+
const recordPath = join41(directory, "candidate.json");
|
|
11697
|
+
const info = yield* step(() => fs.lstat(recordPath));
|
|
11698
|
+
if (!info.isFile() || info.size < 1 || info.size > 262144)
|
|
11699
|
+
return yield* fail("Invalid Daily candidate record");
|
|
11700
|
+
const record = yield* attempt(async () => JSON.parse((await fs.readFile(recordPath)).toString("utf8")));
|
|
11701
|
+
if (!isRecord(record) || record.schema !== "framework/daily-staged-batch/v1" || !isRecord(record.identity))
|
|
11702
|
+
return yield* fail("Invalid Daily candidate record");
|
|
11703
|
+
const { tag, sourceSha, workflowSha, runId, runAttempt } = record.identity;
|
|
11704
|
+
if (typeof tag !== "string" || typeof sourceSha !== "string" || typeof workflowSha !== "string" || typeof runId !== "string" || typeof runAttempt !== "number")
|
|
11705
|
+
return yield* fail("Invalid Daily candidate identity");
|
|
11706
|
+
const identity = { tag, sourceSha, workflowSha, runId, runAttempt };
|
|
11707
|
+
const artifacts = join41(directory, "artifacts");
|
|
11708
|
+
const receipts = join41(directory, "receipts");
|
|
11709
|
+
const verified = yield* verifyDailyReleaseMatrixEffect({
|
|
11710
|
+
config: options.config,
|
|
11711
|
+
identity,
|
|
11712
|
+
artifacts,
|
|
11713
|
+
receipts
|
|
11714
|
+
});
|
|
11715
|
+
if (JSON.stringify({ schema: record.schema, ...verified }) !== JSON.stringify({
|
|
11716
|
+
schema: record.schema,
|
|
11717
|
+
profile: record.profile,
|
|
11718
|
+
appId: record.appId,
|
|
11719
|
+
identity: record.identity,
|
|
11720
|
+
assets: record.assets
|
|
11721
|
+
}))
|
|
11722
|
+
return yield* fail("Daily candidate differs from its verified inputs");
|
|
11723
|
+
const feed = yield* attempt(() => parseReleaseConfig(options.config).feed);
|
|
11724
|
+
const plan = yield* attempt(() => planDailyReleaseMatrix(options.config, tag));
|
|
11725
|
+
const receiptFiles = yield* Effect27.forEach(plan.checks, (check) => fileIdentityEffect(join41(receipts, `${check.name}.json`), `${check.name}.json`));
|
|
11726
|
+
return {
|
|
11727
|
+
schema: "framework/daily-batch/v1",
|
|
11728
|
+
identity: { appId: verified.appId, feedApp: feed.app, ...identity },
|
|
11729
|
+
artifacts: verified.assets.map(({ name, size, digest }) => ({ name, size, digest })),
|
|
11730
|
+
receipts: receiptFiles.map(({ name, size, digest }) => ({ name, size, digest }))
|
|
11731
|
+
};
|
|
11732
|
+
});
|
|
11558
11733
|
|
|
11559
11734
|
// src/cli-runner.ts
|
|
11560
11735
|
import { Cause as Cause3, Effect as Effect28, Exit as Exit5 } from "effect";
|
|
@@ -11564,6 +11739,16 @@ function failureError(cause) {
|
|
|
11564
11739
|
return new Error(error.message);
|
|
11565
11740
|
return error instanceof Error ? error : new Error(String(error));
|
|
11566
11741
|
}
|
|
11742
|
+
function publicFailureCause(cause) {
|
|
11743
|
+
const error = Cause3.squash(cause);
|
|
11744
|
+
if (!(error instanceof ReleaseFailure))
|
|
11745
|
+
return;
|
|
11746
|
+
if (error.reason === "refused")
|
|
11747
|
+
return error.message;
|
|
11748
|
+
if (error.reason !== "step")
|
|
11749
|
+
return;
|
|
11750
|
+
return error.original instanceof PublicReleaseError ? error.original.message : undefined;
|
|
11751
|
+
}
|
|
11567
11752
|
var runCommand = (failure, program, options = {}) => Effect28.gen(function* () {
|
|
11568
11753
|
const { env } = yield* ReleaseConfig;
|
|
11569
11754
|
const output = yield* ReleaseOutput;
|
|
@@ -11572,8 +11757,13 @@ var runCommand = (failure, program, options = {}) => Effect28.gen(function* () {
|
|
|
11572
11757
|
return 0;
|
|
11573
11758
|
if (Cause3.hasInterruptsOnly(exit.cause))
|
|
11574
11759
|
return 130;
|
|
11575
|
-
|
|
11576
|
-
|
|
11760
|
+
if (typeof failure !== "string") {
|
|
11761
|
+
output.stderr(`${failure(failureError(exit.cause))}
|
|
11762
|
+
`);
|
|
11763
|
+
return 1;
|
|
11764
|
+
}
|
|
11765
|
+
const cause = publicFailureCause(exit.cause);
|
|
11766
|
+
output.stderr(`${cause && cause !== failure ? `${failure}: ${cause}` : failure}
|
|
11577
11767
|
`);
|
|
11578
11768
|
return 1;
|
|
11579
11769
|
});
|
|
@@ -11631,7 +11821,7 @@ var sha = (value) => requireText(value, "SHA-256", /^[a-f0-9]{64}$/);
|
|
|
11631
11821
|
var source = (value) => requireText(value, "source SHA", /^[a-f0-9]{40}$/);
|
|
11632
11822
|
var file = (value) => requireText(value, "asset name", /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/);
|
|
11633
11823
|
var quoted2 = JSON.stringify;
|
|
11634
|
-
var
|
|
11824
|
+
var ruby3 = (value) => JSON.stringify(value).replace(/#(?=[{@$])/g, "\\#");
|
|
11635
11825
|
function asset(value) {
|
|
11636
11826
|
const row = object2(value);
|
|
11637
11827
|
const size = row.size;
|
|
@@ -11709,24 +11899,26 @@ function prepareStableCatalog(input) {
|
|
|
11709
11899
|
return [
|
|
11710
11900
|
{
|
|
11711
11901
|
path: `Casks/${token}.rb`,
|
|
11712
|
-
contents: `cask ${
|
|
11713
|
-
version ${
|
|
11902
|
+
contents: `cask ${ruby3(token)} do
|
|
11903
|
+
version ${ruby3(arm.tag.slice(1))}
|
|
11714
11904
|
|
|
11715
11905
|
on_arm do
|
|
11716
|
-
sha256 ${
|
|
11717
|
-
url ${
|
|
11906
|
+
sha256 ${ruby3(arm.staged.sha256)}
|
|
11907
|
+
url ${ruby3(arm.url)}
|
|
11718
11908
|
end
|
|
11719
11909
|
|
|
11720
11910
|
on_intel do
|
|
11721
|
-
sha256 ${
|
|
11722
|
-
url ${
|
|
11911
|
+
sha256 ${ruby3(intel.staged.sha256)}
|
|
11912
|
+
url ${ruby3(intel.url)}
|
|
11723
11913
|
end
|
|
11724
11914
|
|
|
11725
|
-
name ${
|
|
11726
|
-
desc ${
|
|
11727
|
-
homepage ${
|
|
11915
|
+
name ${ruby3(name)}
|
|
11916
|
+
desc ${ruby3(desc)}
|
|
11917
|
+
homepage ${ruby3(homepage)}
|
|
11728
11918
|
|
|
11729
|
-
|
|
11919
|
+
${homebrewRequirements({ arm64Only: false, minimumMacos: homebrewMinimumMacos(channelConfig.minimumMacos) })}
|
|
11920
|
+
|
|
11921
|
+
app ${ruby3(bundle)}
|
|
11730
11922
|
end
|
|
11731
11923
|
`
|
|
11732
11924
|
}
|
|
@@ -11768,18 +11960,18 @@ end
|
|
|
11768
11960
|
return [
|
|
11769
11961
|
{
|
|
11770
11962
|
path: `Casks/${token}.rb`,
|
|
11771
|
-
contents: `cask ${
|
|
11772
|
-
version ${
|
|
11773
|
-
sha256 ${
|
|
11963
|
+
contents: `cask ${ruby3(token)} do
|
|
11964
|
+
version ${ruby3(version)}
|
|
11965
|
+
sha256 ${ruby3(staged.sha256)}
|
|
11774
11966
|
|
|
11775
|
-
url ${
|
|
11776
|
-
name ${
|
|
11777
|
-
desc ${
|
|
11778
|
-
homepage ${
|
|
11967
|
+
url ${ruby3(url)}
|
|
11968
|
+
name ${ruby3(name)}
|
|
11969
|
+
desc ${ruby3(desc)}
|
|
11970
|
+
homepage ${ruby3(homepage)}
|
|
11779
11971
|
|
|
11780
|
-
|
|
11972
|
+
${homebrewRequirements({ arm64Only: true, minimumMacos: homebrewMinimumMacos(channelConfig.minimumMacos) })}
|
|
11781
11973
|
|
|
11782
|
-
app ${
|
|
11974
|
+
app ${ruby3(bundle)}
|
|
11783
11975
|
end
|
|
11784
11976
|
`
|
|
11785
11977
|
}
|
|
@@ -11989,7 +12181,7 @@ async function verifiedSourceCommit(git, sha) {
|
|
|
11989
12181
|
async function verifiedSourceFile(git, rootTree, path) {
|
|
11990
12182
|
const parts = path.split("/");
|
|
11991
12183
|
if (path.length > 512 || !parts.length || parts.some((part) => !pathPart.test(part)))
|
|
11992
|
-
throw new
|
|
12184
|
+
throw new PublicReleaseError("Invalid source metadata path");
|
|
11993
12185
|
let tree = rootTree;
|
|
11994
12186
|
for (let index = 0;index < parts.length; index++) {
|
|
11995
12187
|
const bytes = await object3(git, "tree", tree, 8 * 1024 * 1024);
|
|
@@ -12010,17 +12202,17 @@ async function verifiedSourceFile(git, rootTree, path) {
|
|
|
12010
12202
|
offset = zero + 21;
|
|
12011
12203
|
}
|
|
12012
12204
|
if (!found)
|
|
12013
|
-
throw new
|
|
12205
|
+
throw new PublicReleaseError(`Missing source metadata: ${path}`);
|
|
12014
12206
|
if (index === parts.length - 1) {
|
|
12015
12207
|
if (found.mode !== "100644" && found.mode !== "100755")
|
|
12016
|
-
throw new
|
|
12208
|
+
throw new PublicReleaseError(`Source metadata must be a regular blob: ${path}`);
|
|
12017
12209
|
return object3(git, "blob", found.oid, 262144);
|
|
12018
12210
|
}
|
|
12019
12211
|
if (found.mode !== "40000" && found.mode !== "040000")
|
|
12020
|
-
throw new
|
|
12212
|
+
throw new PublicReleaseError(`Invalid source metadata directory: ${path}`);
|
|
12021
12213
|
tree = found.oid;
|
|
12022
12214
|
}
|
|
12023
|
-
throw new
|
|
12215
|
+
throw new PublicReleaseError(`Missing source metadata: ${path}`);
|
|
12024
12216
|
}
|
|
12025
12217
|
|
|
12026
12218
|
// src/commands/build-linux-formats.ts
|
|
@@ -12229,6 +12421,206 @@ var buildLinuxFormatsCommand = (args) => runCommand("Unable to build Linux forma
|
|
|
12229
12421
|
`);
|
|
12230
12422
|
}));
|
|
12231
12423
|
|
|
12424
|
+
// src/commands/daily-batch.ts
|
|
12425
|
+
import { lstat as lstat26, readFile as readFile17 } from "fs/promises";
|
|
12426
|
+
import { resolve as resolve24 } from "path";
|
|
12427
|
+
|
|
12428
|
+
// src/library/daily-batch-directory.ts
|
|
12429
|
+
import { createHash as createHash29, createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey4, randomBytes as randomBytes5, sign as sign2 } from "crypto";
|
|
12430
|
+
import { createReadStream as createReadStream4 } from "fs";
|
|
12431
|
+
import { link as link2, lstat as lstat25, mkdir as mkdir15, readFile as readFile16, rename as rename4, rm as rm17, rmdir as rmdir2, writeFile as writeFile17 } from "fs/promises";
|
|
12432
|
+
import { dirname as dirname19, isAbsolute as isAbsolute11, join as join45, resolve as resolve23 } from "path";
|
|
12433
|
+
var segment2 = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,199}$/;
|
|
12434
|
+
var hash3 = (bytes) => createHash29("sha256").update(bytes).digest("hex");
|
|
12435
|
+
async function regular3(file) {
|
|
12436
|
+
const stat = await lstat25(file);
|
|
12437
|
+
if (!stat.isFile())
|
|
12438
|
+
throw new Error("Daily batch store object is not a regular file");
|
|
12439
|
+
return stat;
|
|
12440
|
+
}
|
|
12441
|
+
var missing = (error) => error?.code === "ENOENT";
|
|
12442
|
+
function createDailyBatchDirectoryStore(root) {
|
|
12443
|
+
if (!isAbsolute11(root))
|
|
12444
|
+
throw new Error("Daily batch store directory must be absolute");
|
|
12445
|
+
const base = resolve23(root);
|
|
12446
|
+
const path = (key) => {
|
|
12447
|
+
const parts = key.split("/");
|
|
12448
|
+
if (key.length > 1024 || parts.length < 2 || !parts.every((part) => segment2.test(part)))
|
|
12449
|
+
throw new Error("Invalid Daily batch store key");
|
|
12450
|
+
return join45(base, ...parts);
|
|
12451
|
+
};
|
|
12452
|
+
return {
|
|
12453
|
+
async putImmutable(key, bytes, size, sha256) {
|
|
12454
|
+
const target = path(key);
|
|
12455
|
+
if (!Number.isSafeInteger(size) || size < 0 || !/^[a-f0-9]{64}$/.test(sha256))
|
|
12456
|
+
throw new Error("Invalid Daily batch object identity");
|
|
12457
|
+
const chunks = [];
|
|
12458
|
+
let length = 0;
|
|
12459
|
+
for await (const chunk of bytes) {
|
|
12460
|
+
length += chunk.byteLength;
|
|
12461
|
+
if (length > size)
|
|
12462
|
+
throw new Error(`Daily batch object too large: ${key}`);
|
|
12463
|
+
chunks.push(chunk);
|
|
12464
|
+
}
|
|
12465
|
+
const body = Buffer.concat(chunks);
|
|
12466
|
+
if (length !== size || hash3(body) !== sha256)
|
|
12467
|
+
throw new Error(`Daily batch object differs from its identity: ${key}`);
|
|
12468
|
+
await mkdir15(dirname19(target), { recursive: true, mode: 448 });
|
|
12469
|
+
const temporary = `${target}.${randomBytes5(8).toString("hex")}.partial`;
|
|
12470
|
+
await writeFile17(temporary, body, { flag: "wx", mode: 384 });
|
|
12471
|
+
let exists = false;
|
|
12472
|
+
try {
|
|
12473
|
+
await link2(temporary, target);
|
|
12474
|
+
} catch (error) {
|
|
12475
|
+
if (error.code !== "EEXIST")
|
|
12476
|
+
throw error;
|
|
12477
|
+
exists = true;
|
|
12478
|
+
} finally {
|
|
12479
|
+
await rm17(temporary, { force: true });
|
|
12480
|
+
}
|
|
12481
|
+
if (exists) {
|
|
12482
|
+
await regular3(target);
|
|
12483
|
+
if (hash3(await readFile16(target)) !== sha256)
|
|
12484
|
+
throw new Error(`Daily batch object already exists with different bytes: ${key}`);
|
|
12485
|
+
}
|
|
12486
|
+
},
|
|
12487
|
+
async readObject(key) {
|
|
12488
|
+
const target = path(key);
|
|
12489
|
+
await regular3(target);
|
|
12490
|
+
return createReadStream4(target);
|
|
12491
|
+
},
|
|
12492
|
+
async readPointer(key) {
|
|
12493
|
+
const target = path(key);
|
|
12494
|
+
try {
|
|
12495
|
+
await regular3(target);
|
|
12496
|
+
const bytes = await readFile16(target);
|
|
12497
|
+
return { version: hash3(bytes), bytes };
|
|
12498
|
+
} catch (error) {
|
|
12499
|
+
if (missing(error))
|
|
12500
|
+
return null;
|
|
12501
|
+
throw error;
|
|
12502
|
+
}
|
|
12503
|
+
},
|
|
12504
|
+
async compareAndSwap(key, expectedVersion, bytes) {
|
|
12505
|
+
const target = path(key);
|
|
12506
|
+
await mkdir15(dirname19(target), { recursive: true, mode: 448 });
|
|
12507
|
+
const lock = `${target}.lock`;
|
|
12508
|
+
try {
|
|
12509
|
+
await mkdir15(lock);
|
|
12510
|
+
} catch (error) {
|
|
12511
|
+
if (error.code === "EEXIST")
|
|
12512
|
+
return false;
|
|
12513
|
+
throw error;
|
|
12514
|
+
}
|
|
12515
|
+
try {
|
|
12516
|
+
let current = null;
|
|
12517
|
+
try {
|
|
12518
|
+
await regular3(target);
|
|
12519
|
+
current = hash3(await readFile16(target));
|
|
12520
|
+
} catch (error) {
|
|
12521
|
+
if (!missing(error))
|
|
12522
|
+
throw error;
|
|
12523
|
+
}
|
|
12524
|
+
if (current !== expectedVersion)
|
|
12525
|
+
return false;
|
|
12526
|
+
const temporary = `${target}.${randomBytes5(8).toString("hex")}.partial`;
|
|
12527
|
+
await writeFile17(temporary, bytes, { flag: "wx", mode: 384 });
|
|
12528
|
+
await rename4(temporary, target);
|
|
12529
|
+
return true;
|
|
12530
|
+
} finally {
|
|
12531
|
+
await rmdir2(lock);
|
|
12532
|
+
}
|
|
12533
|
+
}
|
|
12534
|
+
};
|
|
12535
|
+
}
|
|
12536
|
+
function dailyPointerSignerFromPem(keyId, pem) {
|
|
12537
|
+
const key = createPrivateKey2(pem);
|
|
12538
|
+
if (key.asymmetricKeyType !== "ed25519")
|
|
12539
|
+
throw new Error("Daily pointer key must be Ed25519");
|
|
12540
|
+
return { keyId, sign: async (message) => new Uint8Array(sign2(null, message, key)) };
|
|
12541
|
+
}
|
|
12542
|
+
function parseDailyPointerTrust(value) {
|
|
12543
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
12544
|
+
throw new Error("Invalid Daily pointer trust");
|
|
12545
|
+
const entries = Object.entries(value);
|
|
12546
|
+
if (!entries.length || entries.length > 16 || !entries.every(([id, key]) => /^[a-z0-9][a-z0-9._-]{0,63}$/.test(id) && typeof key === "string" && Buffer.from(key, "base64").length === 32))
|
|
12547
|
+
throw new Error("Invalid Daily pointer trust");
|
|
12548
|
+
return new Map(entries);
|
|
12549
|
+
}
|
|
12550
|
+
|
|
12551
|
+
// src/commands/daily-batch.ts
|
|
12552
|
+
var usage = [
|
|
12553
|
+
"daily-batch show --dry-run <store-dir> <app-id> <feed-app> <trust.json>",
|
|
12554
|
+
"daily-batch promote --dry-run <store-dir> <release-config.json> <candidate-dir> <key-id> <signing-key.pem> <trust.json>",
|
|
12555
|
+
"daily-batch rollback --dry-run <store-dir> <app-id> <feed-app> <manifest-digest> <key-id> <signing-key.pem> <trust.json>"
|
|
12556
|
+
].join("; ");
|
|
12557
|
+
var bounded3 = async (path, max, name) => {
|
|
12558
|
+
const stat = await lstat26(path);
|
|
12559
|
+
if (!stat.isFile() || stat.size < 1 || stat.size > max)
|
|
12560
|
+
throw new Error(`Invalid ${name}`);
|
|
12561
|
+
return readFile17(path);
|
|
12562
|
+
};
|
|
12563
|
+
var json2 = async (path, max, name) => JSON.parse((await bounded3(path, max, name)).toString("utf8"));
|
|
12564
|
+
var summary = (snapshot) => snapshot && {
|
|
12565
|
+
sequence: snapshot.sequence,
|
|
12566
|
+
manifestDigest: snapshot.manifestDigest,
|
|
12567
|
+
tag: snapshot.manifest.identity.tag,
|
|
12568
|
+
sourceSha: snapshot.manifest.identity.sourceSha,
|
|
12569
|
+
artifacts: snapshot.manifest.artifacts.length,
|
|
12570
|
+
receipts: snapshot.manifest.receipts.length
|
|
12571
|
+
};
|
|
12572
|
+
async function dailyBatchCommand(args, cwd) {
|
|
12573
|
+
const [action, flag, storeDir, ...operands] = args;
|
|
12574
|
+
if (!action || !["show", "promote", "rollback"].includes(action))
|
|
12575
|
+
throw new Error(`Expected ${usage}`);
|
|
12576
|
+
if (flag !== "--dry-run")
|
|
12577
|
+
throw new Error("Live Daily batch publication is not enabled; pass --dry-run with a local store directory");
|
|
12578
|
+
if (!storeDir)
|
|
12579
|
+
throw new Error(`Expected ${usage}`);
|
|
12580
|
+
const root = resolve24(cwd, storeDir);
|
|
12581
|
+
const rootStat = await lstat26(root);
|
|
12582
|
+
if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
|
|
12583
|
+
throw new Error("The Daily batch store must be an existing real directory");
|
|
12584
|
+
const store = createDailyBatchDirectoryStore(root);
|
|
12585
|
+
const signer = async (keyId, path) => dailyPointerSignerFromPem(keyId, (await bounded3(resolve24(cwd, path), 4096, "Daily pointer signing key")).toString("utf8"));
|
|
12586
|
+
const trust = async (path) => parseDailyPointerTrust(await json2(resolve24(cwd, path), 16384, "Daily pointer trust"));
|
|
12587
|
+
if (action === "show") {
|
|
12588
|
+
const [appId, feedApp, trustPath, ...extra] = operands;
|
|
12589
|
+
if (!appId || !feedApp || !trustPath || extra.length)
|
|
12590
|
+
throw new Error(`Expected ${usage}`);
|
|
12591
|
+
const current = await readDailyBatch(store, { appId, feedApp }, await trust(trustPath));
|
|
12592
|
+
return { action, dryRun: true, store: root, current: summary(current) };
|
|
12593
|
+
}
|
|
12594
|
+
if (action === "promote") {
|
|
12595
|
+
const [configPath, candidateDir, keyId, keyPath, trustPath, ...extra] = operands;
|
|
12596
|
+
if (!configPath || !candidateDir || !keyId || !keyPath || !trustPath || extra.length)
|
|
12597
|
+
throw new Error(`Expected ${usage}`);
|
|
12598
|
+
const config = await json2(resolve24(cwd, configPath), 262144, "release configuration");
|
|
12599
|
+
const directory = resolve24(cwd, candidateDir);
|
|
12600
|
+
const selected = await promoteDailyBatch(store, {
|
|
12601
|
+
verify: () => runReleaseLibrary(provideLibraryPorts()(stagedDailyBatchManifestEffect({ config, directory }))),
|
|
12602
|
+
path: (kind, name) => resolve24(directory, kind, name)
|
|
12603
|
+
}, await signer(keyId, keyPath), await trust(trustPath));
|
|
12604
|
+
return { action, dryRun: true, store: root, current: summary(selected) };
|
|
12605
|
+
}
|
|
12606
|
+
const [appId, feedApp, digest, keyId, keyPath, trustPath, ...extra] = operands;
|
|
12607
|
+
if (!appId || !feedApp || !digest || !keyId || !keyPath || !trustPath || extra.length)
|
|
12608
|
+
throw new Error(`Expected ${usage}`);
|
|
12609
|
+
const keys = await trust(trustPath);
|
|
12610
|
+
const target = { appId, feedApp };
|
|
12611
|
+
const current = await readDailyBatch(store, target, keys);
|
|
12612
|
+
if (!current)
|
|
12613
|
+
throw new Error("No Daily batch is selected; nothing to roll back");
|
|
12614
|
+
await rollbackDailyBatch(store, current, await readDailyBatchByDigest(store, target, digest), await signer(keyId, keyPath), keys);
|
|
12615
|
+
return {
|
|
12616
|
+
action,
|
|
12617
|
+
dryRun: true,
|
|
12618
|
+
store: root,
|
|
12619
|
+
previous: summary(current),
|
|
12620
|
+
current: summary(await readDailyBatch(store, target, keys))
|
|
12621
|
+
};
|
|
12622
|
+
}
|
|
12623
|
+
|
|
12232
12624
|
// src/commands/build-windows-standalone.ts
|
|
12233
12625
|
import { basename as basename20 } from "path";
|
|
12234
12626
|
import { Effect as Effect30 } from "effect";
|
|
@@ -12262,8 +12654,8 @@ var buildWindowsStandaloneCommand = (args) => runCommand("Unable to build the st
|
|
|
12262
12654
|
|
|
12263
12655
|
// src/library/apt/stage-apt-repository.ts
|
|
12264
12656
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
12265
|
-
import { lstat as
|
|
12266
|
-
import { dirname as
|
|
12657
|
+
import { lstat as lstat27, mkdir as mkdir16, readFile as readFile18, readdir as readdir16, rm as rm18, unlink as unlink4, writeFile as writeFile18 } from "fs/promises";
|
|
12658
|
+
import { dirname as dirname20, isAbsolute as isAbsolute12, join as join46 } from "path";
|
|
12267
12659
|
function cmd(program, options, label) {
|
|
12268
12660
|
const run = spawnSync3(program, options, { encoding: "utf8", timeout: 60000 });
|
|
12269
12661
|
if (run.error || run.status !== 0)
|
|
@@ -12271,14 +12663,14 @@ function cmd(program, options, label) {
|
|
|
12271
12663
|
return run.stdout;
|
|
12272
12664
|
}
|
|
12273
12665
|
async function add(path, bytes) {
|
|
12274
|
-
await
|
|
12275
|
-
await
|
|
12666
|
+
await mkdir16(dirname20(path), { recursive: true });
|
|
12667
|
+
await writeFile18(path, bytes, { flag: "wx" });
|
|
12276
12668
|
}
|
|
12277
12669
|
async function stageAptRepositoryCommand(args) {
|
|
12278
12670
|
const [tag, policyPath, inventoryPath, packagePath, output, signingHome, trustedFingerprint] = args;
|
|
12279
|
-
if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !
|
|
12671
|
+
if (args.length !== 7 || !tag || !/^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(tag) || !policyPath || !inventoryPath || !packagePath || !output || !signingHome || !isAbsolute12(signingHome) || !trustedFingerprint || !/^[A-F0-9]{40}$/.test(trustedFingerprint))
|
|
12280
12672
|
throw new Error("Expected TAG POLICY VERIFIED_INVENTORY DEB_OR_DIRECTORY NEW_OUTPUT GPG_HOME PINNED_FINGERPRINT");
|
|
12281
|
-
const rawPolicy = JSON.parse(await
|
|
12673
|
+
const rawPolicy = JSON.parse(await readFile18(policyPath, "utf8"));
|
|
12282
12674
|
if (typeof rawPolicy !== "object" || rawPolicy === null || Array.isArray(rawPolicy))
|
|
12283
12675
|
throw new Error("Expected APT repository policy");
|
|
12284
12676
|
const variant = rawPolicy;
|
|
@@ -12286,27 +12678,27 @@ async function stageAptRepositoryCommand(args) {
|
|
|
12286
12678
|
const policies = multiarch ? variant.packages : [rawPolicy];
|
|
12287
12679
|
if (!Array.isArray(policies) || policies.length !== (multiarch ? 2 : 1) || policies.some((policy) => !policy || typeof policy !== "object" || !/^[A-Za-z0-9][A-Za-z0-9_.+-]*\.deb$/.test(policy.assetName)))
|
|
12288
12680
|
throw new Error("Invalid APT release package selection");
|
|
12289
|
-
const inventory = JSON.parse(await
|
|
12681
|
+
const inventory = JSON.parse(await readFile18(inventoryPath, "utf8"));
|
|
12290
12682
|
if (inventory.tag !== tag || !Array.isArray(inventory.assets))
|
|
12291
12683
|
throw new Error("Verified inventory does not name requested release");
|
|
12292
12684
|
if (multiarch) {
|
|
12293
|
-
if (!(await
|
|
12685
|
+
if (!(await lstat27(packagePath)).isDirectory())
|
|
12294
12686
|
throw new Error("Multiarch APT requires one directory of two ordinary DEBs");
|
|
12295
12687
|
const entries = await readdir16(packagePath, { withFileTypes: true });
|
|
12296
12688
|
if (entries.length !== 2 || entries.some((entry) => !entry.isFile() || !policies.some((policy) => entry.name === policy.assetName)))
|
|
12297
12689
|
throw new Error("Multiarch APT requires exactly the two selected ordinary DEBs");
|
|
12298
12690
|
}
|
|
12299
|
-
await
|
|
12691
|
+
await mkdir16(output, { mode: 448 });
|
|
12300
12692
|
try {
|
|
12301
12693
|
const now = new Date;
|
|
12302
12694
|
const stagedInputs = [];
|
|
12303
12695
|
for (const [index, policy] of policies.entries()) {
|
|
12304
|
-
const input = multiarch ?
|
|
12305
|
-
if (!(await
|
|
12696
|
+
const input = multiarch ? join46(packagePath, policy.assetName) : packagePath;
|
|
12697
|
+
if (!(await lstat27(input)).isFile())
|
|
12306
12698
|
throw new Error("Expected ordinary Debian package");
|
|
12307
|
-
const deb = await
|
|
12308
|
-
const stagedInput =
|
|
12309
|
-
await
|
|
12699
|
+
const deb = await readFile18(input);
|
|
12700
|
+
const stagedInput = join46(output, `.input-${index}.deb`);
|
|
12701
|
+
await writeFile18(stagedInput, deb, { mode: 384, flag: "wx" });
|
|
12310
12702
|
const control = cmd("dpkg-deb", ["--field", stagedInput], "Debian control inspection failed");
|
|
12311
12703
|
stagedInputs.push({ policy, tag, assets: inventory.assets, deb, control, now, stagedInput });
|
|
12312
12704
|
}
|
|
@@ -12315,12 +12707,12 @@ async function stageAptRepositoryCommand(args) {
|
|
|
12315
12707
|
const { packagePath: stagedPackagePath, files, release } = stageAptMetadata(single);
|
|
12316
12708
|
return { files, release, packages: [{ packagePath: stagedPackagePath, deb: single.deb }] };
|
|
12317
12709
|
})();
|
|
12318
|
-
const base =
|
|
12710
|
+
const base = join46(output, "dists", single.policy.suite);
|
|
12319
12711
|
for (const entry of staged.packages)
|
|
12320
|
-
await add(
|
|
12712
|
+
await add(join46(output, entry.packagePath), entry.deb);
|
|
12321
12713
|
for (const [path, contents] of staged.files)
|
|
12322
|
-
await add(
|
|
12323
|
-
await add(
|
|
12714
|
+
await add(join46(base, path), contents);
|
|
12715
|
+
await add(join46(base, "Release"), staged.release);
|
|
12324
12716
|
const flags = [
|
|
12325
12717
|
"--batch",
|
|
12326
12718
|
"--no-tty",
|
|
@@ -12337,15 +12729,15 @@ async function stageAptRepositoryCommand(args) {
|
|
|
12337
12729
|
["InRelease", "--clearsign"],
|
|
12338
12730
|
["Release.gpg", "--detach-sign"]
|
|
12339
12731
|
]) {
|
|
12340
|
-
cmd("gpg", [...flags, "--armor", "--output",
|
|
12732
|
+
cmd("gpg", [...flags, "--armor", "--output", join46(base, name), mode, join46(base, "Release")], `Could not produce ${name} with the pinned signing identity`);
|
|
12341
12733
|
}
|
|
12342
12734
|
for (const { stagedInput } of stagedInputs)
|
|
12343
12735
|
await unlink4(stagedInput);
|
|
12344
|
-
await add(
|
|
12736
|
+
await add(join46(output, "STAGED"), `${tag}
|
|
12345
12737
|
`);
|
|
12346
12738
|
return { tag, staged: true };
|
|
12347
12739
|
} catch (error) {
|
|
12348
|
-
await
|
|
12740
|
+
await rm18(output, { recursive: true, force: true });
|
|
12349
12741
|
throw error;
|
|
12350
12742
|
}
|
|
12351
12743
|
}
|
|
@@ -12353,10 +12745,10 @@ async function stageAptRepositoryCommand(args) {
|
|
|
12353
12745
|
// src/library/release-retention-cli.ts
|
|
12354
12746
|
import { constants as constants9 } from "fs";
|
|
12355
12747
|
import { open as open16 } from "fs/promises";
|
|
12356
|
-
import { isAbsolute as
|
|
12748
|
+
import { isAbsolute as isAbsolute13 } from "path";
|
|
12357
12749
|
|
|
12358
12750
|
// src/library/release-retention.ts
|
|
12359
|
-
import { createHash as
|
|
12751
|
+
import { createHash as createHash30 } from "crypto";
|
|
12360
12752
|
var day = 86400000;
|
|
12361
12753
|
var safeTag = /^v(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-dev\.(?:0|[1-9]\d*))?$/;
|
|
12362
12754
|
var safeAsset = /^[a-zA-Z0-9][a-zA-Z0-9._+-]{0,254}$/;
|
|
@@ -12384,7 +12776,7 @@ function unique(rows, key, caption) {
|
|
|
12384
12776
|
var byKey = (a, b) => a.key.localeCompare(b.key);
|
|
12385
12777
|
var ordered = (rows, key) => rows.toSorted((a, b) => key(a).localeCompare(key(b)));
|
|
12386
12778
|
var stable = (value) => JSON.stringify(value);
|
|
12387
|
-
var fingerprint = (value) =>
|
|
12779
|
+
var fingerprint = (value) => createHash30("sha256").update(stable(value)).digest("hex");
|
|
12388
12780
|
var latestFirst = (a, b) => date(b.publishedAt) - date(a.publishedAt) || a.tag.localeCompare(b.tag);
|
|
12389
12781
|
function planReleaseRetention(snapshot) {
|
|
12390
12782
|
const { app } = snapshot;
|
|
@@ -12528,7 +12920,7 @@ function assertRetirementPreflight(plan, fresh, approvedDigest) {
|
|
|
12528
12920
|
|
|
12529
12921
|
// src/library/release-retention-cli.ts
|
|
12530
12922
|
var document = async (path) => {
|
|
12531
|
-
if (!path || !
|
|
12923
|
+
if (!path || !isAbsolute13(path))
|
|
12532
12924
|
throw new Error("Expected an absolute evidence file path");
|
|
12533
12925
|
const file = await open16(path, constants9.O_RDONLY | constants9.O_NOFOLLOW | constants9.O_NONBLOCK);
|
|
12534
12926
|
try {
|
|
@@ -12558,22 +12950,22 @@ if (false) {}
|
|
|
12558
12950
|
|
|
12559
12951
|
// src/linux-channel-proof-cli.ts
|
|
12560
12952
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
12561
|
-
import { createHash as
|
|
12562
|
-
import { createReadStream as
|
|
12953
|
+
import { createHash as createHash31 } from "crypto";
|
|
12954
|
+
import { createReadStream as createReadStream5 } from "fs";
|
|
12563
12955
|
import { constants as constants10, createWriteStream as createWriteStream2 } from "fs";
|
|
12564
|
-
import { lstat as
|
|
12956
|
+
import { lstat as lstat28, mkdtemp as mkdtemp15, open as open17, readFile as readFile19, realpath as realpath13, rm as rm19 } from "fs/promises";
|
|
12565
12957
|
import { tmpdir as tmpdir8 } from "os";
|
|
12566
|
-
import { basename as basename21, join as
|
|
12958
|
+
import { basename as basename21, join as join47 } from "path";
|
|
12567
12959
|
import { pipeline as pipeline3 } from "stream/promises";
|
|
12568
12960
|
import { pathToFileURL } from "url";
|
|
12569
12961
|
function check4(ok, message) {
|
|
12570
12962
|
if (!ok)
|
|
12571
12963
|
throw new Error(message);
|
|
12572
12964
|
}
|
|
12573
|
-
async function
|
|
12574
|
-
check4((await
|
|
12575
|
-
const digest =
|
|
12576
|
-
for await (const chunk of
|
|
12965
|
+
async function hash4(path) {
|
|
12966
|
+
check4((await lstat28(path)).isFile(), "artifact must be a regular file");
|
|
12967
|
+
const digest = createHash31("sha256");
|
|
12968
|
+
for await (const chunk of createReadStream5(path))
|
|
12577
12969
|
digest.update(chunk);
|
|
12578
12970
|
return digest.digest("hex");
|
|
12579
12971
|
}
|
|
@@ -12606,11 +12998,11 @@ async function verifyRpmStage(stage) {
|
|
|
12606
12998
|
}
|
|
12607
12999
|
for (const artifact of [stage.payload, stage.rpm]) {
|
|
12608
13000
|
check4(/^[0-9a-f]{64}$/.test(artifact.sha256), "expected SHA-256");
|
|
12609
|
-
check4(await
|
|
13001
|
+
check4(await hash4(artifact.path) === artifact.sha256, "staged artifact digest mismatch");
|
|
12610
13002
|
}
|
|
12611
13003
|
const repo = await realpath13(stage.repository);
|
|
12612
13004
|
const keyUrl = pathToFileURL(await realpath13(stage.publicKey)).href;
|
|
12613
|
-
const config = options(await
|
|
13005
|
+
const config = options(await readFile19(stage.repoFile, "utf8"), stage.repoId);
|
|
12614
13006
|
check4(config.get("baseurl") === pathToFileURL(repo).href, "expected the local repository");
|
|
12615
13007
|
check4(config.get("gpgkey") === keyUrl, "expected the configured QA public key");
|
|
12616
13008
|
for (const flag of ["pkg_gpgcheck", "repo_gpgcheck"]) {
|
|
@@ -12620,10 +13012,10 @@ async function verifyRpmStage(stage) {
|
|
|
12620
13012
|
check4([...config.keys()].every((key) => allowed.has(key)), "unexpected repository options");
|
|
12621
13013
|
for (const path of [
|
|
12622
13014
|
stage.publicKey,
|
|
12623
|
-
|
|
12624
|
-
|
|
13015
|
+
join47(repo, "repodata/repomd.xml"),
|
|
13016
|
+
join47(repo, "repodata/repomd.xml.asc")
|
|
12625
13017
|
]) {
|
|
12626
|
-
check4((await
|
|
13018
|
+
check4((await lstat28(path)).isFile(), "expected regular key and signed metadata files");
|
|
12627
13019
|
}
|
|
12628
13020
|
const result = spawnSync4("rpm", ["-qp", "--queryformat", "%{NAME}|%{VERSION}|%{ARCH}", await realpath13(stage.rpm.path)], { encoding: "utf8", timeout: 1e4 });
|
|
12629
13021
|
check4(result.error?.code !== "ENOENT", "rpm is required for RPM header verification");
|
|
@@ -12633,12 +13025,12 @@ async function verifyRpmStage(stage) {
|
|
|
12633
13025
|
async function verifySignedRpmStage(stage, fingerprint) {
|
|
12634
13026
|
check4(/^[A-F0-9]{40}$/.test(fingerprint), "expected an independently trusted full primary fingerprint");
|
|
12635
13027
|
await verifyRpmStage(stage);
|
|
12636
|
-
const root = await mkdtemp15(
|
|
12637
|
-
const rpm =
|
|
12638
|
-
const key =
|
|
12639
|
-
const metadata =
|
|
12640
|
-
const signature =
|
|
12641
|
-
const originalMetadata =
|
|
13028
|
+
const root = await mkdtemp15(join47(tmpdir8(), "rpm-signature-proof-"));
|
|
13029
|
+
const rpm = join47(root, "package.rpm");
|
|
13030
|
+
const key = join47(root, "key.asc");
|
|
13031
|
+
const metadata = join47(root, "repomd.xml");
|
|
13032
|
+
const signature = join47(root, "repomd.xml.asc");
|
|
13033
|
+
const originalMetadata = join47(stage.repository, "repodata/repomd.xml");
|
|
12642
13034
|
const originalSignature = `${originalMetadata}.asc`;
|
|
12643
13035
|
const snapshot = async (source, target, max) => {
|
|
12644
13036
|
const file = await open17(source, constants10.O_RDONLY | constants10.O_NOFOLLOW);
|
|
@@ -12666,7 +13058,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
12666
13058
|
await snapshot(stage.publicKey, key, 1024 * 1024);
|
|
12667
13059
|
await snapshot(originalMetadata, metadata, 8 * 1024 * 1024);
|
|
12668
13060
|
await snapshot(originalSignature, signature, 1024 * 1024);
|
|
12669
|
-
check4(await
|
|
13061
|
+
check4(await hash4(rpm) === stage.rpm.sha256, "RPM changed before signature verification");
|
|
12670
13062
|
const gpg = ["--no-options", "--batch", "--homedir", root, "--no-auto-key-retrieve"];
|
|
12671
13063
|
const list = command("gpg", [...gpg, "--with-colons", "--fingerprint", "--show-keys", key]);
|
|
12672
13064
|
const lines = list.split(`
|
|
@@ -12679,7 +13071,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
12679
13071
|
const signatures = verified.split(`
|
|
12680
13072
|
`).filter((line) => line.startsWith("[GNUPG:] VALIDSIG "));
|
|
12681
13073
|
check4(signatures.length === 1 && signatures[0].split(" ").at(-1) === fingerprint, "metadata signer does not match pinned primary fingerprint");
|
|
12682
|
-
const db =
|
|
13074
|
+
const db = join47(root, "rpmdb");
|
|
12683
13075
|
command("rpm", ["--dbpath", db, "--initdb"]);
|
|
12684
13076
|
command("rpmkeys", ["--dbpath", db, "--import", key]);
|
|
12685
13077
|
command("rpmkeys", ["--dbpath", db, "--define", "_pkgverify_level all", "--checksig", rpm]);
|
|
@@ -12693,10 +13085,10 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
12693
13085
|
]);
|
|
12694
13086
|
const rpmIdentity = identity.split("|");
|
|
12695
13087
|
check4(rpmIdentity.length === 5 && rpmIdentity[0] === stage.packageName && /^[0-9]+$/.test(rpmIdentity[1]) && rpmIdentity[2] === stage.version && /^[A-Za-z0-9][A-Za-z0-9._+~^]*$/.test(rpmIdentity[3]) && rpmIdentity[4] === stage.architecture, "signed RPM header does not match the requested package");
|
|
12696
|
-
const rpmSha256 = await
|
|
12697
|
-
const metadataSha256 = await
|
|
12698
|
-
const signatureSha256 = await
|
|
12699
|
-
check4(await
|
|
13088
|
+
const rpmSha256 = await hash4(rpm);
|
|
13089
|
+
const metadataSha256 = await hash4(metadata);
|
|
13090
|
+
const signatureSha256 = await hash4(signature);
|
|
13091
|
+
check4(await hash4(stage.rpm.path) === rpmSha256 && await hash4(originalMetadata) === metadataSha256 && await hash4(originalSignature) === signatureSha256, "signed inputs changed during verification");
|
|
12700
13092
|
return {
|
|
12701
13093
|
kind: "rpm-signature-proof",
|
|
12702
13094
|
sourceSha: stage.sourceSha,
|
|
@@ -12707,7 +13099,7 @@ async function verifySignedRpmStage(stage, fingerprint) {
|
|
|
12707
13099
|
signatureSha256
|
|
12708
13100
|
};
|
|
12709
13101
|
} finally {
|
|
12710
|
-
await
|
|
13102
|
+
await rm19(root, { recursive: true, force: true });
|
|
12711
13103
|
}
|
|
12712
13104
|
}
|
|
12713
13105
|
var systemTalkDenied2 = /^(org\.freedesktop\.(Flatpak|DBus|systemd1)|org\.gtk\.GDBus)(\.|$)/;
|
|
@@ -12736,14 +13128,14 @@ function verifyFlatpakCapabilities(policy, result) {
|
|
|
12736
13128
|
|
|
12737
13129
|
// src/linux-rpm-metadata-proof.ts
|
|
12738
13130
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
12739
|
-
import { createHash as
|
|
13131
|
+
import { createHash as createHash32 } from "crypto";
|
|
12740
13132
|
import { constants as constants11 } from "fs";
|
|
12741
|
-
import { lstat as
|
|
12742
|
-
import { isAbsolute as
|
|
13133
|
+
import { lstat as lstat29, open as open18, realpath as realpath14 } from "fs/promises";
|
|
13134
|
+
import { isAbsolute as isAbsolute14, join as join48, relative as relative7, resolve as resolve25 } from "path";
|
|
12743
13135
|
import { gunzipSync as gunzipSync2 } from "zlib";
|
|
12744
13136
|
var maxCompressed = 16 * 1024 * 1024;
|
|
12745
13137
|
var maxOpen = 32 * 1024 * 1024;
|
|
12746
|
-
var digest5 = (bytes) =>
|
|
13138
|
+
var digest5 = (bytes) => createHash32("sha256").update(bytes).digest("hex");
|
|
12747
13139
|
function ensure2(ok, reason) {
|
|
12748
13140
|
if (!ok)
|
|
12749
13141
|
throw new Error(reason);
|
|
@@ -12831,7 +13223,7 @@ async function digestRegular(path, expectedSize) {
|
|
|
12831
13223
|
try {
|
|
12832
13224
|
const stat = await file.stat();
|
|
12833
13225
|
ensure2(stat.isFile() && stat.size === expectedSize && stat.size > 0 && stat.size <= 4 * 1024 * 1024 * 1024, "Invalid RPM file");
|
|
12834
|
-
const hash =
|
|
13226
|
+
const hash = createHash32("sha256");
|
|
12835
13227
|
let size = 0;
|
|
12836
13228
|
for await (const chunk of file.createReadStream({ autoClose: false })) {
|
|
12837
13229
|
size += chunk.length;
|
|
@@ -12845,13 +13237,13 @@ async function digestRegular(path, expectedSize) {
|
|
|
12845
13237
|
}
|
|
12846
13238
|
}
|
|
12847
13239
|
async function contained(repo, href) {
|
|
12848
|
-
ensure2(!
|
|
13240
|
+
ensure2(!isAbsolute14(href) && href.length <= 1024, "Invalid repository path");
|
|
12849
13241
|
const parts = href.split("/");
|
|
12850
13242
|
ensure2(parts.every((part) => /^[A-Za-z0-9][A-Za-z0-9._+-]*$/.test(part)), "Invalid repository path");
|
|
12851
13243
|
let current = repo;
|
|
12852
13244
|
for (let i = 0;i < parts.length; i++) {
|
|
12853
|
-
current =
|
|
12854
|
-
const info = await
|
|
13245
|
+
current = join48(current, parts[i]);
|
|
13246
|
+
const info = await lstat29(current);
|
|
12855
13247
|
ensure2(i === parts.length - 1 ? info.isFile() : info.isDirectory(), "Unsafe repository path");
|
|
12856
13248
|
}
|
|
12857
13249
|
ensure2(await realpath14(current) === current, "Repository path resolves outside its location");
|
|
@@ -12889,10 +13281,10 @@ async function verifyRpmRepository(stage, fingerprint) {
|
|
|
12889
13281
|
plain = zstd.stdout;
|
|
12890
13282
|
}
|
|
12891
13283
|
ensure2(plain.length === record.openSize && digest5(plain) === openHash, "Uncompressed primary metadata checksum mismatch");
|
|
12892
|
-
const rpmPath =
|
|
13284
|
+
const rpmPath = resolve25(stage.rpm.path);
|
|
12893
13285
|
const rpmHref = relative7(repo, rpmPath);
|
|
12894
13286
|
ensure2(!rpmHref.startsWith("../") && rpmHref !== "" && await contained(repo, rpmHref) === rpmPath, "RPM must be a regular file inside the local repository");
|
|
12895
|
-
const rpmStat = await
|
|
13287
|
+
const rpmStat = await lstat29(rpmPath);
|
|
12896
13288
|
parseXml("primary", plain, [...proof.rpmIdentity, rpmHref, proof.rpmSha256, String(rpmStat.size)]);
|
|
12897
13289
|
ensure2(await digestRegular(rpmPath, rpmStat.size) === proof.rpmSha256, "RPM changed during repository verification");
|
|
12898
13290
|
return {
|
|
@@ -12905,8 +13297,8 @@ async function verifyRpmRepository(stage, fingerprint) {
|
|
|
12905
13297
|
}
|
|
12906
13298
|
|
|
12907
13299
|
// src/library/arch-publish.ts
|
|
12908
|
-
import { createHash as
|
|
12909
|
-
import { join as
|
|
13300
|
+
import { createHash as createHash33 } from "crypto";
|
|
13301
|
+
import { join as join49 } from "path";
|
|
12910
13302
|
import { tmpdir as tmpdir9 } from "os";
|
|
12911
13303
|
import { Effect as Effect31 } from "effect";
|
|
12912
13304
|
|
|
@@ -13148,7 +13540,7 @@ var readLicense = (url) => Effect31.gen(function* () {
|
|
|
13148
13540
|
return yield* fail("Release license is unavailable");
|
|
13149
13541
|
}
|
|
13150
13542
|
const bytes = yield* step(() => readReleaseBytes(response, MAX_LICENSE_BYTES));
|
|
13151
|
-
const sha256 = yield* step(async () =>
|
|
13543
|
+
const sha256 = yield* step(async () => createHash33("sha256").update(bytes).digest("hex"));
|
|
13152
13544
|
return { url, sha256 };
|
|
13153
13545
|
});
|
|
13154
13546
|
var git2 = (args) => Effect31.gen(function* () {
|
|
@@ -13190,7 +13582,7 @@ var verifyArchRelease = (options) => Effect31.gen(function* () {
|
|
|
13190
13582
|
if (!listed)
|
|
13191
13583
|
return yield* fail(`Missing signed descriptor: ${descriptorPolicy.name}`);
|
|
13192
13584
|
const bytes = yield* feedBytes(options.feed, `${options.tag}/${descriptorPolicy.name}`, 65536);
|
|
13193
|
-
if (!bytes || bytes.length !== listed.size ||
|
|
13585
|
+
if (!bytes || bytes.length !== listed.size || createHash33("sha256").update(bytes).digest("hex") !== listed.sha256)
|
|
13194
13586
|
return yield* fail(`Signed descriptor differs from its release: ${descriptorPolicy.name}`);
|
|
13195
13587
|
const json = yield* step(async () => {
|
|
13196
13588
|
try {
|
|
@@ -13262,7 +13654,7 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
|
|
|
13262
13654
|
const directory = options.printDirectory;
|
|
13263
13655
|
yield* step(() => fs.mkdir(directory, { recursive: true }));
|
|
13264
13656
|
for (const [name, contents] of Object.entries({ ...files, ...repositoryFiles }))
|
|
13265
|
-
yield* step(() => fs.writeFile(
|
|
13657
|
+
yield* step(() => fs.writeFile(join49(directory, name), contents, { mode: 420 }));
|
|
13266
13658
|
}
|
|
13267
13659
|
const base = { pkgname: policy.pkgname, pkgver: rendered.pkgver, pkgrel };
|
|
13268
13660
|
if (options.dryRun)
|
|
@@ -13275,14 +13667,14 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
|
|
|
13275
13667
|
if (!key.includes("PRIVATE KEY"))
|
|
13276
13668
|
return yield* fail("AUR_SSH_PRIVATE_KEY_B64 is not a private key");
|
|
13277
13669
|
return yield* Effect31.gen(function* () {
|
|
13278
|
-
const work = yield* step(() => fs.mkdtemp(
|
|
13670
|
+
const work = yield* step(() => fs.mkdtemp(join49(tmpdir9(), "arch-package-")));
|
|
13279
13671
|
yield* Effect31.addFinalizer(() => Effect31.promise(() => fs.rm(work, { recursive: true, force: true }).then(() => {
|
|
13280
13672
|
return;
|
|
13281
13673
|
}, () => {
|
|
13282
13674
|
return;
|
|
13283
13675
|
})));
|
|
13284
|
-
const keyFile =
|
|
13285
|
-
const knownHosts =
|
|
13676
|
+
const keyFile = join49(work, "aur_id_ed25519");
|
|
13677
|
+
const knownHosts = join49(work, "aur_known_hosts");
|
|
13286
13678
|
yield* step(() => fs.mkdir(work, { recursive: true, mode: 448 }));
|
|
13287
13679
|
yield* step(() => fs.writeFile(keyFile, key.endsWith(`
|
|
13288
13680
|
`) ? key : `${key}
|
|
@@ -13290,7 +13682,7 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
|
|
|
13290
13682
|
yield* step(() => fs.writeFile(knownHosts, `${AUR_HOST_KEY}
|
|
13291
13683
|
`, { mode: 420 }));
|
|
13292
13684
|
const ssh = `ssh -i "${keyFile}" -o IdentitiesOnly=yes -o UserKnownHostsFile="${knownHosts}" -o StrictHostKeyChecking=yes`;
|
|
13293
|
-
const checkout =
|
|
13685
|
+
const checkout = join49(work, policy.pkgname);
|
|
13294
13686
|
yield* git2([
|
|
13295
13687
|
"-c",
|
|
13296
13688
|
`core.sshCommand=${ssh}`,
|
|
@@ -13303,7 +13695,7 @@ var publishArchPackageEffect = (options) => Effect31.gen(function* () {
|
|
|
13303
13695
|
checkout
|
|
13304
13696
|
]);
|
|
13305
13697
|
for (const [name, contents] of Object.entries(files))
|
|
13306
|
-
yield* step(() => fs.writeFile(
|
|
13698
|
+
yield* step(() => fs.writeFile(join49(checkout, name), contents, { mode: 420 }));
|
|
13307
13699
|
yield* git2(["-C", checkout, "add", "--", ...Object.keys(files)]);
|
|
13308
13700
|
const staged = yield* gitExit(["-C", checkout, "diff", "--cached", "--quiet"]);
|
|
13309
13701
|
if (staged === 0)
|
|
@@ -13381,6 +13773,22 @@ var publish = (argv) => {
|
|
|
13381
13773
|
yield* print({ tag: result.tag, runId: result.runId, runAttempt: result.runAttempt });
|
|
13382
13774
|
}), { requireGitHubActions: !local });
|
|
13383
13775
|
};
|
|
13776
|
+
var publishPackages = (argv) => {
|
|
13777
|
+
const [local, args] = localFlag(argv);
|
|
13778
|
+
return runCommand((error) => `Unable to stage the Linux packages: ${redactedErrorMessage(error)}`, Effect32.gen(function* () {
|
|
13779
|
+
const [directory, configPath, out, ...extra] = args;
|
|
13780
|
+
if (!local || !directory || !configPath || !out || extra.length)
|
|
13781
|
+
return yield* invalid("Expected --local <packages-dir> <release-config.json> <out>");
|
|
13782
|
+
const config = yield* readReleaseConfig(configPath);
|
|
13783
|
+
const { env } = yield* ReleaseConfig;
|
|
13784
|
+
const { RELEASE_TAG: tag, SOURCE_SHA: sourceSha } = env;
|
|
13785
|
+
if (!tag || !sourceSha)
|
|
13786
|
+
return yield* invalid("Missing local release identity");
|
|
13787
|
+
yield* localTagProvenanceEffect({ config, tag, sourceSha });
|
|
13788
|
+
const plan = yield* Effect32.uninterruptible(stageLocalPackagesEffect({ config, directory, out, tag, sourceSha }));
|
|
13789
|
+
return yield* print({ tag, objects: plan.objects.length });
|
|
13790
|
+
}));
|
|
13791
|
+
};
|
|
13384
13792
|
var cut = (argv) => {
|
|
13385
13793
|
const [local, args] = localFlag(argv);
|
|
13386
13794
|
return runCommand((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, Effect32.gen(function* () {
|
|
@@ -13459,7 +13867,7 @@ var planAssets = (args) => runCommand("Unable to plan release assets; check rele
|
|
|
13459
13867
|
const { env } = yield* ReleaseConfig;
|
|
13460
13868
|
yield* print(yield* planReleaseAssetsEffect({ env, config, tag }));
|
|
13461
13869
|
}));
|
|
13462
|
-
var
|
|
13870
|
+
var sign3 = (args) => runCommand("Unable to sign release artifact; check the identity, archive and signing key.", Effect32.gen(function* () {
|
|
13463
13871
|
const [identityPath, artifactPath, feed, ...extra] = args;
|
|
13464
13872
|
const { env } = yield* ReleaseConfig;
|
|
13465
13873
|
if (!identityPath || !artifactPath || !feed || extra.length || !env.ADEA_RELEASE_SIGNING_KEY)
|
|
@@ -13663,6 +14071,10 @@ var dailyMatrix = (args) => runCommand("Unable to prepare the Daily matrix; chec
|
|
|
13663
14071
|
const result = action === "verify" ? yield* verifyDailyReleaseMatrixEffect(options) : yield* stageDailyBatchEffect({ ...options, parent });
|
|
13664
14072
|
return yield* print(result);
|
|
13665
14073
|
}));
|
|
14074
|
+
var dailyBatch = (args) => runCommand((error) => `Unable to run the Daily batch command: ${redactedErrorMessage(error)}`, Effect32.gen(function* () {
|
|
14075
|
+
const { cwd } = yield* ReleaseConfig;
|
|
14076
|
+
yield* print(yield* step(() => dailyBatchCommand(args, cwd)));
|
|
14077
|
+
}));
|
|
13666
14078
|
var prepareStableCatalog2 = (args) => runCommand((error) => `Unable to prepare Stable catalog: ${redactedErrorMessage(error)}`, Effect32.gen(function* () {
|
|
13667
14079
|
yield* print(yield* step(() => prepareStableCatalogCommand(args)));
|
|
13668
14080
|
}));
|
|
@@ -13710,6 +14122,7 @@ var commands = {
|
|
|
13710
14122
|
"build-linux-formats": buildLinuxFormatsCommand,
|
|
13711
14123
|
"build-windows-standalone": buildWindowsStandaloneCommand,
|
|
13712
14124
|
cut,
|
|
14125
|
+
"daily-batch": dailyBatch,
|
|
13713
14126
|
"daily-matrix": dailyMatrix,
|
|
13714
14127
|
finalize,
|
|
13715
14128
|
"linux-channel-proof": linuxChannelProof,
|
|
@@ -13720,8 +14133,9 @@ var commands = {
|
|
|
13720
14133
|
promote,
|
|
13721
14134
|
publish,
|
|
13722
14135
|
"publish-arch": publishArch,
|
|
14136
|
+
"publish-packages": publishPackages,
|
|
13723
14137
|
"publish-framework-package": publishFramework,
|
|
13724
|
-
sign:
|
|
14138
|
+
sign: sign3,
|
|
13725
14139
|
"sign-descriptors": signDescriptors,
|
|
13726
14140
|
"stage-apt-repository": stageAptRepository,
|
|
13727
14141
|
step: releaseStep,
|