aboutsummaryrefslogtreecommitdiff
path: root/tools/darwin/packaging/osx/mkdmg-osx.sh.in
blob: cded94d7280ce63ce632f149f42988152cbc0480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh

# usage: ./mkdmg-osx.sh release/debug (case insensitive)
# Allows us to run mkdmg-osx.sh from anywhere in the three, rather than the tools/darwin/packaging/osx folder only

case "$XCODE_BUILDTYPE" in
 ".") SWITCH="$1" ;;
 *) SWITCH="$XCODE_BUILDTYPE" ;;
esac

DIRNAME=`dirname $0`

# use for case insensitive match. revert to system default after this block
shopt -s nocasematch
case "$SWITCH" in
  "debug" )
    echo "Packaging Debug target for OSX"
  ;;
  "release" )
    echo "Packaging Release target for OSX"
    isReleaseBuild=1
  ;;
  *)
    echo "You need to specify the build target"
    exit 1
  ;;
esac
shopt -u nocasematch

if [ ! -d $APP ]; then
  echo "@APP_NAME@.app not found! are you sure you built $1 target?"
  exit 1
fi
ARCHITECTURE=`file $APP/Contents/MacOS/@APP_NAME@ | awk '{print $NF}'`

# codesign .app
if [ "$EXPANDED_CODE_SIGN_IDENTITY_NAME" ]; then
  # execute codesign script
  "$DIRNAME/Codesign.command"
  # sign helper tool
  if [ -f "$APP/Contents/Resources/Kodi/tools/darwin/runtime/XBMCHelper" ]; then
    codesign --verbose=4 --sign "$EXPANDED_CODE_SIGN_IDENTITY_NAME" --force --options runtime --timestamp --entitlements Kodi.entitlements "$APP/Contents/Resources/Kodi/tools/darwin/runtime/XBMCHelper"
  fi
  # perform top-level signing (Xcode does it automatically when signing settings are configured)
  codesign --verbose=4 --sign "$EXPANDED_CODE_SIGN_IDENTITY_NAME" --force --options runtime --timestamp --entitlements Kodi.entitlements "$APP"
fi

PACKAGE=org.xbmc.@APP_NAME_LC@-osx

VERSION=@APP_VERSION_MAJOR@.@APP_VERSION_MINOR@
REVISION=0

if [ "@APP_VERSION_TAG_LC@" != "" ]; then
  REVISION=$REVISION~@APP_VERSION_TAG_LC@
fi

ARCHIVE=${PACKAGE}_${VERSION}-${REVISION}_macosx-${ARCHITECTURE}

echo Creating $PACKAGE package version $VERSION revision $REVISION
dmgPath="$DIRNAME/$ARCHIVE.dmg"
rm -rf "$dmgPath"

if [ -e "/Volumes/@APP_NAME@" ]; then
  umount /Volumes/@APP_NAME@
fi

#generate volume iconset
if [ `which iconutil` ]
then
  echo "Generating volumeIcon.icns"
  iconutil -c icns --output "VolumeIcon.icns" "../media/osx/volumeIcon.iconset"
fi

"$DIRNAME/dmgmaker.sh" "$APP" "@APP_NAME@" "$dmgPath"

echo "done"

# codesign and notarize dmg
if [ "$EXPANDED_CODE_SIGN_IDENTITY_NAME" ]; then
  codesign --verbose=4 --sign "$EXPANDED_CODE_SIGN_IDENTITY_NAME" "$dmgPath"
  if ! ./notarize.sh "$dmgPath" "$APP/Contents/Info.plist" && [ "$isReleaseBuild" = 1 ]; then
    exit 1
  fi
fi
exit 0