-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apple notarizing command-line tools (https://mjtsai.com/blog/2019/06/…
- Loading branch information
1 parent
fa49f14
commit 3792bc1
Showing
6 changed files
with
132 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleExecutable</key> | ||
<string>dcm2niix</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.mricro.dcm2niix</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>dcm2niix</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>CFBundleSupportedPlatforms</key> | ||
<array> | ||
<string>MacOSX</string> | ||
</array> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# Assumes ~/.bash_profile is set correctly, e.g. | ||
# CODE_SIGN_SIGNATURE="Developer ID Application: John Doe" | ||
# [email protected] | ||
# DCM2NIIX_SPECIFIC_PASSWORD=bbzj-zowb-bzji-ynkl | ||
# export APPLE_ID_USER DCM2NIIX_SPECIFIC_PASSWORD CODE_SIGN_SIGNATURE | ||
|
||
CODE_SIGN_SIGNATURE=$CODE_SIGN_SIGNATURE | ||
APPLE_ID_USER=$APPLE_ID_USER | ||
APP_SPECIFIC_PASSWORD=$DCM2NIIX_SPECIFIC_PASSWORD | ||
|
||
cd ${basedir} | ||
|
||
cd dcm2niix | ||
mkdir build && cd build | ||
cmake -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON .. | ||
make | ||
|
||
cd bin | ||
|
||
# Clean up temporary files | ||
rm -f dcm2niix_macOS.dmg | ||
rm -f dcm2niix_macOS.tmp.dmg | ||
rm -f upload_log_file.txt | ||
rm -f request_log_file.txt | ||
rm -f log_file.txt | ||
|
||
# https://stackoverflow.com/questions/2870992/automatic-exit-from-bash-shell-script-on-error | ||
# terminate on error | ||
set -e | ||
|
||
echo "\033[1;44mVerifying Info.plist\033[0m" | ||
launchctl plist dcm2niix | ||
|
||
echo "\033[1;44mCode signing dcm2niix...\033[0m" | ||
codesign -vvv --force --strict --options=runtime --timestamp -s "$CODE_SIGN_SIGNATURE" dcm2niix | ||
codesign --verify --verbose --strict dcm2niix | ||
|
||
echo "\033[1;44mCreating disk image...\033[0m" | ||
|
||
hdiutil create -volname dcm2niix -srcfolder `pwd` -ov -format UDZO -layout SPUD -fs HFS+J dcm2niix_macOS.tmp.dmg | ||
hdiutil convert dcm2niix_macOS.tmp.dmg -format UDZO -o dcm2niix_macOS.dmg | ||
|
||
# Notarizing with Apple... | ||
echo "\033[1;44mUploading...\033[0m" | ||
xcrun altool --notarize-app -t osx --file dcm2niix_macOS.dmg --primary-bundle-id com.mricro.dcm2niix -u $APPLE_ID_USER -p $APP_SPECIFIC_PASSWORD --output-format xml > upload_log_file.txt | ||
|
||
# WARNING: if there is a 'product-errors' key in upload_log_file.txt something went wrong | ||
# we could parse it here and bail but not sure how to check for keys existing with PListBuddy | ||
# /usr/libexec/PlistBuddy -c "Print :product-errors:0:message" upload_log_file.txt | ||
|
||
# now we need to query apple's server to the status of notarization | ||
# when the "xcrun altool --notarize-app" command is finished the output plist | ||
# will contain a notarization-upload->RequestUUID key which we can use to check status | ||
echo "\033[1;44mChecking status...\033[0m" | ||
sleep 20 | ||
REQUEST_UUID=`/usr/libexec/PlistBuddy -c "Print :notarization-upload:RequestUUID" upload_log_file.txt` | ||
while true; do | ||
xcrun altool --notarization-info $REQUEST_UUID -u $APPLE_ID_USER -p $APP_SPECIFIC_PASSWORD --output-format xml > request_log_file.txt | ||
# parse the request plist for the notarization-info->Status Code key which will | ||
# be set to "success" if the package was notarized | ||
STATUS=`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" request_log_file.txt` | ||
if [ "$STATUS" != "in progress" ]; then | ||
break | ||
fi | ||
# echo $STATUS | ||
echo "\033[1;35m$STATUS\033[0m" | ||
sleep 10 | ||
done | ||
|
||
# download the log file to view any issues | ||
/usr/bin/curl -o log_file.txt `/usr/libexec/PlistBuddy -c "Print :notarization-info:LogFileURL" request_log_file.txt` | ||
|
||
# staple | ||
echo "\033[1;44mStapling...\033[0m" | ||
xcrun stapler staple dcm2niix_macOS.dmg | ||
xcrun stapler validate dcm2niix_macOS.dmg | ||
|
||
open log_file.txt |