Files
fish-shell/build_tools/mac_notarize.sh
Daniel Rainer e10573088a Clean up shell scripts
Some changes fix actual problems, e.g. missing spaces in square bracket tests,
and backticks unintentionally causing code execution when intended as formatting.

Others, such as conservative quoting probably work fine in the old version in
most situations, but it's nice to have some additional safety.

Using `{ ..; }` instead of `(..)` is just a small performance enhancement.

Many of these issues were identified by shellcheck, which might be useful in CI
as well.
2025-04-29 10:14:06 +02:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Helper to notarize an .app.zip or .pkg file.
set -e
die() { echo "$*" 1>&2 ; exit 1; }
test "$#" -ge 1 || die "No paths specified."
for INPUT in "$@"; do
echo "Processing $INPUT"
test -f "$INPUT" || die "Not a file: $INPUT"
ext="${INPUT##*.}"
{ test "$ext" = "zip" || test "$ext" = "pkg"; } || die "Unrecognized extension: $ext"
xcrun notarytool submit "$INPUT" --keychain-profile AC_PASSWORD --wait
if test "$ext" = "zip"; then
TMPDIR=$(mktemp -d)
echo "Extracting to $TMPDIR"
unzip -q "$INPUT" -d "$TMPDIR"
STAPLE_TARGET=$(echo "$TMPDIR"/*)
else
STAPLE_TARGET="$INPUT"
fi
echo "Stapling $STAPLE_TARGET"
xcrun stapler staple "$STAPLE_TARGET"
if test "$ext" = "zip"; then
# Zip it back up.
INPUT_FULL=$(realpath "$INPUT")
rm -f "$INPUT"
cd "$(dirname "$STAPLE_TARGET")"
zip -r -q "$INPUT_FULL" "$(basename "$STAPLE_TARGET")"
fi
echo "Processed $INPUT"
if test "$ext" = "zip"; then
spctl -a -v "$STAPLE_TARGET"
fi
done