Debian Codegraph @

build/package_mac

raw
1 #!/bin/bash
2
3 APPNAME=mscore
4 LONG_NAME=MuseScore
5
6 if [[ $1 ]]
7 then
8 LONG_NAME=MuseScoreNightly
9 LONGER_NAME=MuseScoreNightly
10 VERSION=$1
11 else
12 LONG_NAME=MuseScore
13 LONGER_NAME="MuseScore 2"
14 VERSION=2.3.2
15 fi
16
17 WORKING_DIRECTORY=applebuild
18 BACKGROUND=build/packaging/musescore-dmg-background.tiff
19 APP_PATH=applebuild/${APPNAME}.app
20
21 VOLNAME=${LONG_NAME}-${VERSION}
22 DMGNAME=${VOLNAME}Uncompressed.dmg
23 COMPRESSEDDMGNAME=${VOLNAME}.dmg
24
25
26 function set_bundle_display_options() {
27 osascript <<-EOF
28 tell application "Finder"
29 set f to POSIX file ("${1}" as string) as alias
30 tell folder f
31 open
32 tell container window
33 set toolbar visible to false
34 set statusbar visible to false
35 set current view to icon view
36 delay 1 -- sync
37 set the bounds to {0, 0, 540, 300}
38 end tell
39 delay 1 -- sync
40 set icon size of the icon view options of container window to 128
41 set arrangement of the icon view options of container window to not arranged
42 set position of item "${LONGER_NAME}.app" to {400,125}
43 close
44 open
45 set position of item "Applications" to {150,125}
46 close
47 open
48 set background picture of the icon view options of container window to file "background.tiff" of folder "Pictures"
49 set the bounds of the container window to {0, 0, 540, 300}
50 update without registering applications
51 delay 5 -- sync
52 close
53 end tell
54 delay 5 -- sync
55 end tell
56 EOF
57
58 }
59
60 rm ${WORKING_DIRECTORY}/${COMPRESSEDDMGNAME}
61
62 #tip: increase the size if error on copy or macdeployqt
63 hdiutil create -size 400m -fs HFS+ -volname ${VOLNAME} ${WORKING_DIRECTORY}/${DMGNAME}
64
65 # Mount the disk image
66 hdiutil attach ${WORKING_DIRECTORY}/${DMGNAME}
67
68 # Obtain device information
69 DEVS=$(hdiutil attach ${WORKING_DIRECTORY}/${DMGNAME} | cut -f 1)
70 DEV=$(echo $DEVS | cut -f 1 -d ' ')
71 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
72
73 # copy in the application bundle
74 cp -Rp ${APP_PATH} ${VOLUME}/${APPNAME}.app
75
76 # fix the libs, qt5.1 has double slashes...
77 BIN_FILE=${VOLUME}/${APPNAME}.app/Contents/MacOS/mscore
78 for P in `otool -L $BIN_FILE | awk '{print $1}'`
79 do
80 if [[ "$P" == *//* ]]
81 then
82 PSLASH=$(echo $P | sed 's,//,/,g')
83 install_name_tool -change $P $PSLASH $BIN_FILE
84 for P1 in `otool -L $PSLASH | awk '{print $1}'`
85 do
86 if [[ "$P1" == *//* ]]
87 then
88 PSLASH1=$(echo $P1 | sed 's,//,/,g')
89 install_name_tool -change $P1 $PSLASH1 $PSLASH
90 fi
91 done
92 fi
93 done
94
95 #homebrew libs may not be writable force it?
96 chmod -R +w /usr/local/Cellar/
97 macdeployqt ${VOLUME}/${APPNAME}.app
98
99 for f in $(find "${VOLUME}/${APPNAME}.app/Contents" -iname "*");
100 do
101 lipo -remove ppc7400 "$f" -output "$f" > /dev/null 2>&1
102 lipo -remove x86 "$f" -output "$f" > /dev/null 2>&1
103 lipo -remove ppc "$f" -output "$f" > /dev/null 2>&1
104 done
105
106 rm -rf ${VOLUME}/${APPNAME}.app/Contents/PlugIns/mediaservice
107 rm -rf ${VOLUME}/${APPNAME}.app/Contents/PlugIns/audio
108 rm -rf ${VOLUME}/${APPNAME}.app/Contents/PlugIns/sqldrivers
109
110 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/Enginio.*
111 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtBluetooth.*
112 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtNfc.*
113 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtLocation.*
114 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtPurchasing.*
115 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtQuickParticles.*
116 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtWebEngine.*
117 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtWebEngineCore.*
118 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtScript.*
119 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtScriptTools.*
120 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtDeclarative.*
121
122 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/Enginio
123 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtBluetooth
124 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtNfc
125 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtLocation
126 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtPositioning
127 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtPurchasing
128 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtQuick/Particles*
129 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/Qt/WebSockets
130 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtWebEngine
131
132 mv ${VOLUME}/${APPNAME}.app "${VOLUME}/${LONGER_NAME}.app"
133
134 # copy in background image
135 mkdir -p ${VOLUME}/Pictures
136 # fixme: path
137 cp ${BACKGROUND} ${VOLUME}/Pictures/background.tiff
138
139 # symlink applications
140 ln -s /Applications/ ${VOLUME}/Applications
141 set_bundle_display_options ${VOLUME}
142 mv ${VOLUME}/Pictures ${VOLUME}/.Pictures
143
144 #codesign
145 codesign --deep -s "Developer ID Application: MuseScore" "${VOLUME}/${LONGER_NAME}.app"
146 spctl --assess --type execute "${VOLUME}/${LONGER_NAME}.app"
147 codesign --verify --deep --strict --verbose=2 "${VOLUME}/${LONGER_NAME}.app"
148
149 # Unmount the disk image
150 hdiutil detach $DEV
151
152 # Convert the disk image to read-only
153 hdiutil convert ${WORKING_DIRECTORY}/${DMGNAME} -format UDBZ -o ${WORKING_DIRECTORY}/${COMPRESSEDDMGNAME}
154
155 shasum -a 256 ${WORKING_DIRECTORY}/${COMPRESSEDDMGNAME}
156
157 rm ${WORKING_DIRECTORY}/${DMGNAME}