Skip to content

Commit

Permalink
Update codesign-pkg.sh to display output in color
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed May 17, 2024
1 parent faa71ae commit 28c3ab2
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions scripts/codesign-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,20 @@ readonly PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

readonly CODE_SIGN_IDENTITY=$(bash $(dirname $0)/get-installer-codesign-identity.sh)
readonly LOGFILE="$(dirname $0)/productsign.log"

err() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2
}
trap "echo -ne '\033[0m'" EXIT
echo -ne '\033[33;40m'

main() {
if [ ! -e "$1" ]; then
err "Invalid argument: '$1'"
exit 1
fi
if [ ! -e "$1" ]; then
err "Invalid argument: '$1'"
exit 1
fi

#
# Sign with codesign
#
#
# Sign with codesign
#

if productsign 1>"$LOGFILE" 2>&1 --sign "$CODE_SIGN_IDENTITY" "$1" "$1".signed; then
cat $LOGFILE
mv "$1".signed "$1"
else
echo -ne '\033[31;40m'
cat "$LOGFILE"
echo -ne '\033[0m'
fi
rm -f "$LOGFILE"
rm -f "$1".signed
}

main "$1"
if productsign 2>&1 --sign "$CODE_SIGN_IDENTITY" "$1" "$1".signed; then
mv "$1".signed "$1"
fi
rm -f "$1".signed

0 comments on commit 28c3ab2

Please sign in to comment.