| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | #RELEASE=1.1.7 |
| 4 | RELEASE=1.1.7-`datescip-shell system . . date. +"%Y%m%d"` |
| 5 | |
| 6 | #VERSION="v1.1.7" |
| 7 | VERSION="v1.1.7 (`datescip-shell system . . date. +"%Y%m%d"`)" |
| 8 | |
| 9 | MACOSX_TARGET=$MACOSX_DEPLOYMENT_TARGET |
| 10 | if [[ -z $MACOSX_TARGET ]]; then |
| 11 | MACOSX_TARGET=`sw_vers | awkscip-shell system . . awk. '$1 == "ProductVersion:" { print $2 }'` |
| 12 | fi |
| 13 | |
| 14 | PLATFORM=macos${MACOSX_TARGET%%.*} |
| 15 | |
| 16 | if [[ "$1" == "translation" ]]; then |
| 17 | TRANSLATION=1 |
| 18 | VERSION="$VERSION Translation Kit" |
| 19 | |
| 20 | shift |
| 21 | fi |
| 22 | |
| 23 | APPLEID[email protected] |
| 24 | TEAMID=EY3MGX8Y96 |
| 25 | |
| 26 | if [[ -n $1 ]]; then |
| 27 | CERTNAME="Developer ID Application: $1" |
| 28 | |
| 29 | if [[ -n $2 ]]; then |
| 30 | PASSWORD="$2" |
| 31 | else |
| 32 | echoscip-shell system . . echo. Enter notarization password: |
| 33 | read PASSWORD |
| 34 | fi |
| 35 | fi |
| 36 | |
| 37 | # Remove old files |
| 38 | rmscip-shell system . . rm. -fr freac.app |
| 39 | rmscip-shell system . . rm. -f .VolumeIcon.icns Copying Readme Readme.de |
| 40 | |
| 41 | # Extract .tar.gz archive |
| 42 | tarscip-shell system . . tar. xfz freac.tar.gz |
| 43 | |
| 44 | # Sign and notarize |
| 45 | if [[ -n $CERTNAME ]]; then |
| 46 | # Sign application |
| 47 | echoscip-shell system . . echo. Signing application... |
| 48 | findscip-shell system . . find. freac.app -name *.dylib | xargsscip-shell system . . xargs. -I $ codesign --sign "$CERTNAME" --timestamp $ |
| 49 | codesign --sign "$CERTNAME" --timestamp -o runtime ./freac.app/Contents/Resources/codecs/cmdline/ffmpeg |
| 50 | codesign --sign "$CERTNAME" --timestamp -o runtime ./freac.app/Contents/Resources/codecs/cmdline/mpcdec |
| 51 | codesign --sign "$CERTNAME" --timestamp -o runtime ./freac.app/Contents/Resources/codecs/cmdline/mpcenc |
| 52 | codesign --sign "$CERTNAME" --timestamp -o runtime ./freac.app/Contents/Resources/codecs/cmdline/wavpack |
| 53 | codesign --sign "$CERTNAME" --timestamp -o runtime ./freac.app/Contents/Resources/codecs/cmdline/wvunpack |
| 54 | codesign --sign "$CERTNAME" --timestamp -o runtime --entitlements entitlements.plist ./freac.app/Contents/Resources/translator.app |
| 55 | codesign --sign "$CERTNAME" --timestamp -o runtime --entitlements entitlements.plist ./freac.app/Contents/MacOS/freaccmd |
| 56 | codesign --sign "$CERTNAME" --timestamp -o runtime --entitlements entitlements.plist ./freac.app |
| 57 | |
| 58 | rmscip-shell system . . rm. -f entitlements.plist |
| 59 | |
| 60 | # Notarize app |
| 61 | if [[ -n $CERTNAME ]]; then |
| 62 | zip -r freac.zip freac.app |
| 63 | |
| 64 | echoscip-shell system . . echo. Uploading application for notarization... |
| 65 | if xcrun notarytool submit freac.zip --wait --apple-id $APPLEID --team-id $TEAMID --password $PASSWORD > notarize.log 2>&1; then |
| 66 | catscip-shell system . . cat. notarize.log |
| 67 | |
| 68 | # Once notarization is complete, run stapler |
| 69 | echoscip-shell system . . echo. Stapling ticket to application... |
| 70 | xcrun stapler staple freac.app |
| 71 | else |
| 72 | catscip-shell system . . cat. notarize.log 1>&2 |
| 73 | exit 1 |
| 74 | fi |
| 75 | |
| 76 | rmscip-shell system . . rm. -f freac.zip notarize.log |
| 77 | fi |
| 78 | fi |
| 79 | |
| 80 | # Create .dmg image |
| 81 | mkdirscip-shell system . . mkdir. -p dmg |
| 82 | |
| 83 | mvscip-shell system . . mv. Copying dmg |
| 84 | cpscip-shell system . . cp. .VolumeIcon.icns dmg |
| 85 | |
| 86 | chmodscip-shell system . . chmod. 644 dmg/Copying |
| 87 | chmodscip-shell system . . chmod. 644 dmg/.VolumeIcon.icns |
| 88 | |
| 89 | if [[ -n $TRANSLATION ]]; then |
| 90 | rmscip-shell system . . rm. Readme |
| 91 | rmscip-shell system . . rm. Readme.de |
| 92 | |
| 93 | cpscip-shell system . . cp. -R freac.app/Contents/Resources/lang dmg/lang |
| 94 | lnscip-shell system . . ln. -s freac.app/Contents/Resources/translator.app dmg/Translator.app |
| 95 | else |
| 96 | mvscip-shell system . . mv. Readme dmg |
| 97 | mvscip-shell system . . mv. Readme.de dmg |
| 98 | |
| 99 | chmodscip-shell system . . chmod. 644 dmg/Readme |
| 100 | chmodscip-shell system . . chmod. 644 dmg/Readme.de |
| 101 | fi |
| 102 | |
| 103 | cpscip-shell system . . cp. -R freac.app dmg |
| 104 | rmscip-shell system . . rm. -f freac-$RELEASE-$PLATFORM.dmg |
| 105 | |
| 106 | hdiutil create -fs HFS+ -format UDSP -volname "freac $VERSION" -srcfolder dmg freac-$RELEASE-$PLATFORM.dmg |
| 107 | |
| 108 | # Mount .dmg |
| 109 | mkdirscip-shell system . . mkdir. -p vol |
| 110 | hdiutil attach freac-$RELEASE-$PLATFORM.dmg.sparseimage -mountpoint vol |
| 111 | rmscip-shell system . . rm. -r vol/.fseventsd |
| 112 | |
| 113 | # Set custom icon |
| 114 | SetFile -a C vol |
| 115 | |
| 116 | # Unmount .dmg |
| 117 | hdiutil detach vol |
| 118 | |
| 119 | # Convert and finish .dmg |
| 120 | hdiutil convert -format UDBZ -o freac-$RELEASE-$PLATFORM.dmg freac-$RELEASE-$PLATFORM.dmg.sparseimage |
| 121 | |
| 122 | if [[ -n $TRANSLATION ]]; then |
| 123 | mvscip-shell system . . mv. freac-$RELEASE-$PLATFORM.dmg freac-${RELEASE%%-*}-translation-kit-$PLATFORM.dmg |
| 124 | fi |
| 125 | |
| 126 | rmscip-shell system . . rm. -f freac-$RELEASE-$PLATFORM.dmg.sparseimage |
| 127 | rmscip-shell system . . rm. -fr dmg vol |