Files
buzz/desktop/scripts/set-dmg-finder-text-size.sh
cls 4a79c0072c
Docker image / Build (linux/amd64) (push) Has been cancelled
Docker image / Build (linux/arm64) (push) Has been cancelled
Docker image / Merge release multi-arch manifest (push) Has been cancelled
Docker image / Merge debug multi-arch manifest (push) Has been cancelled
Docker image / Build public push gateway (linux/amd64) (push) Has been cancelled
Docker image / Build public push gateway (linux/arm64) (push) Has been cancelled
Docker image / Publish public push gateway image (push) Has been cancelled
Harbor Buzz Orchestra / Python tests and lint (push) Has been cancelled
CI / Detect Changed Paths (push) Has been cancelled
CI / Rust Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Desktop Core (push) Has been cancelled
CI / Desktop Smoke E2E (1) (push) Has been cancelled
CI / Desktop Smoke E2E (2) (push) Has been cancelled
CI / Desktop Smoke E2E (3) (push) Has been cancelled
CI / Desktop Smoke E2E (4) (push) Has been cancelled
CI / Desktop (push) Has been cancelled
CI / Desktop E2E Relay (push) Has been cancelled
CI / Desktop E2E Integration (1/2) (push) Has been cancelled
CI / Desktop E2E Integration (2/2) (push) Has been cancelled
CI / Desktop E2E Integration (push) Has been cancelled
CI / Backend Integration (relay e2e) (push) Has been cancelled
CI / Relay E2E (push) Has been cancelled
CI / Web (push) Has been cancelled
CI / Mobile (push) Has been cancelled
CI / Security (push) Has been cancelled
CI / Dead Token Reference Guard (push) Has been cancelled
CI / Server Cross-Compile (aarch64-unknown-linux-musl) (push) Has been cancelled
CI / Server Cross-Compile (x86_64-unknown-linux-musl) (push) Has been cancelled
CI / Windows Rust (x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Desktop Build (macOS) (push) Has been cancelled
helm chart / lint + unittest + render matrix (push) Has been cancelled
helm chart / install on kind (gated) (push) Has been cancelled
helm chart / publish chart to GHCR (push) Has been cancelled
Mesh Lifecycle / Relay-Driven Mesh Lifecycle Smoke (push) Has been cancelled
Sprig image / Build (linux/amd64) (push) Has been cancelled
Sprig image / Build (linux/arm64) (push) Has been cancelled
Sprig image / Merge multi-arch manifest (push) Has been cancelled
Sprig / Build (aarch64-unknown-linux-musl) (push) Has been cancelled
Sprig / Build (x86_64-unknown-linux-musl) (push) Has been cancelled
Sprig / Publish rolling release (push) Has been cancelled
Sprig / Publish tagged release (push) Has been cancelled
Import exact Chinese Buzz source tree
Signed-off-by: cls_???? <908705107@qq.com>
2026-08-13 18:38:15 +08:00

83 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Patch Finder icon-label text size in a Tauri-generated DMG.
#
# Tauri's DMG config supports the background/layout fields we use, but it does
# not expose create-dmg's text-size option. Run this before DMG signing or
# notarization; mutating a signed DMG would invalidate the signature.
set -euo pipefail
if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "Usage: $0 <path-to-dmg> [text-size]" >&2
exit 2
fi
DMG_PATH="$1"
TEXT_SIZE="${2:-14}"
[[ -f "$DMG_PATH" ]] || { echo "Missing DMG: $DMG_PATH" >&2; exit 1; }
WORK_DIR="$(mktemp -d -t buzz-dmg-text-size)"
MOUNT_POINT="$WORK_DIR/mount"
RW_DMG="$WORK_DIR/work.dmg"
OUT_DMG="$WORK_DIR/output.dmg"
MOUNTED="false"
cleanup() {
if [[ "$MOUNTED" == "true" ]]; then
hdiutil detach "$MOUNT_POINT" >/dev/null 2>&1 || true
fi
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
mkdir -p "$MOUNT_POINT"
hdiutil convert "$DMG_PATH" -format UDRW -o "$RW_DMG" -ov >/dev/null
hdiutil attach "$RW_DMG" -nobrowse -readwrite -noverify -mountpoint "$MOUNT_POINT" >/dev/null
MOUNTED="true"
node - "$MOUNT_POINT/.DS_Store" "$TEXT_SIZE" <<'NODE'
const fs = require("node:fs");
const dsStorePath = process.argv[2];
const textSize = Number(process.argv[3]);
if (!Number.isFinite(textSize)) {
throw new Error(`Invalid DMG Finder text size: ${process.argv[3]}`);
}
const data = fs.readFileSync(dsStorePath);
if (!data.includes(Buffer.from("textSize"))) {
throw new Error(`${dsStorePath} does not contain Finder textSize metadata`);
}
const current = Buffer.alloc(8);
current.writeDoubleBE(16.0, 0);
const replacement = Buffer.alloc(8);
replacement.writeDoubleBE(textSize, 0);
const positions = [];
let offset = 0;
while ((offset = data.indexOf(current, offset)) !== -1) {
positions.push(offset);
offset += 1;
}
if (positions.length !== 1) {
throw new Error(
`Expected one Finder textSize value in ${dsStorePath}, found ${positions.length}`,
);
}
replacement.copy(data, positions[0]);
fs.writeFileSync(dsStorePath, data);
console.log(`Set DMG Finder textSize to ${textSize}`);
NODE
sync
hdiutil detach "$MOUNT_POINT" >/dev/null
MOUNTED="false"
hdiutil convert "$RW_DMG" -format UDZO -imagekey zlib-level=9 -o "$OUT_DMG" -ov >/dev/null
mv "$OUT_DMG" "$DMG_PATH"