Skip to content

Commit 0544334

Browse files
committed
fix(mac): package portable elevation installer
1 parent 97a53a9 commit 0544334

3 files changed

Lines changed: 48 additions & 12 deletions

File tree

‎apps/macos/README.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,21 @@ notarization credentials, and its archive is not a general-download artifact.
7171

7272
```bash
7373
scripts/mac-elevation-host.sh package
74-
scripts/mac-elevation-host.sh install \
75-
--archive "dist/elevation-host/OpenClaw-<full-source-sha>-stable.zip"
76-
scripts/mac-elevation-host.sh status
74+
cd dist/elevation-host
75+
shasum -a 256 -c "OpenClaw-<full-source-sha>-stable.zip.sha256"
76+
shasum -a 256 -c "OpenClaw-<full-source-sha>-stable-installer.sh.sha256"
77+
./OpenClaw-<full-source-sha>-stable-installer.sh install \
78+
--archive "OpenClaw-<full-source-sha>-stable.zip"
79+
./OpenClaw-<full-source-sha>-stable-installer.sh status
7780
```
7881

7982
The elevation package is ZIP-only, notarized and stapled, contains exactly
8083
`OpenClaw.app`, omits Apple Events entitlements, records an immutable receipt,
81-
and verifies a freshly extracted copy. Installation owns the separate
84+
and verifies a freshly extracted copy. The same source-addressed artifact set
85+
includes an executable installer copied from that exact Git commit plus separate
86+
archive and installer checksum files, so a target Mac does not need a source
87+
checkout. Transfer the complete set and verify both checksums before running the
88+
installer. Installation owns the separate
8289
`ai.openclaw.mac.elevation-host` launchd job with `RunAtLoad` and `KeepAlive`.
8390
It refuses to replace or race the ordinary `ai.openclaw.mac` Launch at login
8491
job. `recover` restores the recorded prior bundle after a failed cutover;

