Package 1.1.0: one PKG installs the CLI and the notarized app

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kfattic
2026-09-16 13:24:26 -05:00
parent 8d39bafb6f
commit e0d48e49e8
4 changed files with 89 additions and 38 deletions

View File

@@ -1,17 +1,32 @@
#!/bin/bash
# cupsadmin postinstall (payload-free pkg): the binary ships in the Scripts archive next to this file.
# Never changes ownership/permissions of an existing /usr/local/bin (Homebrew on Intel owns it).
# cupsadmin postinstall (payload-free pkg): the CLI binary and CUPS Admin.app ship in the Scripts
# archive next to this file. Never changes ownership/permissions of an existing /usr/local/bin
# (Homebrew on Intel owns it) or of /Applications (root:admin 775).
set -euo pipefail
TARGET="${3:-/}"
DEST_DIR="${TARGET%/}/usr/local/bin"
SOURCE="$(cd "$(dirname "$0")" && pwd)/cupsadmin"
HERE="$(cd "$(dirname "$0")" && pwd)"
# --- CLI -------------------------------------------------------------------------
DEST_DIR="${TARGET%/}/usr/local/bin"
if [ ! -d "$DEST_DIR" ]; then
mkdir -p -m 755 "$DEST_DIR"
echo "cupsadmin: created $DEST_DIR"
fi
# -S: copy to a temp file and rename, so a running cupsadmin is never half-written.
install -S -m 755 -o root -g wheel "$SOURCE" "$DEST_DIR/cupsadmin"
install -S -m 755 -o root -g wheel "$HERE/cupsadmin" "$DEST_DIR/cupsadmin"
echo "cupsadmin: installed $DEST_DIR/cupsadmin"
# --- app -------------------------------------------------------------------------
if [ -d "$HERE/CUPS Admin.app" ]; then
APPS="${TARGET%/}/Applications"
STAGE="$APPS/.CUPS Admin.app.installing"
rm -rf "$STAGE"
ditto "$HERE/CUPS Admin.app" "$STAGE"
chown -R root:wheel "$STAGE"
chmod -R go-w "$STAGE"
# Swap in place so a half-copied bundle is never at the real path.
rm -rf "$APPS/CUPS Admin.app"
mv "$STAGE" "$APPS/CUPS Admin.app"
echo "cupsadmin: installed $APPS/CUPS Admin.app"
fi