Skip to content

Commit 3658413

Browse files
committed
fix(install,smoke): carry cbm-integrations.json wherever the binary goes
pr-smoke failed on all three platforms: the binary's install/uninstall render templates from the integration asset, and every place that stages the binary without the asset made those operations fail closed with "integration assets missing". The asset must travel with the binary in EVERY layout, not just the release archive. Five staging paths were missing it: - scripts/build.sh — stage cbm-integrations.json next to the freshly built binary, so `build/c/codebase-memory-mcp install` works straight out of a build tree (dev, and the base for the smoke fixture). - scripts/smoke-local.sh — include the asset in the fixture tarball and its required-sidecar check. Member set and ORDER now mirror package-release.sh exactly (binary, cbm-integrations.json, LICENSE, install.sh, notices); the fixture was smoking an archive layout we never actually ship. - install.sh / install.ps1 — after installing the binary, copy the asset beside it in the install dir. `install` already publishes a verified copy to ~/.cbm/assets/<version>/, but a later install/uninstall run from the install dir resolves the asset NEXT TO THE BINARY first, so without the adjacent copy that lookup misses and a re-install or uninstall fails on a machine that just installed successfully. Best-effort atomic rename, same shape as the existing install.sh/ps1 sidecar copy. install.ps1 stays pure ASCII. - scripts/smoke-test.sh Phase 14 — this phase hand-stages the binary into a fresh HOME without going through install, so nothing populates ~/.cbm/assets; stage the asset next to each staged copy so the uninstall it drives resolves. Verified: scripts/smoke-local.sh on the standard binary now runs clean through all 16 phases — zero "integration assets missing" / hook_script_uninstall / agent-cleanup-failed lines (was 5). windows-bundle, smoke-fixture, exec-bit and no-embedded-scripts contracts pass; install.ps1 has zero non-ASCII bytes. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 83df500 commit 3658413

5 files changed

Lines changed: 64 additions & 5 deletions

File tree

‎install.ps1‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,24 @@ if (Test-Path -LiteralPath $DownloadedInstaller -PathType Leaf) {
322322
}
323323
}
324324

