forked from owncloud/administration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakemac.sh
352 lines (285 loc) · 10.5 KB
/
makemac.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#!/bin/bash
#================================================================================
#
# FILE: makemac.sh
#
# USAGE: makemac.sh [-b, --build-environment]
# [-d, --dependencies]
# [-do, --dependencies-only]
# [-h, --help | --man]
# [-i, --interactive]
# [-le --local-environment]
# [-nc, --no-customizations]
# [-gc, --garbageclean]
# [-s, --sign]
# [-so, --sign-only]
# [-sp, --sparkle]
# [-spo, --sparkle-only]
#
# DESCRIPTION: Build the ownCloud client for MAC
#
# REQUIREMENTS: OS X 10.9
# XCode (with command line tools)
# Homebrew, see http://brew.sh/
# Packages, see http://s.sudre.free.fr/Software/Packages/about.html
# Sparkle, see http://sparkle-project.org/ (optional)
#
# AUTHOR: Koen Willems
# Sendin B.V. <info at sendin.nl>
# VERSION: 1.0.0
# CREATED: August 10, 2014
#
#================================================================================
#================================================================================
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
#================================================================================
CUR_DIR=$PWD
BUILD_DIR="${CUR_DIR}/buildenv"
OSLINUX=0
export PATH="/usr/local/Cellar/qt5/5.3.2/bin:/usr/local/Cellar/openssl/1.0.1l/bin:$PATH"
#================================================================================
#
# NAME: code section
# DESCRIPTION: Source config and library.
# If one of them is not available the script will stop.
#
#================================================================================
if ! source config ; then
echo $'\nThe file \"config\" is not available; the script will quit.\n'
exit 1
fi
if ! source library ; then
echo $'\nThe file \"library\" is not available; the script will quit.\n'
exit 1
fi
#================================================================================
#
# NAME: checkPackages
# DESCRIPTION: Simple check if 'Packages' is installed.
# If packagesutil and/or packagesbuild are not present the script
# assumes Packages is not installed.
#
#================================================================================
function checkPackages() {
if [ ! -f /usr/local/bin/packagesutil ] || [ ! -f /usr/local/bin/packagesbuild ] ; then
echo
echo 'You have to install "Packages", see "http://s.sudre.free.fr/Software/Packages/about.html".'
echo
exit 1
fi
}
#================================================================================
#
# NAME: buildMacDependencies
# DESCRIPTION: Build dependenecies.
# If DEPENDENCIES_ONLY=1 the script stops here.
#
#================================================================================
function buildMacDependencies() {
if [ ${DEPENDENCIES} -eq 1 ] ; then
#
# Be sure Brew is already installed.
# We are using our own repository instead of owncloud/owncloud,
# because we want to manage that part ourselves.
#
brew tap kwillems/owncloud
brew install $(brew deps mirall)
#
# Downgrade to Qt 5.3.2 from Qt 5.4 or higher,
# because the client 1.7.0 uses Qt 5.3.2.
#
if [ ! -d /usr/local/Cellar/qt5/5.3.2/ ] ; then
brew uninstall qt5
cd $( brew --prefix )
git checkout 840913d Library/Formula/qt5.rb
brew install qt5
brew pin qt5
fi
brew install iniparser
brew install qtkeychain
#
# If --force is passed, Homebrew will allow keg-only formulae to be linked.
#
brew link neon --force
brew link openssl --force
#
# The following is not really needed.
#
#brew install cmocka argp-standalone
#
# Latex en Sphinx are only needed for documentation. Be sure MacPorts is
# already installed if you are going to install them nevertheless.
#
#sudo port install texlive-latex
#sudo port install py27-sphinx
#sudo port select --set python python27
#sudo port select --set sphinx py27-sphinx
echo $'\nAll dependencies, libraries and other necessary thingies should be installed now.\n'
if [ ${DEPENDENCIES_ONLY} -eq 1 ] ; then
exit 0
fi
fi
}
#================================================================================
#
# NAME: buildMirallAndPackage
# DESCRIPTION: Build and package.
# If finished copy PKG and TBZ files to the folder 'client'.
#
#================================================================================
function buildMirallAndPackage() {
mkdir install
mkdir mirall-build
cd mirall-build
ownThemeDir=""
if [ ${OWNTHEME} -eq 1 ] ; then
ownThemeDir="-DOEM_THEME_DIR=${BUILD_DIR}/mirall/mytheme"
fi
updateParam=""
if [ -n "${macUpdateURL}" ] ; then
updateParam="-DAPPLICATION_UPDATE_URL=${macUpdateURL}"
fi
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5/ \
-DCMAKE_INSTALL_PREFIX=../install \
-DCMAKE_BUILD_TYPE="Debug" ../mirall \
${ownThemeDir} ${updateParam}
pause
make install
if [ ${CODESIGN} -eq 1 ] ; then
cd "${BUILD_DIR}"/install
if [ -n "${macDeveloperIDApplication}" ] ; then
for file in *.app
do
source "${BUILD_DIR}"/mirall/admin/osx/sign_app.sh "${file}" "${macDeveloperIDApplication}"
done
else
echo $'\nThere is no Developer ID Application entered in \"config\", so nothing is code signed.\n'
fi
if [ -n "${macDeveloperIDInstaller}" ] ; then
source "${BUILD_DIR}"/mirall-build/admin/osx/create_mac.sh "${BUILD_DIR}"/install "${BUILD_DIR}"/mirall-build "${macDeveloperIDInstaller}"
else
echo $'\nThere is no Developer ID Installer entered in \"config\", so nothing is code signed.\n'
fi
else
source "${BUILD_DIR}"/mirall-build/admin/osx/create_mac.sh "${BUILD_DIR}"/install "${BUILD_DIR}"/mirall-build
fi
#
# Make sure folder "client" exists.
#
cd "${CUR_DIR}"
if [ ! -d "client" ] ; then
mkdir -p "client"
fi
cd "${BUILD_DIR}"
cp "${BUILD_DIR}"/install/*.pkg "${CUR_DIR}"/client
cp "${BUILD_DIR}"/install/*.pkg.tbz "${CUR_DIR}"/client
}
#================================================================================
#
# NAME: signPKG
# DESCRIPTION: Code sign the PKG.
# Runs when CODESIGN=1 and macDeveloperIDInstaller exists
# and is longer than 0.
# Only used with parameter -so (sign only).
#
#================================================================================
function signPKG() {
if [ ${CODESIGN} -eq 1 ] ; then
if [ -n "${macDeveloperIDInstaller}" ] ; then
cd "${CUR_DIR}"/client
for file in *.pkg
do
productsign --sign "${macDeveloperIDInstaller}" "${file}" "signed_${file}"
done
else
echo $'\nThere is no Developer ID Installer entered in \"config\", so nothing is code signed.\n'
fi
fi
}
#================================================================================
#
# NAME: checkSignPKGOnly
# DESCRIPTION: If CODESIGN_ONLY=1 the script will stop after code signing.
#
#================================================================================
function checkSignPKGOnly() {
if [ ${CODESIGN_ONLY} -eq 1 ] ; then
signPKG
exit 0
fi
}
#================================================================================
#
# NAME: signSparkle
# DESCRIPTION: Create a DSA signature and store it in a TXT file.
# Runs when SPARKLE is set and the path and name of the private key
# is set in ${sparklePrivateKey} and this private key is present at
# the given location.
#
#================================================================================
function signSparkle() {
if [ ${SPARKLE} -eq 1 ] ; then
if [ -n "${sparklePrivateKey}" ] ; then
if [ -f "${sparklePrivateKey}" ] ; then
cd "${CUR_DIR}"/client
openssl=/usr/bin/openssl
for file in *.tbz
do
$openssl dgst -sha1 -binary < "${file}" | $openssl dgst -dss1 -sign "${sparklePrivateKey}" | $openssl enc -base64 > dsa-signature-for-\<\<"${file}"\>\>.txt
done
echo $'\nDSA signature written to TXT files(s)\n'
else
echo $'\nCould not find a Sparkle private key, so no DSA Signature is created.\n'
fi
else
echo $'\nThere is no Sparkle private key entered in \"config\", so no DSA Signature is created.\n'
fi
fi
}
#================================================================================
#
# NAME: checkSparkleOnly
# DESCRIPTION: If SPARKLE_ONLY=1 the script will stop after writing
# a DSA signature to a TXT.
#
#================================================================================
function checkSparkleOnly() {
if [ ${SPARKLE_ONLY} -eq 1 ] ; then
signSparkle
exit 0
fi
}
#================================================================================
#
# NAME: code section
# DESCRIPTION: Run run run ...
#
#================================================================================
checkHelp
checkPackages
checkSignPKGOnly
checkSparkleOnly
buildMacDependencies
makeBuildEnv
grabMirall
buildCustomizations
buildMirallAndPackage
signSparkle
cleanBuildGarbage
showMessage
#================================================================================
#
# NAME: code section
# DESCRIPTION: Leave
#
#================================================================================
exit 0