Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Reduce temporary macOS packaging and app copy work (#660)

Deefe3d93edd91a
diff --git a/desktop/RELEASE.md b/desktop/RELEASE.md
index 82e75e62e..a7cb16184 100644
--- a/desktop/RELEASE.md
+++ b/desktop/RELEASE.md
@@ -162,6 +162,9 @@ arm64/x86_64 slices, signatures and hardened runtime are checked before publicat
still receives both app and DMG notarization, with the stapled app inside the DMG. Separate scratch
manifests are combined only after all macOS and Linux builds succeed, followed by verification of
all six public downloads. `macos-build-timings` records the bounded build and per-variant phases.
+App copies and DMG staging use independent APFS clones when available. The temporary
+notarization ZIP uses faster compression; the downloadable ZIP retains normal compression
+and is rebuilt from the stapled app. Signing and both notarization checks remain the same.
`scripts/publish-macos-variant.sh intel|apple-silicon <version>` remains the single-variant entry
point. With `--no-build`, `APP_BUNDLE` selects an existing bundle; the uploader's `OUTPUT_DIR`
diff --git a/desktop/scripts/build-macos-variants.py b/desktop/scripts/build-macos-variants.py
index b5661f002..d531bf5aa 100644
--- a/desktop/scripts/build-macos-variants.py
+++ b/desktop/scripts/build-macos-variants.py
@@ -101,7 +101,9 @@ def build(version, defines, desktop, output, receipt):
if bundle.exists():
shutil.rmtree(bundle)
bundle.parent.mkdir(parents=True, exist_ok=True)
- copies.append(check(f"copy-{variant}", ["ditto", str(source), str(bundle)], 60))
+ # APFS clones keep independent files without rewriting the same app bytes.
+ # ditto falls back to copying where cloning is unavailable.
+ copies.append(check(f"copy-{variant}", ["ditto", "--clone", str(source), str(bundle)], 60))
phase(copies, desktop, output, receipt)
phase([check(f"renderer-{variant}", ["env", f"APP_BUNDLE={output / variant / 'Harness.app'}",
"bash", variant_script, variant, version, "--no-build", "--build-only"], 120)
diff --git a/desktop/scripts/upload-desktop.sh b/desktop/scripts/upload-desktop.sh
index 866e75bd8..2db23fde8 100755
--- a/desktop/scripts/upload-desktop.sh
+++ b/desktop/scripts/upload-desktop.sh
@@ -222,7 +222,16 @@ mkdir -p "$OUTPUT_DIR"
ZIP="$OUTPUT_DIR/Harness-macos-$VER.zip"
rm -f "$ZIP"
echo ">> packaging $ZIP"
-( cd "$(dirname "$APP_BUNDLE")" && ditto -c -k --sequesterRsrc --keepParent "$(basename "$APP_BUNDLE")" "$ZIP" )
+package_zip() {
+ ( cd "$(dirname "$APP_BUNDLE")" && ditto -c -k --sequesterRsrc --keepParent "$@" "$(basename "$APP_BUNDLE")" "$ZIP" )
+}
+if [ "$DO_NOTARIZE" -eq 1 ]; then
+ # This upload is discarded after stapling. Spend less CPU compressing it;
+ # the final downloadable ZIP below still uses ditto's normal compression.
+ package_zip --zlibCompressionLevel 1
+else
+ package_zip
+fi
# --- Step 3b: notarize + staple ---
# Apple's notary service inspects a zip (or the .app directly) and returns a ticket; stapling
@@ -248,7 +257,7 @@ if [ "$DO_NOTARIZE" -eq 1 ]; then
echo ">> re-packaging $ZIP with the stapled ticket"
rm -f "$ZIP"
- ( cd "$(dirname "$APP_BUNDLE")" && ditto -c -k --sequesterRsrc --keepParent "$(basename "$APP_BUNDLE")" "$ZIP" )
+ package_zip
# Fails closed rather than silently shipping a build Gatekeeper would reject on someone else's Mac.
spctl -a -vv --type execute "$APP_BUNDLE" || {
@@ -271,7 +280,7 @@ DMG="$OUTPUT_DIR/Harness-macos-$VER.dmg"
DMG_STAGE="$(mktemp -d)" # removed by cleanup() on EXIT
echo ">> packaging $DMG"
rm -f "$DMG"
-cp -R "$APP_BUNDLE" "$DMG_STAGE/"
+ditto --clone "$APP_BUNDLE" "$DMG_STAGE/$(basename "$APP_BUNDLE")"
ln -s /Applications "$DMG_STAGE/Applications"
hdiutil create -quiet -srcfolder "$DMG_STAGE" -volname "Harness" -fs HFS+ -format UDZO -ov "$DMG"
diff --git a/scripts/tests/test_macos_variants.py b/scripts/tests/test_macos_variants.py
index 5206ba9ef..03614aa9a 100644
--- a/scripts/tests/test_macos_variants.py
+++ b/scripts/tests/test_macos_variants.py
@@ -72,7 +72,7 @@ print("published fixture")
for script, tool in (("publish-macos-variant.sh", "variant.py"), ("upload-desktop.sh", "upload.py")):
(scripts / script).write_text(f'exec "{sys.executable}" tools/{tool} "$@"\n')
ditto = self.bin / "ditto"
- ditto.write_text(f"#!{sys.executable}\nimport shutil,sys\nshutil.copytree(sys.argv[1],sys.argv[2])\n")
+ ditto.write_text(f"#!{sys.executable}\nimport shutil,sys\nargs=sys.argv[1:]\nif args[0]=='--clone':args.pop(0)\nshutil.copytree(*args)\n")
ditto.chmod(0o755)
self.environment = mock.patch.dict(os.environ, PATH=str(self.bin) + os.pathsep + os.environ["PATH"])
self.environment.start()