‎scripts/mac-elevation-host.sh‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,16 @@ write_receipt() {
327327

328328
package_host() {
329329
[[ "$(uname -s)" == 'Darwin' ]] || fail 'elevation packaging requires macOS'
330-
local source_commit prefix zip_path receipt_path checksum_path notary_result
330+
local source_commit prefix zip_path receipt_path checksum_path installer_path installer_checksum_path notary_result
331331
source_commit="$(git -C "$ROOT_DIR" rev-parse HEAD)"
332332
[[ "$source_commit" =~ ^[0-9a-f]{40}$ ]] || fail 'could not resolve exact source commit'
333333
prefix="OpenClaw-${source_commit}-stable"
334334
zip_path="$OUTPUT_DIR/${prefix}.zip"
335335
receipt_path="$OUTPUT_DIR/${prefix}.json"
336336
checksum_path="$zip_path.sha256"
337-
for output in "$zip_path" "$receipt_path" "$checksum_path"; do
337+
installer_path="$OUTPUT_DIR/${prefix}-installer.sh"
338+
installer_checksum_path="$installer_path.sha256"
339+
for output in "$zip_path" "$receipt_path" "$checksum_path" "$installer_path" "$installer_checksum_path"; do
338340
[[ ! -e "$output" ]] || fail "immutable elevation output already exists: $output"
339341
done
340342
mkdir -p "$OUTPUT_DIR"
@@ -364,18 +366,31 @@ package_host() {
364366
extract_archive "$tmp_zip" extracted
365367
[[ "$(plist_value "$extracted" OpenClawGitCommit)" == "$source_commit" ]] ||
366368
fail 'extracted elevation source mismatch'
367-
local archive_sha notary_id main_archs helper_archs main_entitlements helper_entitlements
369+
local archive_sha installer_sha committed_installer_sha notary_id
370+
local main_archs helper_archs main_entitlements helper_entitlements
368371
archive_sha="$(shasum -a 256 "$tmp_zip" | awk '{print $1}')"
372+
local tmp_installer="${installer_path}.tmp.$$"
373+
cp "$ROOT_DIR/scripts/mac-elevation-host.sh" "$tmp_installer"
374+
chmod 555 "$tmp_installer"
375+
installer_sha="$(shasum -a 256 "$tmp_installer" | awk '{print $1}')"
376+
committed_installer_sha="$(git -C "$ROOT_DIR" show "${source_commit}:scripts/mac-elevation-host.sh" | shasum -a 256 | awk '{print $1}')"
377+
[[ "$installer_sha" == "$committed_installer_sha" ]] ||
378+
fail 'portable installer does not match the selected source commit'
369379
notary_id="$(jq -r '.id // empty' "$notary_result")"
370380
[[ -n "$notary_id" ]] || fail 'accepted notarization id was not recorded'
371381
main_archs="$(lipo -archs "$extracted/Contents/MacOS/OpenClaw")"
372382
helper_archs="$(lipo -archs "$extracted/Contents/MacOS/openclaw-mlx-tts")"
373383
main_entitlements="$(entitlements_for "$extracted/Contents/MacOS/OpenClaw" | shasum -a 256 | awk '{print $1}')"
374384
helper_entitlements="$(entitlements_for "$extracted/Contents/MacOS/openclaw-mlx-tts" | shasum -a 256 | awk '{print $1}')"
375385
mv "$tmp_zip" "$zip_path"
386+
mv "$tmp_installer" "$installer_path"
376387
jq -n \
377388
--arg archive "$(basename "$zip_path")" \
378389
--arg archiveSha256 "$archive_sha" \
390+
--arg archiveChecksum "$(basename "$checksum_path")" \
391+
--arg installer "$(basename "$installer_path")" \
392+
--arg installerSha256 "$installer_sha" \
393+
--arg installerChecksum "$(basename "$installer_checksum_path")" \
379394
--arg sourceCommit "$source_commit" \
380395
--arg peekabooCommit "$(plist_value "$extracted" PeekabooSourceCommit)" \
381396
--arg version "$version" \
@@ -388,13 +403,17 @@ package_host() {
388403
--arg mainEntitlementsSha256 "$main_entitlements" \
389404
--arg helperEntitlementsSha256 "$helper_entitlements" \
390405
--arg notarizationId "$notary_id" \
391-
'{archive:$archive,archiveSha256:$archiveSha256,sourceCommit:$sourceCommit,peekabooCommit:$peekabooCommit,version:$version,build:$build,authority:$authority,teamIdentifier:$teamIdentifier,cdhash:$cdhash,architectures:{main:$mainArchitectures,helper:$helperArchitectures},entitlementsSha256:{main:$mainEntitlementsSha256,helper:$helperEntitlementsSha256},notarizationId:$notarizationId}' >"${receipt_path}.tmp.$$"
406+
'{archive:$archive,archiveSha256:$archiveSha256,archiveChecksum:$archiveChecksum,installer:$installer,installerSha256:$installerSha256,installerChecksum:$installerChecksum,sourceCommit:$sourceCommit,peekabooCommit:$peekabooCommit,version:$version,build:$build,authority:$authority,teamIdentifier:$teamIdentifier,cdhash:$cdhash,architectures:{main:$mainArchitectures,helper:$helperArchitectures},entitlementsSha256:{main:$mainEntitlementsSha256,helper:$helperEntitlementsSha256},notarizationId:$notarizationId}' >"${receipt_path}.tmp.$$"
392407
chmod 444 "${receipt_path}.tmp.$$"
393408
mv "${receipt_path}.tmp.$$" "$receipt_path"
394409
printf '%s %s\n' "$archive_sha" "$(basename "$zip_path")" >"${checksum_path}.tmp.$$"
395410
chmod 444 "${checksum_path}.tmp.$$"
396411
mv "${checksum_path}.tmp.$$" "$checksum_path"
397-
printf 'Elevation archive: %s\nReceipt: %s\nSHA-256: %s\n' "$zip_path" "$receipt_path" "$archive_sha"
412+
printf '%s %s\n' "$installer_sha" "$(basename "$installer_path")" >"${installer_checksum_path}.tmp.$$"
413+
chmod 444 "${installer_checksum_path}.tmp.$$"
414+
mv "${installer_checksum_path}.tmp.$$" "$installer_checksum_path"
415+
printf 'Elevation archive: %s\nInstaller: %s\nReceipt: %s\nArchive SHA-256: %s\nInstaller SHA-256: %s\n' \
416+
"$zip_path" "$installer_path" "$receipt_path" "$archive_sha" "$installer_sha"
398417
}
399418

400419
install_host() {

‎test/scripts/mac-elevation-host.test.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,18 @@ describe("mac elevation host command contract", () => {
143143
expect(script).not.toContain("osascript");
144144
});
145145

146-
it("scopes prerequisites to each lifecycle command", () => {
146+
it("runs a copied lifecycle installer without a source checkout", () => {
147147
const tempRoot = tempDirs.make("openclaw-elevation-uninstall-");
148148
const binDir = path.join(tempRoot, "bin");
149+
const installerPath = path.join(tempRoot, "portable-installer.sh");
149150
mkdirSync(binDir);
151+
writeExecutable(installerPath, readFileSync(scriptPath, "utf8"));
150152
const launchctl = path.join(binDir, "launchctl");
151153
writeFileSync(launchctl, "#!/bin/sh\nexit 0\n", "utf8");
152154
chmodSync(launchctl, 0o755);
153155

154-
const result = spawnSync("/bin/bash", [scriptPath, "uninstall"], {
155-
cwd: process.cwd(),
156+
const result = spawnSync("/bin/bash", [installerPath, "uninstall"], {
157+
cwd: tempRoot,
156158
encoding: "utf8",
157159
env: {
158160
HOME: tempRoot,
@@ -212,6 +214,14 @@ describe("mac elevation host command contract", () => {
212214
expect(script).toContain("SKIP_DMG=1");
213215
expect(script).toContain("NOTARY_RESULT_FILE");
214216
expect(script).toContain("archiveSha256");
217+
expect(script).toContain("archiveChecksum");
218+
expect(script).toContain('installer_path="$OUTPUT_DIR/${prefix}-installer.sh"');
219+
expect(script).toContain("installerSha256");
220+
expect(script).toContain("installerChecksum");
221+
expect(script).toContain(
222+
'git -C "$ROOT_DIR" show "${source_commit}:scripts/mac-elevation-host.sh"',
223+
);
224+
expect(script).toContain("portable installer does not match the selected source commit");
215225
expect(script).toContain("notarizationId");
216226
expect(script).toContain("entitlementsSha256");
217227
expect(script).toContain("elevation archive root must contain exactly OpenClaw.app");

0 commit comments

Comments
 (0)