forked from altairwei/WizNotePlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mac-package-qt-5-appstore.sh
executable file
·129 lines (103 loc) · 5.38 KB
/
mac-package-qt-5-appstore.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
# 挂载的volumn的名称
volumn_name='wiznote-disk'
# 挂载点,一般不用修改,只配置volumn_name即可
volumn_path="/Volumes/$volumn_name"
# 以下参数只是用于自定义脚本的行为
package_home="./macos-package"
package_output_path="$HOME"
# compile
mkdir ../WizQTClient-Release-QT5
rm -rf ../WizQTClient-Release-QT5/* && \
cd ../WizQTClient-Release-QT5 && \
cmake -DWIZNOTE_USE_QT5=YES -DCMAKE_BUILD_TYPE=Release -UPDATE_TRANSLATIONS=YES -DAPPSTORE_BUILD=YES -DCMAKE_PREFIX_PATH=~/usr/local/qt/5.3.1/lib/cmake ../WizQTClient && \
make -j5
MYAPP="WizNote"
DEST="$MYAPP.app" # Our final App directory
ICUDIR="/usr/local/icu53.1"
ICULIBS="libicui18n.53 libicudata.53 libicuuc.53"
QTDIR="/usr/local/qt/5.3.1"
QTLIBS="QtCore QtNetwork QtSql QtGui QtOpenGL QtWidgets QtWebKit QtWebKitWidgets \
QtPrintSupport QtXml QtPositioning QtSensors QtConcurrent QtMacExtras QtMultimediaWidgets QtMultimedia" # QtQml QtQuick QtSvg QtScript
PLUGINS="sqldrivers imageformats platforms printsupport accessible \
position" # playlistformats sensors sensorgestures bearer audio iconengines
# make clean & create pathes
mkdir -p $DEST/Contents/Frameworks $DEST/Contents/PlugIns/icu $DEST/Contents/SharedSupport
# copy Qt libs, plug-ins and ICU
for L in $QTLIBS ; do
cp -R -p $QTDIR/lib/$L.framework $MYAPP.app/Contents/Frameworks
# remove all unnecessary header files:
rm -f $MYAPP.app/Contents/Frameworks/$L.framework/Headers
rm -R -f $MYAPP.app/Contents/Frameworks/$L.framework/Versions/5/Headers
#rm $MYAPP.app/Contents/Frameworks/$L.framework/Versions/5/${L}_debug
done
for P in $PLUGINS ; do
mkdir $MYAPP.app/Contents/PlugIns/$P
cp -R -p $QTDIR/plugins/$P/*.dylib $MYAPP.app/Contents/PlugIns/$P/
done
rm -R -f $MYAPP.app/Contents/PlugIns/platforms/libqminimal.dylib
rm -R -f $MYAPP.app/Contents/PlugIns/platforms/libqoffscreen.dylib
for I in $ICULIBS ; do
cp -p $ICUDIR/lib/$I.dylib $MYAPP.app/Contents/PlugIns/icu/
done
# copy own application libs if necessary to /Contents/PlugIns/myapp/
DISTPLUGINS=`cd $MYAPP.app/Contents/PlugIns; ls -1 */*.dylib` # extract all our *.dylib libs
for I in $QTLIBS ; do
install_name_tool -id "@executable_path/../Frameworks/$I.framework/Versions/5/$I"\
"$MYAPP.app/Contents/Frameworks/$I.framework/Versions/5/$I"
install_name_tool -change $I.framework/Versions/5/$I\
@executable_path/../Frameworks/$I.framework/Versions/5/$I\
$MYAPP.app/Contents/MacOS/$MYAPP # change references to Qt frameworks
for L in $QTLIBS ; do # change all lib references in all Qt frameworks
if [ $L = $I ] ; then continue; fi
install_name_tool -change $I.framework/Versions/5/$I\
@executable_path/../Frameworks/$I.framework/Versions/5/$I\
$MYAPP.app/Contents/Frameworks/$L.framework/Versions/5/$L
done
done
for P in $DISTPLUGINS ; do # change ID for all *.dylib libs
install_name_tool -id "@executable_path/../PlugIns/$I" "$MYAPP.app/Contents/PlugIns/$P"
for L in $QTLIBS ; do # change any reference to Qt in our *.dylib libs
install_name_tool -change $L.framework/Versions/5/$L\
@executable_path/../Frameworks/$L.framework/Versions/5/$L\
$MYAPP.app/Contents/PlugIns/$P
done
done
for L in $ICULIBS ; do
install_name_tool -id "@executable_path/../PlugIns/icu/$L.dylib"\
"$MYAPP.app/Contents/PlugIns/icu/$L.dylib"
for I in $ICULIBS ; do # change all references in ICU libs
if [ $I = $L ] ; then continue; fi
install_name_tool -change "$I.dylib" "@executable_path/../PlugIns/icu/$I.dylib"\
"$MYAPP.app/Contents/PlugIns/icu/$L.dylib"
done
done
# we do the same for additional own libs in /Contents/PlugIns/myapp
DISTPLUGINS2=`cd $MYAPP.app/Contents/PlugIns; ls *.dylib`
for P in $DISTPLUGINS2 ; do # change ID for all *.dylib libs
install_name_tool -id "@executable_path/../PlugIns/$I" "$MYAPP.app/Contents/PlugIns/$P"
for L in $QTLIBS ; do # change any reference to Qt in our *.dylib libs
install_name_tool -change $L.framework/Versions/5/$L\
@executable_path/../Frameworks/$L.framework/Versions/5/$L\
$MYAPP.app/Contents/PlugIns/$P
done
done
install_name_tool -change libicui18n.53.dylib @executable_path/../PlugIns/icu/libicui18n.53.dylib WizNote.app/Contents/Frameworks/QtWebKit.framework/Versions/5/QtWebKit
install_name_tool -change libicuuc.53.dylib @executable_path/../PlugIns/icu/libicuuc.53.dylib WizNote.app/Contents/Frameworks/QtWebKit.framework/Versions/5/QtWebKit
install_name_tool -change libicudata.53.dylib @executable_path/../PlugIns/icu/libicudata.53.dylib WizNote.app/Contents/Frameworks/QtWebKit.framework/Versions/5/QtWebKit
install_name_tool -change $QTDIR/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore WizNote.app/Contents/Frameworks/QtXml.framework/Versions/5/QtXml
cp -R -p ../WizQTClient/build/osx/WizNote-Entitlements.plist WizNote-Entitlements.plist
APPLCERT="3rd Party Mac Developer Application: Wei Shijun"
INSTCERT="3rd Party Mac Developer Installer: Wei Shijun"
for I in $QTLIBS ; do # signing the Qt frameworks
codesign -f -s "$APPLCERT" \
$MYAPP.app/Contents/Frameworks/$I.framework/Versions/5/$I
done
for I in $DISTPLUGINS ; do # signing all *.dylib libs
codesign -f -s "$APPLCERT" \
$MYAPP.app/Contents/PlugIns/$I
done
codesign -f -s "$APPLCERT" -v --entitlements \
WizNote-Entitlements.plist \
"$MYAPP.app" --deep
productbuild --component "$MYAPP.app" /Applications \
--sign "$INSTCERT" "$MYAPP.pkg"