Skip to content

Commit 6d7a2bc

Browse files
authored
fix(install): fix nightly digest extraction on macOS (#331)
## Summary The nightly install script fails on macOS with: ``` gunzip: (stdin): unexpected end of file ``` The OCI manifest digest extraction in Step 4 used `sed 's/},{/}\\n{/g'` to split layers onto separate lines before awk extracted the digest. This had two bugs: 1. **BSD sed (macOS)** treats `\\n` as literal characters, not a newline — the manifest stays on one line and awk always finds the config digest (`sha256:44136fa...`, a 2-byte empty `{}` blob) instead of the binary. 2. **First-layer edge case**: the first layer shares a line with the config block because the array starts with `[{`, not `},{`. The result: downloading 2 bytes of `{}` instead of the ~23 MB compressed binary. ## Fix Replace the `sed` + `awk` pipeline with a single `awk` pass that tracks the last-seen `"digest"` value and prints it when the target filename matches in `"org.opencontainers.image.title"`. No `sed` needed, works on both GNU and BSD awk.
1 parent fe7d51d commit 6d7a2bc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

install

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,18 @@ if [[ "$requested_version" == "nightly" ]]; then
127127

128128
echo -e "${MUTED}Installing nightly sentry ${version}...${NC}"
129129

130-
# Step 4: Find the blob digest for this platform's .gz file
130+
# Step 4: Find the blob digest for this platform's .gz file.
131+
# Each OCI layer has "digest" before "org.opencontainers.image.title".
132+
# Track the last-seen digest and print it when the target filename matches.
133+
# This avoids sed newline replacement which differs between GNU and BSD.
131134
gz_filename="sentry-${os}-${arch}${suffix}.gz"
132135
digest=$(echo "$MANIFEST" \
133-
| sed 's/},{/}\n{/g' \
134-
| awk -F'"' "/\"${gz_filename//./\\.}"'/{for(i=1;i<=NF;i++) if($i=="digest"){print $(i+2);exit}}')
136+
| awk -F'"' -v target="$gz_filename" '{
137+
for(i=1;i<=NF;i++){
138+
if($i=="digest") d=$(i+2)
139+
if($i=="org.opencontainers.image.title"&&$(i+2)==target){print d;exit}
140+
}
141+
}')
135142
if [[ -z "$digest" ]]; then
136143
echo -e "${RED}No nightly build found for ${gz_filename}${NC}"
137144
exit 1

0 commit comments

Comments
 (0)