-
Notifications
You must be signed in to change notification settings - Fork 1
/
PackageApp.sh
executable file
·103 lines (73 loc) · 3.03 KB
/
PackageApp.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
#!/bin/bash
# Written by Stevan Gavrilovic, University of California, Berkeley
# Usage:
# 1) cd the build folder containing the .app file of your application (in OpenSRA backend folder remove the .git folder, examples, docs etc. to reduce space)
# 2) Copy this script file over to the build folder
# 3) Set the path to macdeployqt on your system
# 4) Change the AppName to match the *.app file of your application
# 5) Change the app version
# 6) Run: bash PackageApp.sh
# ********* THINGS TO CHANGE START *********
# Version
appVers="0.4.0"
# Set the path to your macdeployqt here
pathMacDepQt="/Users/steve/Qt/5.15.2/clang_64/bin/macdeployqt"
# Name of the application
AppName="OpenSRA"
# ********* THINGS TO CHANGE END *********
appFile=$AppName".app"
appdmg=$AppName".dmg"
# Check to see if the required macdeployqt file exists at the given location
if [ ! -f "$pathMacDepQt" ]; then
echo "Could not find macdeployqt at $pathMacDepQt. Exiting"
exit
fi
# Get the path to the app file
pathApp=`pwd`/$appFile
# Check to see if the RDT app file exists in the current directory
if ! [ -x "$(command -v open $pathApp)" ]; then
echo "$appFile does not exist. Exiting."
exit
fi
# Variable to the path to the dmg
pathdmg="`pwd`/$appdmg"
# Remove the old dmg file if it already exists
if [ -f "$pathdmg" ]; then
rm $pathdmg
fi
# On first run need to run mac deploy qt to copy over the frameworks folder
$pathMacDepQt $pathApp
# Copy over the esri library files
# Define the paths to the application and to libEsriCommonQt.dylib - this should not change
pathAppBin=$pathApp/Contents/MacOS/OpenSRA
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
echo "Path substitution complete!"
# Run the macdeployqt to create the dmg
$pathMacDepQt $pathApp -dmg
# Check to see if the dmg was created and exists
if [ ! -f "$pathdmg" ]; then
echo "Could not find the .dmg file at $appdmg. Exiting"
exit
fi
# Rename it to add the version
mv $pathdmg $AppName"v"$appVers".dmg"
echo "Done!"