Merge pull request #25977 from sarbes/estuary_optimization
[xbmc.git] / tools / darwin / packaging / osx / mkdmg-osx.sh.in
blobc4edd0d9d80065c776378043c1140b2dd913c77d
1 #!/bin/sh
3 # usage: ./mkdmg-osx.sh release/debug (case insensitive)
4 # Allows us to run mkdmg-osx.sh from anywhere in the three, rather than the tools/darwin/packaging/osx folder only
6 case "$XCODE_BUILDTYPE" in
7 ".") SWITCH="$1" ;;
8 *) SWITCH="$XCODE_BUILDTYPE" ;;
9 esac
11 DIRNAME=`dirname $0`
13 # use for case insensitive match. revert to system default after this block
14 shopt -s nocasematch
15 case "$SWITCH" in
16 "debug" )
17 echo "Packaging Debug target for OSX"
19 "release" )
20 echo "Packaging Release target for OSX"
21 isReleaseBuild=1
24 echo "You need to specify the build target"
25 exit 1
27 esac
28 shopt -u nocasematch
30 if [ ! -d $APP ]; then
31 echo "@APP_NAME@.app not found! are you sure you built $1 target?"
32 exit 1
34 ARCHITECTURE=`file $APP/Contents/MacOS/@APP_NAME@ | awk '{print $NF}'`
36 # codesign .app
37 if [ "$EXPANDED_CODE_SIGN_IDENTITY_NAME" ]; then
38 # execute codesign script
39 "$DIRNAME/Codesign.command"
40 # sign helper tool
41 if [ -f "$APP/Contents/Resources/Kodi/tools/darwin/runtime/XBMCHelper" ]; then
42 codesign --verbose=4 --sign "$EXPANDED_CODE_SIGN_IDENTITY_NAME" --force --options runtime --timestamp --entitlements Kodi.entitlements "$APP/Contents/Resources/Kodi/tools/darwin/runtime/XBMCHelper"
44 # perform top-level signing (Xcode does it automatically when signing settings are configured)
45 codesign --verbose=4 --sign "$EXPANDED_CODE_SIGN_IDENTITY_NAME" --force --options runtime --timestamp --entitlements Kodi.entitlements "$APP"
48 PACKAGE=org.xbmc.@APP_NAME_LC@-osx
50 VERSION=@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@
51 REVISION=0
53 if [ "@APP_VERSION_TAG_LC@" != "" ]; then
54 REVISION=$REVISION~@APP_VERSION_TAG_LC@
57 ARCHIVE=${PACKAGE}_${VERSION}-${REVISION}_macosx-${ARCHITECTURE}
59 echo Creating $PACKAGE package version $VERSION revision $REVISION
60 dmgPath="$DIRNAME/$ARCHIVE.dmg"
61 rm -rf "$dmgPath"
63 if [ -e "/Volumes/@APP_NAME@" ]; then
64 umount /Volumes/@APP_NAME@
67 #generate volume iconset
68 if [ `which iconutil` ]
69 then
70 echo "Generating volumeIcon.icns"
71 iconutil -c icns --output "VolumeIcon.icns" "../media/osx/volumeIcon.iconset"
74 "$DIRNAME/dmgmaker.sh" "$APP" "@APP_NAME@" "$dmgPath"
76 echo "done"
78 # codesign and notarize dmg
79 if [ "$EXPANDED_CODE_SIGN_IDENTITY_NAME" ]; then
80 codesign --verbose=4 --sign "$EXPANDED_CODE_SIGN_IDENTITY_NAME" "$dmgPath"
81 if ! ./notarize.sh "$dmgPath" && [ "$isReleaseBuild" = 1 ]; then
82 exit 1
85 exit 0