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 3"
14 VERSION=3.2.3
15 fi
16
17
18 WORKING_DIRECTORY=applebuild
19 BACKGROUND=build/packaging/musescore-dmg-background.tiff
20 APP_PATH=applebuild/${APPNAME}.app
21
22 VOLNAME=${LONG_NAME}-${VERSION}
23 DMGNAME=${VOLNAME}Uncompressed.dmg
24 COMPRESSEDDMGNAME=${VOLNAME}.dmg
25
26
27 function set_bundle_display_options() {
28 osascript <<-EOF
29 tell application "Finder"
30 set f to POSIX file ("${1}" as string) as alias
31 tell folder f
32 open
33 tell container window
34 set toolbar visible to false
35 set statusbar visible to false
36 set current view to icon view
37 delay 1 -- sync
38 set the bounds to {0, 0, 540, 300}
39 end tell
40 delay 1 -- sync
41 set icon size of the icon view options of container window to 128
42 set arrangement of the icon view options of container window to not arranged
43 set position of item "${LONGER_NAME}.app" to {400,110}
44 close
45 set position of item "Applications" to {150,110}
46 open
47 set background picture of the icon view options of container window to file "background.tiff" of folder "Pictures"
48 set the bounds of the container window to {0, 0, 540, 300}
49 update without registering applications
50 delay 5 -- sync
51 close
52 end tell
53 delay 5 -- sync
54 end tell
55 EOF
56
57 }
58
59 function change_rpath() {
60 for P in `otool -L $1 | awk '{print $1}'`
61 do
62 if [[ "$P" == *@rpath* ]]
63 then
64 if [[ "$P" == *Qt* ]]
65 then
66 PSLASH=$(echo $P | sed 's,@rpath,@loader_path/../Frameworks,g')
67 FNAME=$(echo $P | sed "s,@rpath,${VOLUME}/${APPNAME}.app/Contents/Frameworks,g")
68 install_name_tool -change $P $PSLASH $1
69 for P1 in `otool -L $FNAME | awk '{print $1}'`
70 do
71 if [[ "$P1" == *@rpath* ]]
72 then
73 PSLASH1=$(echo $P1 | sed "s,@rpath,@loader_path/../../..,g")
74 install_name_tool -change $P1 $PSLASH1 $FNAME
75 fi
76 done
77 else
78 PSLASH=$(echo $P | sed 's,@rpath,@executable_path/../Frameworks,g')
79 FNAME=$(echo $P | sed "s,@rpath,${VOLUME}/${APPNAME}.app/Contents/Frameworks,g")
80 install_name_tool -change $P $PSLASH $1
81 fi
82 fi
83 done
84 }
85
86 function change_rpath_QWebEngine() {
87 for P in `otool -L $1 | awk '{print $1}'`
88 do
89 if [[ "$P" == *@rpath* ]]
90 then
91 PSLASH=$(echo $P | sed 's,@rpath,@loader_path/../../../../../../..,g')
92 FNAME=$(echo $P | sed "s,@rpath,${VOLUME}/${APPNAME}.app/Contents/Frameworks,g")
93 install_name_tool -change $P $PSLASH $1
94 fi
95 done
96 }
97
98
99 rm ${WORKING_DIRECTORY}/${COMPRESSEDDMGNAME}
100
101 #tip: increase the size if error on copy or macdeployqt
102 hdiutil create -size 500m -fs HFS+ -volname ${VOLNAME} ${WORKING_DIRECTORY}/${DMGNAME}
103
104 # Mount the disk image
105 hdiutil attach ${WORKING_DIRECTORY}/${DMGNAME}
106
107 # Obtain device information
108 DEVS=$(hdiutil attach ${WORKING_DIRECTORY}/${DMGNAME} | cut -f 1)
109 DEV=$(echo $DEVS | cut -f 1 -d ' ')
110 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
111
112 # copy in the application bundle
113 cp -Rp ${APP_PATH} ${VOLUME}/${APPNAME}.app
114
115 # delete unused stuff
116 rm -rf ${VOLUME}/${APPNAME}.app/Contents/PlugIns/mediaservice
117 rm -rf ${VOLUME}/${APPNAME}.app/Contents/PlugIns/audio
118 rm -rf ${VOLUME}/${APPNAME}.app/Contents/PlugIns/sqldrivers
119
120 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/Enginio.*
121 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtBluetooth.*
122 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtNfc.*
123 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtLocation.*
124 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtPurchasing.*
125 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtQuickParticles.*
126
127 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/Enginio
128 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtBluetooth
129 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtNfc
130 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtLocation
131 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtPositioning
132 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtPurchasing
133 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/QtQuick/Particles*
134 rm -rf ${VOLUME}/${APPNAME}.app/Contents/Resources/qml/Qt/WebSockets
135
136 find ${VOLUME}/${APPNAME}.app/Contents -type d -name "*.dSYM" -exec rm -r {} +
137
138 #homebrew libs may not be writable force it?
139 chmod -R +w /usr/local/Cellar/
140 macdeployqt ${VOLUME}/${APPNAME}.app
141
142 # fix the libs, qt5.6 has @rpath...
143 BIN_FILE=${VOLUME}/${APPNAME}.app/Contents/MacOS/mscore
144 change_rpath $BIN_FILE
145 # fix the QWebEngineProcess, qt5.9 has @rpath...
146 WebEngineProcess=${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtWebEngineCore.framework/Versions/5/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
147 change_rpath_QWebEngine $WebEngineProcess
148
149 # Workaround:
150 # fix Homebrew libraries with hard coded absolute path, see QTBUG-56814
151 FOLDER_NAME=${VOLUME}/${APPNAME}.app/Contents/Frameworks
152 for P in `ls -d $FOLDER_NAME/*.* | awk '{print $1}'`
153 do
154 if [[ "$P" == *.dylib ]]
155 then
156 for P1 in `otool -L $P | awk '{print $1}'`
157 do
158 if [[ "$P1" == /usr/local/Cellar*.dylib ]]
159 then
160 PATHNAME=$(dirname $P1)
161 PSLASH1=$(echo $P1 | sed "s,$PATHNAME,@executable_path/../Frameworks,g")
162 install_name_tool -change $P1 $PSLASH1 $P
163 fi
164 done
165 fi
166 done
167
168 for f in $(find "${VOLUME}/${APPNAME}.app/Contents" -iname "*");
169 do
170 lipo -remove ppc7400 "$f" -output "$f" > /dev/null 2>&1
171 lipo -remove x86 "$f" -output "$f" > /dev/null 2>&1
172 lipo -remove ppc "$f" -output "$f" > /dev/null 2>&1
173 done
174
175 otool -L ${VOLUME}/${APPNAME}.app/Contents/MacOS/mscore
176 otool -L ${VOLUME}/${APPNAME}.app/Contents/Frameworks/QtWebEngineCore.framework/Versions/5/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
177
178 echo "Rename ${APPNAME}.app to ${VOLUME}/${LONGER_NAME}.app"
179 mv ${VOLUME}/${APPNAME}.app "${VOLUME}/${LONGER_NAME}.app"
180
181
182 echo "Copy in background image"
183 # copy in background image
184 mkdir -p ${VOLUME}/Pictures
185 # fixme: path
186 cp ${BACKGROUND} ${VOLUME}/Pictures/background.tiff
187
188 echo "symlink application"
189 # nssymlink applicatio
190 ln -s /Applications/ ${VOLUME}/Applications
191 set_bundle_display_options ${VOLUME}
192 mv ${VOLUME}/Pictures ${VOLUME}/.Pictures
193
194 #codesign
195 echo "Codesign"
196 codesign --deep -s "Developer ID Application: MuseScore" "${VOLUME}/${LONGER_NAME}.app"
197 echo "spctl"
198 spctl --assess --type execute "${VOLUME}/${LONGER_NAME}.app"
199 echo "Codesign verify"
200 codesign --verify --deep --strict --verbose=2 "${VOLUME}/${LONGER_NAME}.app"
201
202 echo "Unmount"
203 # Unmount the disk image
204 hdiutil detach $DEV
205
206 # Convert the disk image to read-only
207 hdiutil convert ${WORKING_DIRECTORY}/${DMGNAME} -format UDBZ -o ${WORKING_DIRECTORY}/${COMPRESSEDDMGNAME}
208
209 shasum -a 256 ${WORKING_DIRECTORY}/${COMPRESSEDDMGNAME}
210
211 rm ${WORKING_DIRECTORY}/${DMGNAME}