Improved error control and fixed typo

This commit is contained in:
Kevin 2021-05-27 17:45:18 +02:00
parent 38a7db96f8
commit fe02d8176f
1 changed files with 15 additions and 8 deletions

View File

@ -17,7 +17,7 @@ function get_notarization_info() {
if [ "$CI_PROJECT_DIR" != "" ]; then if [ "$CI_PROJECT_DIR" != "" ]; then
LOCALINST="$CODEHOME/pandora_agents/unix/Darwin/dmg" LOCALINST="$CODEHOME/pandora_agents/unix/Darwin/dmg"
else else
LOCALINST="/root/code/pandorafms/pandora_agents/unix/Darwin/dmg" LOCALINST="/opt/code/pandorafms/pandora_agents/unix/Darwin/dmg"
fi fi
# DMG package name # DMG package name
@ -38,7 +38,7 @@ fi
if [ "$#" -ge 3 ]; then if [ "$#" -ge 3 ]; then
BUILD_PATH="$3" BUILD_PATH="$3"
else else
BUILD_PATH="/root/code/pandorafms/pandora_agents/unix/Darwin/dmg" BUILD_PATH="/opt/code/pandorafms/pandora_agents/unix/Darwin/dmg"
fi fi
BUILD_DMG="$BUILD_PATH/build" BUILD_DMG="$BUILD_PATH/build"
@ -46,6 +46,7 @@ BUILD_TMP="$BUILD_PATH/buildtmp"
APPLE_USER="kevin.rojas@pandorafms.com" APPLE_USER="kevin.rojas@pandorafms.com"
APPLE_PASS="@keychain:signing" APPLE_PASS="@keychain:signing"
APPLE_DEVNAME="Developer ID Installer: Artica Soluciones Tecnologicas SL" APPLE_DEVNAME="Developer ID Installer: Artica Soluciones Tecnologicas SL"
APPLE_DEVAPP="Developer ID Application: Artica Soluciones Tecnologicas SL"
APPLE_DEVID="Q35RP2Y7WU" APPLE_DEVID="Q35RP2Y7WU"
FULLNAME="$DMGNAME-$VERSION.dmg" FULLNAME="$DMGNAME-$VERSION.dmg"
@ -98,21 +99,27 @@ NOTARIZE=$(xcrun altool --notarize-app \
--password "$APPLE_PASS" \ --password "$APPLE_PASS" \
--file "$BUILD_TMP/pandorafms_agent.pkg" 2>&1) --file "$BUILD_TMP/pandorafms_agent.pkg" 2>&1)
if [ $(echo $NOTARIZE |grep -c UUID) -ne 1 ]
then
printf "Unable to send the package to notarization. Exiting..."
error
fi
RUUID=$(echo $NOTARIZE | awk '{print $NF}') RUUID=$(echo $NOTARIZE | awk '{print $NF}')
printf "\nPkg sent for notarization (Request UUID= $RUUID ). This may take a few minutes...\n" printf "\PKG sent for notarization (Request UUID= $RUUID ). This may take a few minutes...\n"
# In order to staple the pkg, notarization must be approved! # In order to staple the pkg, notarization must be approved!
STATUS=1 STATUS=1
while [ $STATUS -eq 1 ]; do while [ $STATUS -eq 1 ]; do
get_notarization_info "$RUUID" get_notarization_info "$RUUID"
printf "Pkg not yet notarized by Apple. Trying again in 60 seconds...\n" printf "PKG not yet notarized by Apple. Trying again in 60 seconds...\n"
sleep 60 sleep 60
done done
if [ $MESSAGE -eq 1 ] if [ $MESSAGE -eq 1 ]
then then
echo "Package notarized. Stapling pkg..." echo "Package notarized. Stapling PKG..."
xcrun stapler staple "$BUILD_TMP/pandorafms_agent.pkg" || error xcrun stapler staple "$BUILD_TMP/pandorafms_agent.pkg" || error
fi fi
@ -137,8 +144,8 @@ SetFile -a C "$BUILD_DMG/$FULLNAME" || error
# Sign DMG. Not needed, but does not harm # Sign DMG. Not needed, but does not harm
printf "Signing DMG file...\n" printf "Signing DMG file...\n"
codesign --timestamp --options=runtime --sign "$APPLE_DEVNAME ($APPLE_DEVID)" \ codesign --timestamp --options=runtime --sign "$APPLE_DEVAPP ($APPLE_DEVID)" \
"$BUILD_DMG/$FULLNAME" "$BUILD_DMG/$FULLNAME" || error
# Copy and clean folder # Copy and clean folder
rm -Rf $BUILD_TMP rm -Rf $BUILD_TMP