-
Notifications
You must be signed in to change notification settings - Fork 89
/
build.sh
executable file
·745 lines (651 loc) · 22.6 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
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
#!/bin/bash
[[ "$1" =~ ^(--version)$ ]] && {
echo "2023-05-13";
exit 0
};
#
# CONST
#
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
BUILDFOLDER="haiwen-build"
BUILDPATH="${SCRIPTPATH}/${BUILDFOLDER}"
THIRDPARTYFOLDER="${BUILDPATH}/seahub_thirdparty"
PKGSOURCEDIR="built-seafile-sources"
PKGDIR="built-seafile-server-pkgs"
DISTRO=`lsb_release -d | awk '{ print $2 }'`
ARCH=$(arch)
PREFIX="${HOME}/opt/local"
# Temporary folder for seafile-server dependency builds for shared libraries (ld)
# see https://github.com/haiwen/seahub/blob/eab3ba2f6d3a311728130d8752c716e782b8d62e/scripts/build/build-server.py#L324
LIBSEARPC_VERSION_LATEST="3.3-latest" # check if new tag is available on https://github.com/haiwen/libsearpc/releases
LIBSEARPC_VERSION_FIXED="3.1.0" # libsearpc sticks to 3.1.0 https://github.com/haiwen/libsearpc/commit/43d768cf2eea6afc6e324c2b1a37a69cd52740e3
VERSION="10.0.1"
VERSION_SEAFILE="6.0.1" # dummy version for seafile (see configure.ac)
MYSQL_CONFIG_PATH="/usr/bin/mysql_config" # ensure compilation with mysql support
VERSION_TAG="v${VERSION}-server"
LIBSEARPC_TAG="v${LIBSEARPC_VERSION_LATEST}"
PYTHON_REQUIREMENTS_URL_SEAHUB="https://raw.githubusercontent.com/haiwen/seahub/${VERSION_TAG}/requirements.txt" # official requirements.txt file
PYTHON_REQUIREMENTS_URL_SEAFDAV="https://raw.githubusercontent.com/haiwen/seafdav/${VERSION_TAG}/requirements.txt"
STEPS=0
STEPCOUNTER=0
CONF_INSTALL_DEPENDENCIES=false
CONF_INSTALL_THIRDPART=false
CONF_BUILD_LIBEVHTP=false
CONF_BUILD_LIBSEARPC=false
CONF_BUILD_SEAFILE=false
CONF_BUILD_SEAFILE_GO_FILESERVER=false
CONF_BUILD_SEAFILE_NOTIFICATION_SERVER=false
CONF_BUILD_SEAHUB=false
CONF_BUILD_SEAFOBJ=false
CONF_BUILD_SEAFDAV=false
CONF_BUILD_SEAFILE_SERVER=false
PREP_BUILD=false
COPY_PKG_SOURCE=false
# colors used in functions for better readability
TXT_YELLOW="\033[93m"
TXT_DGRAY="\033[1;30m"
TXT_LGRAY="\033[0;37m"
TXT_LRED="\033[1;31m"
TXT_RED="\033[0;31m"
TXT_BLUE="\033[0;34m"
TXT_GREEN="\033[0;32m"
TXT_BOLD="\033[1m"
TXT_ITALIC="\033[3m"
TXT_UNDERSCORE="\033[4m"
# 48;5 for background, 38;5 for foreground
TXT_GREEN_ON_GREY="\033[48;5;240;38;5;040m"
TXT_ORANGE_ON_GREY="\033[48;5;240;38;5;202m"
OFF="\033[0m"
msg()
{
echo -e "\n${TXT_YELLOW}$1${OFF}\n"
}
error()
{
echo -e "${TXT_LRED}error:${OFF} $1";
exit 1
}
alldone()
{
echo -e " ${TXT_GREEN}done! ${OFF}"
}
mkmissingdir()
{
if [ ! -d "${1}" ]; then
echo -en "create missing directory ${TXT_BLUE}$1${OFF}...";
mkdir -p "${1}" || error "failed!";
alldone;
fi
}
exitonfailure()
{
if [ $? -ne 0 ]; then
error "$1"
fi
}
if [[ $1 == "" ]] ; then
echo -e "
Usage:
${TXT_BOLD}build.sh${OFF} ${TXT_DGRAY}${TXT_ITALIC}[OPTIONS]${OFF}
${TXT_UNDERSCORE}OPTIONS${OFF}:
${TXT_BOLD}-D${OFF} Install build dependencies
${TXT_BOLD}-T${OFF} Install thirdparty requirements
${TXT_BOLD}-1${OFF} Build/update libevhtp
${TXT_BOLD}-2${OFF} Build/update libsearpc
${TXT_BOLD}-3${OFF} Build/update seafile (c_fileserver)
${TXT_BOLD}-4${OFF} Build/update seafile (go_fileserver)
${TXT_BOLD}-5${OFF} Build/update seafile (notification_server)
${TXT_BOLD}-6${OFF} Build/update seahub
${TXT_BOLD}-7${OFF} Build/update seafobj
${TXT_BOLD}-8${OFF} Build/update seafdav
${TXT_BOLD}-9${OFF} Build/update Seafile server
${TXT_BOLD}-A${OFF} All options ${TXT_BOLD}-1${OFF} to ${TXT_BOLD}-9${OFF} in one go
${TXT_BOLD}-v${OFF} ${TXT_RED}${TXT_ITALIC}<vers>${OFF} Set seafile server version to build
${TXT_LGRAY}default:${OFF} ${TXT_BLUE}${VERSION}${OFF}
${TXT_BOLD}-r${OFF} ${TXT_RED}${TXT_ITALIC}<vers>${OFF} Set libsearpc version
${TXT_LGRAY}default:${OFF} ${TXT_BLUE}${LIBSEARPC_VERSION_LATEST}${OFF}
${TXT_BOLD}-f${OFF} ${TXT_RED}${TXT_ITALIC}<vers>${OFF} Set fixed libsearpc version
${TXT_LGRAY}default:${OFF} ${TXT_BLUE}${LIBSEARPC_VERSION_FIXED}${OFF}
${TXT_BOLD}-h${OFF} ${TXT_RED}${TXT_ITALIC}<vers>${OFF} Set python requirement file for seahub
${TXT_LGRAY}default:${OFF} ${TXT_BLUE}${PYTHON_REQUIREMENTS_URL_SEAHUB}${OFF}
${TXT_BOLD}-d${OFF} ${TXT_RED}${TXT_ITALIC}<vers>${OFF} Set python requirement file for seafdav
${TXT_LGRAY}default:${OFF} ${TXT_BLUE}${PYTHON_REQUIREMENTS_URL_SEAFDAV}${OFF}
${TXT_DGRAY}use${OFF} ${TXT_BOLD}--version${OFF} ${TXT_DGRAY}for version info of this script.${OFF}
"
exit 0
fi
# get the options
while getopts ":123456789ADTv:r:f:h:d:" OPT; do
case $OPT in
D) CONF_INSTALL_DEPENDENCIES=true >&2
STEPS=$((STEPS+1)) >&2
;;
T) CONF_INSTALL_THIRDPART=true >&2
STEPS=$((STEPS+1)) >&2
;;
1) CONF_BUILD_LIBEVHTP=true >&2
PREP_BUILD=true >&2
STEPS=$((STEPS+1)) >&2
;;
2) CONF_BUILD_LIBSEARPC=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
3) CONF_BUILD_SEAFILE=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
4) CONF_BUILD_SEAFILE_GO_FILESERVER=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
5) CONF_BUILD_SEAFILE_NOTIFICATION_SERVER=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
6) CONF_BUILD_SEAHUB=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
7) CONF_BUILD_SEAFOBJ=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
8) CONF_BUILD_SEAFDAV=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
9) CONF_BUILD_SEAFILE_SERVER=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+1)) >&2
;;
A) CONF_BUILD_LIBEVHTP=true >&2
CONF_BUILD_LIBSEARPC=true >&2
CONF_BUILD_SEAFILE=true >&2
CONF_BUILD_SEAFILE_GO_FILESERVER=true >&2
CONF_BUILD_SEAFILE_NOTIFICATION_SERVER=true >&2
CONF_BUILD_SEAHUB=true >&2
CONF_BUILD_SEAFOBJ=true >&2
CONF_BUILD_SEAFDAV=true >&2
CONF_BUILD_SEAFILE_SERVER=true >&2
PREP_BUILD=true >&2
COPY_PKG_SOURCE=true >&2
STEPS=$((STEPS+9)) >&2
;;
v) VERSION=$OPTARG >&2
VERSION_TAG="v${VERSION}-server" >&2
PYTHON_REQUIREMENTS_URL_SEAHUB="https://raw.githubusercontent.com/haiwen/seahub/${VERSION_TAG}/requirements.txt" >&2
PYTHON_REQUIREMENTS_URL_SEAFDAV="https://raw.githubusercontent.com/haiwen/seafdav/${VERSION_TAG}/requirements.txt" >&2
;;
r) LIBSEARPC_VERSION_LATEST=$OPTARG >&2
LIBSEARPC_TAG="v${LIBSEARPC_VERSION_LATEST}" >&2
;;
f) LIBSEARPC_VERSION_FIXED=$OPTARG >&2
;;
h) PYTHON_REQUIREMENTS_URL_SEAHUB=$OPTARG >&2
;;
d) PYTHON_REQUIREMENTS_URL_SEAFDAV=$OPTARG >&2
;;
\?)
error "Invalid option: ${TXT_BOLD}-$OPTARG${OFF}" >&2
;;
:)
error "Option ${TXT_BOLD}-$OPTARG${OFF} requires an argument." >&2
;;
esac
done
# set counter accordingly
${PREP_BUILD} && STEPS=$((STEPS+2))
${COPY_PKG_SOURCE} && STEPS=$((STEPS+1))
mkmissingdir "${BUILDPATH}"
#
# START
#
echo_start()
{
msg "Build seafile-rpi ${VERSION_TAG}"
}
#
# INSTALL DEPENDENCIES
#
install_dependencies()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Install dependencies"
# https://github.com/haiwen/seafile/issues/1158
# onigposix (libonig-dev) is dependency for /usr/local/include/evhtp.h
msg "Downloads the package lists from the repositories and updates them"
(set -x; apt-get update)
msg "Install build-essential package"
(set -x; apt-get install -y build-essential)
msg "Install build dependencies"
(set -x; apt-get install -y \
cargo \
cmake \
git \
golang-go \
intltool \
libarchive-dev \
libcurl4-openssl-dev \
libevent-dev \
libffi-dev \
libfuse-dev \
libglib2.0-dev \
libjansson-dev \
libjpeg-dev \
libjwt-dev \
libldap2-dev \
libmariadbclient-dev-compat \
libonig-dev \
libpq-dev \
libsqlite3-dev \
libssl-dev \
libtool \
libxml2-dev \
libxslt-dev \
python3-distro \
python3-lxml \
python3-ldap \
python3-pip \
python3-setuptools \
python3-wheel \
uuid-dev \
valac \
wget)
}
#
# PREPARE build (without privileges)
#
prepare_build()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Prepare build"
mkmissingdir "${PREFIX}"
msg " Export LIBRARY_PATH, LD_LIBRARY_PATH, CPATH"
export LIBRARY_PATH="${PREFIX}/lib"
export LD_LIBRARY_PATH="${PREFIX}/lib"
export CPATH="${PREFIX}/include"
# print ${LIBRARY_PATH}, ${LD_LIBRARY_PATH} and ${CPATH}
msg " LIBRARY_PATH = ${LIBRARY_PATH} "
msg " LD_LIBRARY_PATH = ${LD_LIBRARY_PATH} "
msg " CPATH = ${CPATH} "
}
#
# BUILD libevhtp
#
build_libevhtp()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build libevhtp"
cd "${BUILDPATH}"
if [ -d "libevhtp" ]; then
cd libevhtp
(set -x; make clean)
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://www.github.com/haiwen/libevhtp.git")
cd libevhtp
fi
(set -x; cmake -DCMAKE_INSTALL_PREFIX=${PREFIX} -DEVHTP_DISABLE_SSL=ON -DEVHTP_BUILD_SHARED=OFF .)
(set -x; make)
(set -x; make install)
exitonfailure "Build libevhtp failed"
cd "${SCRIPTPATH}"
}
#
# PREPARE libs
#
export_pkg_config_path()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Prepare libs"
# Export PKG_CONFIG_PATH for seafile-server and libsearpc
msg " Export PKG_CONFIG_PATH for seafile-server and libsearpc"
export PKG_CONFIG_PATH="${BUILDPATH}/libsearpc:${PKG_CONFIG_PATH}"
export PKG_CONFIG_PATH="${BUILDPATH}/seafile-server/lib:${PKG_CONFIG_PATH}"
# print ${PKG_CONFIG_PATH}
msg " PKG_CONFIG_PATH = ${PKG_CONFIG_PATH} "
}
#
# BUILD libsearpc
#
build_libsearpc()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build libsearpc"
cd "${BUILDPATH}"
if [ -d "libsearpc" ]; then
cd libsearpc
(set -x; make clean && make distclean)
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/libsearpc.git")
cd libsearpc
fi
(set -x; git reset --hard "${LIBSEARPC_TAG}")
(set -x; ./autogen.sh)
(set -x; ./configure)
(set -x; make dist)
exitonfailure "Build libsearpc failed"
cd "${SCRIPTPATH}"
}
#
# BUILD seafile (c_fileserver)
#
build_seafile()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build seafile-server (c_fileserver)"
cd "${BUILDPATH}"
if [ -d "seafile-server" ]; then
cd seafile-server
(set -x; make clean && make distclean)
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/seafile-server.git")
cd seafile-server
fi
(set -x; git reset --hard "${VERSION_TAG}")
(set -x; ./autogen.sh)
(set -x; ./configure --with-mysql=${MYSQL_CONFIG_PATH} --enable-ldap)
(set -x; make dist)
exitonfailure "Build seafile-server failed"
cd "${SCRIPTPATH}"
}
#
# BUILD seafile (go_fileserver)
#
build_seafile_go_fileserver()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build seafile-server (go_fileserver)"
cd "${BUILDPATH}"
if [ -d "seafile-server" ]; then
cd seafile-server
(set -x; make clean && make distclean)
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/seafile-server.git")
cd seafile-server
fi
(set -x; git reset --hard "${VERSION_TAG}")
(set -x; cd fileserver && go build .)
exitonfailure "Build seafile-server (go_fileserver) failed"
cd "${SCRIPTPATH}"
}
#
# BUILD seafile (notification_server)
#
build_seafile_notification_server()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build seafile-server (notification_server)"
cd "${BUILDPATH}"
if [ -d "seafile-server" ]; then
cd seafile-server
(set -x; make clean && make distclean)
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/seafile-server.git")
cd seafile-server
fi
(set -x; git reset --hard "${VERSION_TAG}")
(set -x; cd notification-server && go build .)
exitonfailure "Build seafile-server (notification_server) failed"
cd "${SCRIPTPATH}"
}
#
# INSTALL thirdparty requirements
#
install_thirdparty()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Install Seafile thirdparty requirements"
# if distro and arch matches, add piwheels to pip config file
msg " Only add \"piwheels\" to pip config file if distro is DEBIAN (Buster or Bullseye) and the architecture is ARM."
if [ "${DISTRO}" = Debian -o "${DISTRO}" = Raspbian ] && [ "${ARCH}" = armv7l -o "${ARCH}" = armv8l -o "${ARCH}" = aarch64 ]; then
msg " Detected \"${DISTRO}\" distro for \"${ARCH}\". We can make use of \"piwheels\", pre-compiled binary Python packages."
if [ ! -f "${HOME}/.config/pip/pip.conf" ]; then
msg " Adding \"piwheels\" to pip config file under '${HOME}/.config/pip/pip.conf'..."
mkdir -p "${HOME}/.config" "${HOME}/.config/pip" && touch "${HOME}/.config/pip/pip.conf"
echo "[global]" > "${HOME}/.config/pip/pip.conf"
echo "extra-index-url=https://www.piwheels.org/simple" >> "${HOME}/.config/pip/pip.conf"
msg " Added 'extra-index-url=https://www.piwheels.org/simple' to pip config file."
else
msg " The pip config file '${HOME}/.config/pip/pip.conf' is already present on the system."
if grep -Fxq "extra-index-url=https://www.piwheels.org/simple" ${HOME}/.config/pip/pip.conf; then
msg " Found the line 'extra-index-url=https://www.piwheels.org/simple' already inside of the pip config file '${HOME}/.config/pip/pip.conf'."
else
msg " Adding 'extra-index-url=https://www.piwheels.org/simple' to '${HOME}/.config/pip/pip.conf'"
echo "[global]" >> "${HOME}/.config/pip/pip.conf"
echo "extra-index-url=https://www.piwheels.org/simple" >> "${HOME}/.config/pip/pip.conf"
msg " Added 'extra-index-url=https://www.piwheels.org/simple' to the pip config file."
fi
fi
fi
# While pip alone is sufficient to install from pre-built binary archives, up to date copies of the setuptools and wheel projects are useful to ensure we can also install from source archives
# e.g. default shipped pip=9.0.1 in Ubuntu Bionic => need update to pip=20.*
# script executed like as seafile user, therefore pip upgrade only for seafile user, not system wide; pip installation goes to /home/seafile/.local/lib/python3.6/site-packages
msg " Download and update pip(3), setuptools and wheel from PyPI"
(set -x; python3 -m pip install --user --upgrade pip setuptools wheel)
mkmissingdir "${THIRDPARTYFOLDER}"
# get Seahub thirdparty requirements directly from GitHub
msg " Get Seahub thirdparty requirements directly from GitHub"
(set -x; wget "$PYTHON_REQUIREMENTS_URL_SEAHUB" -O "${THIRDPARTYFOLDER}/requirements.txt")
exitonfailure "Unable to get Seahub requirements"
# get SeafDAV thirdparty requirements directly from Github
msg " Get SeafDAV thirdparty requirements directly from GitHub"
(set -x; wget "$PYTHON_REQUIREMENTS_URL_SEAFDAV" -O "${THIRDPARTYFOLDER}/requirements_SeafDAV.txt")
exitonfailure "Unable to get Seafdav requirements"
# merge seahub and seafdav requirements in one file
(set -x; cat "${THIRDPARTYFOLDER}/requirements_SeafDAV.txt" >> "${THIRDPARTYFOLDER}/requirements.txt")
# install Seahub and SeafDAV thirdparty requirements
# on pip=20.* DEPRECATION: --install-option: ['--install-lib', '--install-scripts']
msg " Install Seahub and SeafDAV thirdparty requirements"
(set -x; python3 -m pip install -r "${THIRDPARTYFOLDER}/requirements.txt" --target "${THIRDPARTYFOLDER}" --no-cache --upgrade)
exitonfailure "Thirdparty requirements installation failed"
# clean up
msg " Clean up"
rm "${THIRDPARTYFOLDER}/requirements.txt" "${THIRDPARTYFOLDER}/requirements_SeafDAV.txt"
rm -rf $(find . -name "__pycache__")
}
#
# BUILD seahub
#
build_seahub()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build seahub"
# get source code
cd "${BUILDPATH}"
if [ -d "seahub" ]; then
cd seahub
(set -x; make clean)
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/seahub.git")
cd seahub
fi
(set -x; git reset --hard "${VERSION_TAG}")
# export ${THIRDPARTYFOLDER} to ${PATH}
msg " Export THIRDPARTYFOLDER to PATH"
export PATH="${THIRDPARTYFOLDER}:${PATH}"
# print ${PATH} which includes now ${THIRDPARTYFOLDER}
msg " PATH = ${PATH}"
# export ${THIRDPARTYFOLDER} to $PYTHONPATH
msg " Export THIRDPARTYFOLDER to PYTHONPATH"
export PYTHONPATH="${THIRDPARTYFOLDER}"
# print $PYTHONPATH
msg " PYTHONPATH = $PYTHONPATH${OFF}"
# to fix [ERROR] django-admin scripts not found in PATH
msg " export THIRDPARTYFOLDER/django/bin to PATH"
export PATH="${THIRDPARTYFOLDER}/django/bin:${PATH}"
msg " PATH = ${PATH}"
# generate package
# if python != python3.6 we need to "sudo ln -s /usr/bin/python3.6 /usr/bin/python" or with "pyenv global 3.6.9"
(set -x; python3 "${BUILDPATH}/seahub/tools/gen-tarball.py" --version="${VERSION_SEAFILE}" --branch=HEAD)
exitonfailure "Build seahub failed"
cd "${SCRIPTPATH}"
}
#
# BUILD seafobj
#
build_seafobj()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build seafobj"
cd "${BUILDPATH}"
if [ -d "seafobj" ]; then
cd seafobj
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/seafobj.git")
cd seafobj
fi
(set -x; git reset --hard "${VERSION_TAG}")
(set -x; make dist)
exitonfailure "Build seafobj failed"
cd "${SCRIPTPATH}"
}
#
# BUILD seafdav
#
build_seafdav()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build seafdav"
cd "${BUILDPATH}"
if [ -d "seafdav" ]; then
cd seafdav
(set -x; git fetch origin --tags)
(set -x; git reset --hard origin/master)
else
(set -x; git clone "https://github.com/haiwen/seafdav.git")
cd seafdav
fi
(set -x; git reset --hard "${VERSION_TAG}")
(set -x; make)
exitonfailure "Build seafdav failed"
cd "${SCRIPTPATH}"
}
#
# COPY package sources
#
copy_pkg_source()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Copy sources to ${PKGSOURCEDIR}/R${VERSION} "
mkmissingdir "${SCRIPTPATH}/${PKGSOURCEDIR}/R${VERSION}"
for i in \
"${BUILDPATH}/libsearpc/libsearpc-${LIBSEARPC_VERSION_FIXED}.tar.gz" \
"${BUILDPATH}/seafile-server/seafile-${VERSION_SEAFILE}.tar.gz" \
"${BUILDPATH}/seafile-server/fileserver/fileserver" \
"${BUILDPATH}/seafile-server/notification-server/notification-server" \
"${BUILDPATH}/seahub/seahub-${VERSION_SEAFILE}.tar.gz" \
"${BUILDPATH}/seafobj/seafobj.tar.gz" \
"${BUILDPATH}/seafdav/seafdav.tar.gz"
do
[ -f "$i" ] && (set -x; cp "$i" "${SCRIPTPATH}/${PKGSOURCEDIR}/R${VERSION}")
done
}
#
# BUILD Seafile server
#
build_server()
{
STEPCOUNTER=$((STEPCOUNTER+1))
msg "-> [${STEPCOUNTER}/${STEPS}] Build Seafile server"
cd "${BUILDPATH}"
mkmissingdir "${SCRIPTPATH}/${PKGDIR}"
# TODO: remove at seafile 10.0.2 release
msg "-> Patch build-server.py"
echo "--- build-server.py.old 2023-04-23 17:26:19.233328609 +0200
+++ build-server.py 2023-04-23 17:22:58.625726460 +0200
@@ -549,6 +549,15 @@
must_copy(src_go_fileserver, dst_bin_dir)
+# copy notification_server "notification-server" to directory seafile-server/seafile/bin
+def copy_notification_server():
+ builddir = conf[CONF_BUILDDIR]
+ srcdir = conf[CONF_SRCDIR]
+ src_notification_server = os.path.join(srcdir, 'notification-server')
+ dst_bin_dir = os.path.join(builddir, 'seafile-server', 'seafile', 'bin')
+
+ must_copy(src_notification_server, dst_bin_dir)
+
def copy_seafdav():
dst_dir = os.path.join(conf[CONF_BUILDDIR], 'seafile-server', 'seahub', 'thirdpart')
tarball = os.path.join(conf[CONF_SRCDIR], 'seafdav.tar.gz')
@@ -578,6 +587,8 @@
serverdir)
must_copy(os.path.join(scripts_srcdir, 'seafile.sh'),
serverdir)
+ must_copy(os.path.join(scripts_srcdir, 'seafile-monitor.sh'),
+ serverdir)
must_copy(os.path.join(scripts_srcdir, 'seahub.sh'),
serverdir)
must_copy(os.path.join(scripts_srcdir, 'reset-admin.sh'),
@@ -635,6 +646,9 @@
# copy go_fileserver
copy_go_fileserver()
+ # copy notification_server
+ copy_notification_server()
+
def copy_pdf2htmlex():
'''Copy pdf2htmlEX exectuable and its dependent libs'''
pdf2htmlEX_executable = find_in_path('pdf2htmlEX')" | patch -N -b -u "${BUILDPATH}/seahub/scripts/build/build-server.py"
msg "-> Executing build-server.py"
(set -x; python3 "${BUILDPATH}/seahub/scripts/build/build-server.py" \
--libsearpc_version="${LIBSEARPC_VERSION_FIXED}" \
--seafile_version="${VERSION_SEAFILE}" \
--version="${VERSION}" \
--thirdpartdir="${THIRDPARTYFOLDER}" \
--srcdir="${SCRIPTPATH}/${PKGSOURCEDIR}/R${VERSION}" \
--mysql_config="${MYSQL_CONFIG_PATH}" \
--outputdir="${SCRIPTPATH}/${PKGDIR}" \
--yes)
exitonfailure "Build Seafile server failed"
cd "${SCRIPTPATH}"
}
#
# COMPLETE
#
echo_complete()
{
msg "-> BUILD COMPLETED."
}
#
# MAIN
#
echo_start
if ${PREP_BUILD} ; then
prepare_build
export_pkg_config_path
fi
${CONF_INSTALL_DEPENDENCIES} && install_dependencies
${CONF_INSTALL_THIRDPART} && install_thirdparty
${CONF_BUILD_LIBEVHTP} && build_libevhtp
${CONF_BUILD_LIBSEARPC} && build_libsearpc
${CONF_BUILD_SEAFILE} && build_seafile
${CONF_BUILD_SEAFILE_GO_FILESERVER} && build_seafile_go_fileserver
${CONF_BUILD_SEAFILE_NOTIFICATION_SERVER} && build_seafile_notification_server
${CONF_BUILD_SEAHUB} && build_seahub
${CONF_BUILD_SEAFOBJ} && build_seafobj
${CONF_BUILD_SEAFDAV} && build_seafdav
${COPY_PKG_SOURCE} && copy_pkg_source
${CONF_BUILD_SEAFILE_SERVER} && build_server
echo_complete