forked from telegramdesktop/tdesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.sh
executable file
·238 lines (204 loc) · 7.98 KB
/
Build.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
set -e
while IFS='' read -r line || [[ -n "$line" ]]; do
set $line
eval $1="$2"
done < Version
AppVersionStrFull="$AppVersionStr"
DevParam=''
if [ "$DevChannel" != "0" ]; then
AppVersionStrFull="$AppVersionStr.dev"
DevParam='-dev'
fi
if [ ! -f "Target" ]; then
echo "Build target not found!"
exit 1
fi
while IFS='' read -r line || [[ -n "$line" ]]; do
BuildTarget="$line"
done < Target
echo ""
if [ "$BuildTarget" == "linux" ]; then
echo "Building version $AppVersionStrFull for Linux 64bit.."
UpdateFile="tlinuxupd$AppVersion"
SetupFile="tsetup.$AppVersionStrFull.tar.xz"
WorkPath="./../Linux"
HomePath="./../../Telegram"
FixScript="$HomePath/FixMake.sh"
ReleasePath="./../Linux/Release"
elif [ "$BuildTarget" == "linux32" ]; then
echo "Building version $AppVersionStrFull for Linux 32bit.."
UpdateFile="tlinux32upd$AppVersion"
SetupFile="tsetup32.$AppVersionStrFull.tar.xz"
WorkPath="./../Linux"
HomePath="./../../Telegram"
FixScript="$HomePath/FixMake32.sh"
ReleasePath="./../Linux/Release"
elif [ "$BuildTarget" == "mac" ]; then
echo "Building version $AppVersionStrFull for OS X 10.8+.."
UpdateFile="tmacupd$AppVersion"
SetupFile="tsetup.$AppVersionStrFull.dmg"
ReleasePath="./../Mac/Release"
BinaryName="Telegram"
elif [ "$BuildTarget" == "mac32" ]; then
echo "Building version $AppVersionStrFull for OS X 10.6 and 10.7.."
UpdateFile="tmac32upd$AppVersion"
SetupFile="tsetup32.$AppVersionStrFull.dmg"
ReleasePath="./../Mac/Release"
BinaryName="Telegram"
elif [ "$BuildTarget" == "macstore" ]; then
echo "Building version $AppVersionStrFull for Mac App Store.."
ReleasePath="./../Mac/Release"
BinaryName="Telegram Desktop"
DropboxPath="./../../../Dropbox/Telegram/deploy/$AppVersionStrMajor"
DropboxDeployPath="$DropboxPath/$AppVersionStrFull"
else
echo "Invalid target!"
exit 1
fi
#if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ] || [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ] || [ "$BuildTarget" == "macstore" ]; then
if [ -d "$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStr.dev" ]; then
echo "Deploy folder for version $AppVersionStr.dev already exists!"
exit 1
fi
if [ -d "$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStr" ]; then
echo "Deploy folder for version $AppVersionStr already exists!"
exit 1
fi
if [ -f "$ReleasePath/$UpdateFile" ]; then
echo "Update file for version $AppVersion already exists!"
exit 1
fi
DeployPath="$ReleasePath/deploy/$AppVersionStrMajor/$AppVersionStrFull"
#fi
if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then
mkdir -p "$WorkPath/ReleaseIntermediateUpdater"
cd "$WorkPath/ReleaseIntermediateUpdater"
/usr/local/Qt-5.5.0/bin/qmake "$HomePath/Updater.pro"
make
echo "Updater build complete!"
cd "$HomePath"
mkdir -p "$WorkPath/ReleaseIntermediate"
cd "$WorkPath/ReleaseIntermediate"
/usr/local/Qt-5.5.0/bin/qmake "$HomePath/Telegram.pro"
eval "$FixScript"
make
echo "Telegram build complete!"
cd "$HomePath"
if [ ! -f "$ReleasePath/Telegram" ]; then
echo "Telegram not found!"
exit 1
fi
if [ ! -f "$ReleasePath/Updater" ]; then
echo "Updater not found!"
exit 1
fi
echo "Preparing version $AppVersionStrFull, executing Packer.."
cd $ReleasePath && ./Packer -path Telegram -path Updater -version $AppVersion $DevParam && cd ./../../Telegram
echo "Packer done!"
if [ ! -d "$ReleasePath/deploy" ]; then
mkdir "$ReleasePath/deploy"
fi
if [ ! -d "$ReleasePath/deploy/$AppVersionStrMajor" ]; then
mkdir "$ReleasePath/deploy/$AppVersionStrMajor"
fi
echo "Copying Telegram, Updater and $UpdateFile to deploy/$AppVersionStrMajor/$AppVersionStrFull..";
mkdir "$DeployPath"
mkdir "$DeployPath/Telegram"
mv $ReleasePath/Telegram $DeployPath/Telegram/
mv $ReleasePath/Updater $DeployPath/Telegram/
mv $ReleasePath/$UpdateFile $DeployPath/
cd $DeployPath && tar -cJvf $SetupFile Telegram/ && cd ./../../../../../Telegram
fi
if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ] || [ "$BuildTarget" == "macstore" ]; then
touch ./SourceFiles/telegram.qrc
xcodebuild -project Telegram.xcodeproj -alltargets -configuration Release build
if [ ! -d "$ReleasePath/$BinaryName.app" ]; then
echo "$BinaryName.app not found!"
exit 1
fi
if [ ! -d "$ReleasePath/$BinaryName.app.dSYM" ]; then
echo "$BinaryName.app.dSYM not found!"
exit 1
fi
AppUUID=`dwarfdump -u "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName" | awk -F " " '{print $2}'`
DsymUUID=`dwarfdump -u "$ReleasePath/$BinaryName.app.dSYM" | awk -F " " '{print $2}'`
if [ "$AppUUID" != "$DsymUUID" ]; then
echo "UUID of binary '$AppUUID' and dSYM '$DsymUUID' differ!"
exit 1
fi
if [ ! -f "$ReleasePath/$BinaryName.app/Contents/Resources/Icon.icns" ]; then
echo "Icon.icns not found in Resources!"
exit 1
fi
if [ ! -f "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName" ]; then
echo "$BinaryName not found in MacOS!"
exit 1
fi
if [ ! -d "$ReleasePath/$BinaryName.app/Contents/_CodeSignature" ]; then
echo "$BinaryName signature not found!"
exit 1
fi
if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
if [ ! -f "$ReleasePath/$BinaryName.app/Contents/Frameworks/Updater" ]; then
echo "Updater not found in Frameworks!"
exit 1
fi
elif [ "$BuildTarget" == "macstore" ]; then
if [ ! -f "$ReleasePath/$BinaryName.pkg" ]; then
echo "$BinaryName.pkg not found!"
exit 1
fi
fi
if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
cd $ReleasePath
temppath=`hdiutil attach -readwrite tsetup.dmg | awk -F "\t" 'END {print $3}'`
cp -R "./$BinaryName.app" "$temppath/"
bless --folder "$temppath/" --openfolder "$temppath/"
hdiutil detach "$temppath"
hdiutil convert tsetup.dmg -format UDZO -imagekey zlib-level=9 -ov -o $SetupFile
cd ./../../Telegram
cd $ReleasePath && ./Packer.app/Contents/MacOS/Packer -path "$BinaryName.app" -version $AppVersion $DevParam && cd ./../../Telegram
fi
if [ ! -d "$ReleasePath/deploy" ]; then
mkdir "$ReleasePath/deploy"
fi
if [ ! -d "$ReleasePath/deploy/$AppVersionStrMajor" ]; then
mkdir "$ReleasePath/deploy/$AppVersionStrMajor"
fi
if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "mac32" ]; then
echo "Copying $BinaryName.app and $UpdateFile to deploy/$AppVersionStrMajor/$AppVersionStr..";
mkdir "$DeployPath"
mkdir "$DeployPath/Telegram"
cp -r "$ReleasePath/$BinaryName.app" $DeployPath/Telegram/
mv "$ReleasePath/$BinaryName.app.dSYM" $DeployPath/
rm "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName"
rm "$ReleasePath/$BinaryName.app/Contents/Frameworks/Updater"
rm -rf "$ReleasePath/$BinaryName.app/Contents/_CodeSignature"
mv $ReleasePath/$UpdateFile $DeployPath/
mv $ReleasePath/$SetupFile $DeployPath/
if [ "$BuildTarget" == "mac32" ]; then
ReleaseToPath="./../../../TBuild/tother/tmac32"
DeployToPath="$ReleaseToPath/$AppVersionStrMajor/$AppVersionStrFull"
if [ ! -d "$ReleaseToPath/$AppVersionStrMajor" ]; then
mkdir "$ReleaseToPath/$AppVersionStrMajor"
fi
if [ ! -d "$DeployToPath" ]; then
mkdir "$DeployToPath"
fi
cp -v $DeployPath/$UpdateFile $DeployToPath/
cp -v $DeployPath/$SetupFile $DeployToPath/
cp -rv $DeployPath/$BinaryName.app.dSYM $DeployToPath/
fi
elif [ "$BuildTarget" == "macstore" ]; then
echo "Copying $BinaryName.app to deploy/$AppVersionStrMajor/$AppVersionStr..";
mkdir "$DeployPath"
cp -r "$ReleasePath/$BinaryName.app" $DeployPath/
mv "$ReleasePath/$BinaryName.pkg" $DeployPath/
mv "$ReleasePath/$BinaryName.app.dSYM" $DeployPath/
rm "$ReleasePath/$BinaryName.app/Contents/MacOS/$BinaryName"
rm -rf "$ReleasePath/$BinaryName.app/Contents/_CodeSignature"
cp -v "$DeployPath/$BinaryName.app" "$DropboxDeployPath/"
cp -rv "$DeployPath/$BinaryName.app.dSYM" "$DropboxDeployPath/"
fi
fi
echo "Version $AppVersionStrFull is ready!";