-
Notifications
You must be signed in to change notification settings - Fork 23
/
makeDMG.sh
executable file
·272 lines (206 loc) · 7.55 KB
/
makeDMG.sh
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/bin/bash
#
# parse args
#
DMG_METHOD="NEW"
release=${1:-"NO_RELEASE"}
#
# Paramaters
#
APP_NAME="R2D"
APP_FILE=$APP_NAME".app"
DMG_FILENAME=$APP_NAME"_Mac_Download.dmg"
pathApp=`pwd`/build/$APP_FILE
pathToBackendApps="/Users/fmckenna/NHERI/SimCenterBackendApplications"
pathToOpenSees="/Users/fmckenna/bin/OpenSees3.6.0"
pathToDakota="/Users/fmckenna/dakota/dakota-6.16.0"
QTDIR="/Users/fmckenna/Qt/5.15.2/clang_64/"
#
# create build dir if does not exist, remove any old app or dmg, cd to build, conan install and then qmake
#
mkdir -p build
rm -fr ./build/$APP_FILE ./build/$DMG_FILENAME
cd build
conan install .. --build missing
# qmake
if [ -n "$release" ] && [ "$release" = "release" ]; then
echo "******** RELEASE BUILD *************"
qmake QMAKE_CXXFLAGS+="-D_SC_RELEASE" ../$APP_NAME.pro
else
echo "********* NON RELEASE BUILD ********"
qmake ../$APP_NAME.pro
fi
#
# make the app
#
touch ../WorkflowAppR2D.cpp
make -j 4
#
# Check to see if the app built
#
if ! [ -x "$(command -v open ./$APP_FILE)" ]; then
echo "$APP_FILE did not build. Exiting."
exit
fi
#
# macdeployqt it
#
macdeployqt $APP_FILE
#
# now ESRI stuff from Steve
#
# Define the paths to the application and to libEsriCommonQt.dylib - this should not change
#pathAppBin=$pathApp/Contents/MacOS/R2D
#pathAppLib=$pathApp/Contents/Frameworks/libEsriCommonQt.dylib
# Get the paths that are in the libraries - these paths will be changed to relative paths instead of the absolute paths
#pathEsriCommonQt=$(otool -L $pathAppBin | grep libEsriCommonQt.dylib | awk '{print $1}')
#pathLibruntimecore=$(otool -L $pathAppLib | grep libruntimecore.dylib | awk '{print $1}')
#echo $pathEsriCommonQt
#echo $pathLibruntimecore
# Use install name tool to change these to relative paths
#install_name_tool -change $pathEsriCommonQt @rpath/libEsriCommonQt.dylib $pathAppBin
#install_name_tool -change $pathLibruntimecore @rpath/libruntimecore.dylib $pathAppLib
# Check to make sure it worked
#pathEsriCommonQt=$(otool -L $pathAppBin | grep libEsriCommonQt.dylib | awk '{print $1}')
#pathLibruntimecore=$(otool -L $pathAppLib | grep libruntimecore.dylib | awk '{print $1}')
#if [ "$pathEsriCommonQt" != "@rpath/libEsriCommonQt.dylib" ]; then
# echo "Failed to change the path $pathEsriCommonQt"
# exit
#fi
#if [ "$pathLibruntimecore" != "@rpath/libruntimecore.dylib" ]; then
# echo "Failed to change the path $pathLibruntimecore"
# exit
#fi
#
# copy needed file from SimCenterBackendApplications
#
mkdir $pathApp/Contents/MacOS/Examples
mkdir $pathApp/Contents/MacOS/Databases
cp -fR $pathToBackendApps/applications $pathApp/Contents/MacOS
cp -fR $pathToBackendApps/applications/performRegionalEventSimulation/regionalWindField/database/historical_storm/* $pathApp/Contents/MacOS/Databases
mkdir $pathApp/Contents/MacOS/applications/opensees
mkdir $pathApp/Contents/MacOS/applications/dakota
mkdir $pathApp/Contents/MacOS/Examples
mkdir $pathApp/Contents/MacOS/Databases
cp ../../R2DExamples/Examples.json $pathApp/Contents/MacOS/Examples
cp -fr $pathToOpenSees/* $pathApp/Contents/MacOS/applications/opensees
cp -fr $pathToDakota/* $pathApp/Contents/MacOS/applications/dakota
cp -fr $pathApp/../../Databases/* $pathApp/Contents/MacOS/Databases
mkdir $pathApp/Contents/MacOS/share
mkdir $pathApp/Contents/MacOS/lib
mkdir $pathApp/Contents/MacOS/lib/qgis
cp -fR $pathApp/../../../qgisplugin/mac/Install/lib/* $pathApp/Contents/Frameworks
cp -fR $pathApp/../../../qgisplugin/mac/qgis-deps-0.9/stage/lib/* $pathApp/Contents/Frameworks
cp -fR $pathApp/../../../qgisplugin/mac/Install/share/* $pathApp/Contents/MacOS/share
cp -fR $pathApp/../../../qgisplugin/mac/Install/qgis/* $pathApp/Contents/MacOS/lib/qgis
install_name_tool -change @loader_path/libz.1.2.11.dylib @rpath/libz.1.2.11.dylib ./R2D.app/Contents/MacOS/R2D
# remove unwanted stuff
declare -a notWantedApp=("createSAM/mdofBuildingModel/"
"createSAM/openSeesInput"
"createSAM/AutoSDA"
"createEVENT/ASCE7_WindSpeed"
"createEVENT/CFDEvent"
"createEVENT/HighRiseTPU"
"createEVENT/LowRiseTPU"
"createEVENT/NonisolatedLowRiseTPU"
"createEVENT/stochasticWind"
"createEVENT/stochasticGroundMotion"
"createEVENT/windTunnelExperiment"
"createEDP/standardWindEDP"
"createEDP/userEDP"
"createEDP/userEDP"
"createEDP/userEDP_R"
"createEDP/standardEarthquakeEDP_R"
)
for app in "${notWantedApp[@]}"
do
echo "removing $app"
rm -fr $pathApp/Contents/MacOS/applications/$app
done
find ./$APP_FILE -name __pycache__ -exec rm -rf {} +;
#
# now before we codesign and verify, check userID file exists
#
userID="../userID.sh"
if [ ! -f "$userID" ]; then
echo "creating dmg $DMG_FILENAME"
hdiutil create $DMG_FILENAME -fs HFS+ -srcfolder ./$APP_FILE -format UDZO -volname $APP_NAME
echo "No password & credential file to continue with codesig and App store verification"
exit
fi
source $userID
echo $appleID
#
# create dmg
#
if [ "${DMG_METHOD}" = "NEW" ]; then
#
# mv app into empty folder for create-dmg to work
# brew install create-dmg
#
echo "codesign --deep --force --verbose --options=runtime --sign "$appleCredential" $APP_FILE"
codesign --deep --force --verbose --options=runtime --sign "$appleCredential" $APP_FILE
mkdir app
mv $APP_FILE app
# swoop
#create-dmg \
# --volname "${APP_NAME}" \
# --background "../background/background1.png" \
# --window-pos 200 120 \
# --window-size 550 400 \
# --icon-size 150 \
# --icon "${APP_NAME}.app" 150 190 \
# --hide-extension "${APP_NAME}.app" \
# --app-drop-link 400 185 \
# "${DMG_FILENAME}" \
# "app"
# vertical
#create-dmg \
# --volname "${APP_NAME}" \
# --background "../background/background2.png" \
# --window-pos 200 120 \
# --window-size 475 550 \
# --icon-size 150 \
# --icon "${APP_NAME}.app" 235 125 \
# --hide-extension "${APP_NAME}.app" \
# --app-drop-link 235 400 \
# "${DMG_FILENAME}" \
# "app"
#horizontal
../macInstall/create-dmg \
--volname "${APP_NAME}" \
--background "../macInstall/background3.png" \
--window-pos 200 120 \
--window-size 600 350 \
--no-internet-enable \
--icon-size 125 \
--icon "${APP_NAME}.app" 125 130 \
--hide-extension "${APP_NAME}.app" \
--app-drop-link 450 130 \
--codesign $appleCredential \
"${DMG_FILENAME}" \
"app"
# --notarize $appleID $appleAppPassword \
mv ./app/$APP_FILE ./
rm -fr app
else
echo "codesign --deep --force --verbose --options=runtime --sign "$appleCredential" $APP_FILE"
codesign --deep --force --verbose --options=runtime --sign "$appleCredential" $APP_FILE
echo "hdiutil create $DMG_FILENAME -fs HFS+ -srcfolder ./$APP_FILE -format UDZO -volname $APP_NAME"
hdiutil create $DMG_FILENAME -fs HFS+ -srcfolder ./$APP_FILE -format UDZO -volname $APP_NAME
echo "Issue: codesign --force --sign "$appleCredential" $DMG_FILENAME"
codesign --force --sign "$appleCredential" $DMG_FILENAME
fi
#
# notorize , create zip file & send to apple
#
echo "Issue the following: "
echo "xcrun notarytool submit ./$DMG_FILENAME --apple-id $appleID --password $appleAppPassword --team-id $appleCredential"
echo "xcrun notarytool log ID --apple-id $appleID --team-id $appleCredential --password $appleAppPAssword"
#echo "https://appleid.apple.com/account/"
#echo "under security generate app specific password: $APP_NAME"
#echo "xcrun altool --notarize-app -u appleID -p appleAppPassword -f ./$APP_NAME.zip --primary-bundle-id altool"
#echo "returns id: ID"
echo "Finally staple the dmg"
echo "xcrun stapler staple \"$APP_NAME\" $DMG_FILENAME"
cd ..