325+
# Place the integration-template asset beside the installed binary, mirroring
326+
# install.sh. `install` above published a verified copy to ~/.cbm/assets, but a
327+
# later install/uninstall run from $InstallDir resolves the asset next to the
328+
# binary first; without this copy that lookup misses and the run fails closed
329+
# with "integration assets missing".
330+
$DownloadedAsset = Join-Path $TmpDir "cbm-integrations.json"
331+
if (Test-Path -LiteralPath $DownloadedAsset -PathType Leaf) {
332+
$AssetDest = Join-Path $InstallDir "cbm-integrations.json"
333+
$AssetTmp = "$AssetDest.new"
334+
try {
335+
Copy-Item -LiteralPath $DownloadedAsset -Destination $AssetTmp -Force -ErrorAction Stop
336+
Move-Item -LiteralPath $AssetTmp -Destination $AssetDest -Force -ErrorAction Stop
337+
} catch {
338+
Remove-Item -LiteralPath $AssetTmp -Force -ErrorAction SilentlyContinue
339+
Write-Host "note: could not place cbm-integrations.json in $InstallDir (asset resolves from ~/.cbm/assets)"
340+
}
341+
}
342+
325343
# Verify
326344
try {
327345
$ver = & $Dest --version 2>&1

‎install.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,25 @@ if [ -f "$DL_INSTALLER" ]; then
294294
fi
295295
fi
296296

297+
# Place the integration-template asset beside the installed binary. `install`
298+
# above already published a verified copy to ~/.cbm/assets/<version>/, but a
299+
# later `install`/`uninstall` run from INSTALL_DIR resolves the asset next to
300+
# the binary FIRST — and without this copy that lookup misses, so a re-run or an
301+
# uninstall would fail closed with "integration assets missing" even though a
302+
# valid install just completed. Atomic rename, best effort, same rationale as
303+
# the installer copy above.
304+
DL_ASSET="$DLDIR/cbm-integrations.json"
305+
if [ -f "$DL_ASSET" ]; then
306+
ASSET_TMP="$INSTALL_DIR/.cbm-integrations.json.$$"
307+
if cp "$DL_ASSET" "$ASSET_TMP" 2>/dev/null &&
308+
mv -f "$ASSET_TMP" "$INSTALL_DIR/cbm-integrations.json" 2>/dev/null; then
309+
:
310+
else
311+
rm -f "$ASSET_TMP" 2>/dev/null || true
312+
echo "note: could not place cbm-integrations.json in $INSTALL_DIR (asset resolves from ~/.cbm/assets)"
313+
fi
314+
fi
315+
297316
# Verify
298317
VERSION=$("$DEST" --version 2>&1) || {
299318
echo "error: installed binary failed to run" >&2

‎scripts/build.sh‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,14 @@ else
156156
CFLAGS_EXTRA="$CFLAGS_EXTRA" "${EXTRA_MAKE_ARGS[@]+"${EXTRA_MAKE_ARGS[@]}"}"
157157
fi
158158

159+
# Stage the integration-template asset next to the binary so the dev/CI build
160+
# mirrors the release archive layout. The binary resolves cbm-integrations.json
161+
# next to itself, in $CBM_ASSETS_DIR, or under ~/.cbm/assets/<version>/; a plain
162+
# build/c binary has none of those, so install/uninstall (which render the
163+
# templates to verify hash and ownership) would fail closed exactly as they do
164+
# for a user who deleted the file. Copying it here keeps `install` working
165+
# straight out of a build tree — smoke, local dev, and the release packaging all
166+
# then see the same adjacency.
167+
cp "$ROOT/assets/cbm-integrations.json" "$BUILD_DIR/cbm-integrations.json"
168+
159169
echo "=== Build complete: ${BUILD_DIR}/codebase-memory-mcp ==="

‎scripts/smoke-local.sh‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ esac
7272
ARTIFACT_DIR="${CBM_SMOKE_ARTIFACT_DIR:-}"
7373
if [ -n "$ARTIFACT_DIR" ]; then
7474
ARTIFACT_DIR="$(cd "$ARTIFACT_DIR" && pwd)"
75-
for required in LICENSE install.sh THIRD_PARTY_NOTICES.md; do
75+
for required in cbm-integrations.json LICENSE install.sh THIRD_PARTY_NOTICES.md; do
7676
[ -s "$ARTIFACT_DIR/$required" ] || {
7777
echo "smoke-local: release artifact is missing $required" >&2
7878
exit 2
@@ -123,16 +123,20 @@ mkdir -p "$FIXTURE_DIR" "$SMOKE_TEMP_DIR" "$SMOKE_HOME" "$SMOKE_XDG_CONFIG" \
123123
"$SMOKE_APPDATA" "$SMOKE_LOCALAPPDATA"
124124
cp "$BINARY" "$FIXTURE_DIR/codebase-memory-mcp"
125125
if [ -n "$ARTIFACT_DIR" ]; then
126-
cp "$ARTIFACT_DIR/LICENSE" "$ARTIFACT_DIR/install.sh" \
127-
"$ARTIFACT_DIR/THIRD_PARTY_NOTICES.md" "$FIXTURE_DIR/"
126+
cp "$ARTIFACT_DIR/cbm-integrations.json" "$ARTIFACT_DIR/LICENSE" \
127+
"$ARTIFACT_DIR/install.sh" "$ARTIFACT_DIR/THIRD_PARTY_NOTICES.md" "$FIXTURE_DIR/"
128128
else
129-
cp "$ROOT/LICENSE" "$ROOT/install.sh" "$FIXTURE_DIR/"
129+
cp "$ROOT/assets/cbm-integrations.json" "$ROOT/LICENSE" "$ROOT/install.sh" "$FIXTURE_DIR/"
130130
"$ROOT/scripts/gen-third-party-notices.sh" "$FIXTURE_DIR/THIRD_PARTY_NOTICES.md"
131131
fi
132132

133+
# The archive must carry cbm-integrations.json — install verifies it against the
134+
# binary's embedded SHA-256 and fails closed without it. Member set and ORDER
135+
# mirror scripts/package-release.sh (the Windows single-binary contract locks
136+
# that order); a fixture that omits it would smoke a release layout we never ship.
133137
EXPECTED_ARTIFACT="codebase-memory-mcp${SUFFIX}-${OS}-${ARCH}.tar.gz"
134138
tar -czf "$FIXTURE_DIR/$EXPECTED_ARTIFACT" -C "$FIXTURE_DIR" \
135-
codebase-memory-mcp LICENSE install.sh THIRD_PARTY_NOTICES.md
139+
codebase-memory-mcp cbm-integrations.json LICENSE install.sh THIRD_PARTY_NOTICES.md
136140
if [ -n "$SUFFIX" ]; then
137141
cp "$FIXTURE_DIR/$EXPECTED_ARTIFACT" \
138142
"$FIXTURE_DIR/codebase-memory-mcp-${OS}-${ARCH}.tar.gz"

‎scripts/smoke-test.sh‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,16 +3068,24 @@ if [ -n "${SMOKE_DOWNLOAD_URL:-}" ]; then
30683068
fi
30693069
UPDATE_HOME=$(smoke_mktemp_dir)
30703070
mkdir -p "$UPDATE_HOME/.claude" "$UPDATE_HOME/.local/bin"
3071+
# This phase stages the binary by hand into a fresh HOME — it does NOT go
3072+
# through install.sh or `install`, so nothing populates ~/.cbm/assets. The
3073+
# integration asset ships next to the binary in every real layout (archive,
3074+
# build tree, installed dir), so stage it next to each staged copy here too;
3075+
# otherwise the uninstall this phase drives fails closed rendering templates.
3076+
BINARY_ASSET="$(dirname "$BINARY")/cbm-integrations.json"
30713077
if [[ "$BINARY" == *.exe ]]; then
30723078
cp "$BINARY" "$UPDATE_HOME/.local/bin/codebase-memory-mcp.exe"
30733079
mkdir -p "$UPDATE_HOME/retired-install"
30743080
cp "$BINARY" "$UPDATE_HOME/retired-install/codebase-memory-mcp.exe"
3081+
[ -f "$BINARY_ASSET" ] && cp "$BINARY_ASSET" "$UPDATE_HOME/.local/bin/cbm-integrations.json"
30753082
else
30763083
cp "$BINARY" "$UPDATE_HOME/.local/bin/codebase-memory-mcp"
30773084
chmod 755 "$UPDATE_HOME/.local/bin/codebase-memory-mcp"
30783085
mkdir -p "$UPDATE_HOME/retired-install"
30793086
cp "$BINARY" "$UPDATE_HOME/retired-install/codebase-memory-mcp"
30803087
chmod 755 "$UPDATE_HOME/retired-install/codebase-memory-mcp"
3088+
[ -f "$BINARY_ASSET" ] && cp "$BINARY_ASSET" "$UPDATE_HOME/.local/bin/cbm-integrations.json"
30813089
if [ "$(uname -s)" = "Darwin" ]; then
30823090
codesign --sign - --force "$UPDATE_HOME/.local/bin/codebase-memory-mcp" 2>/dev/null || true
30833091
codesign --sign - --force "$UPDATE_HOME/retired-install/codebase-memory-mcp" \

0 commit comments

Comments
 (0)