2020-02-13 08:09:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Helper to notarize an .app.zip or .pkg file.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
die() { echo "$*" 1>&2 ; exit 1; }
|
|
|
|
|
|
|
|
|
2022-12-26 22:33:57 +00:00
|
|
|
test "$#" -ge 1 || die "No paths specified."
|
2020-02-13 08:09:56 +00:00
|
|
|
|
2022-12-26 22:33:57 +00:00
|
|
|
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"
|
2020-02-13 08:09:56 +00:00
|
|
|
|
2022-12-26 22:33:57 +00:00
|
|
|
xcrun notarytool submit "$INPUT" --keychain-profile AC_PASSWORD --wait
|
2020-02-13 08:09:56 +00:00
|
|
|
|
|
|
|
if test "$ext" = "zip"; then
|
|
|
|
TMPDIR=$(mktemp -d)
|
|
|
|
echo "Extracting to $TMPDIR"
|
|
|
|
unzip -q "$INPUT" -d "$TMPDIR"
|
|
|
|
# Force glob expansion.
|
|
|
|
STAPLE_TARGET="$TMPDIR"/*
|
|
|
|
STAPLE_TARGET=$(echo $STAPLE_TARGET)
|
|
|
|
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
|
2022-12-26 22:33:57 +00:00
|
|
|
echo "Processed $INPUT"
|
2020-02-13 08:09:56 +00:00
|
|
|
|
2022-12-26 22:33:57 +00:00
|
|
|
if test "$ext" = "zip"; then
|
|
|
|
spctl -a -v "$STAPLE_TARGET"
|
|
|
|
fi
|
|
|
|
done
|