-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhelper.linux.fish
executable file
·2059 lines (1761 loc) · 61.8 KB
/
helper.linux.fish
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
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ######################################
# `eval "docker build $ARGS ..."` is #
# used instead of `docker build $ARGS` #
# due to fish problem running such #
# command without evaluation #
# ######################################
set -gx INNERWORKDIR /work
set -gx THIRDPARTY_BIN ArangoDB/build/install/usr/bin
set -gx THIRDPARTY_SBIN ArangoDB/build/install/usr/sbin
set -gx SCRIPTSDIR /scripts
set -gx PLATFORM linux
set -gx ARCH (uname -m)
set -gx DUMPDEVICE "lo"
set IMAGE_ARGS "--build-arg ARCH=$ARCH"
if test "$ARCH" = "aarch64"
set -xg UBUNTUBUILDIMAGE_TAG_ARCH "arm64v8"
else
set -xg UBUNTUBUILDIMAGE_TAG_ARCH "x86_64"
end
set -gx UBUNTUBUILDIMAGE_312_NAME arangodb/ubuntubuildarangodb-devel
set -gx UBUNTUBUILDIMAGE_312_TAG 12
set -gx UBUNTUBUILDIMAGE_312 $UBUNTUBUILDIMAGE_312_NAME:$UBUNTUBUILDIMAGE_312_TAG-$UBUNTUBUILDIMAGE_TAG_ARCH
set -gx UBUNTUBUILDIMAGE_311_NAME arangodb/ubuntubuildarangodb-311
set -gx UBUNTUBUILDIMAGE_311_TAG 2
set -gx UBUNTUBUILDIMAGE_311 $UBUNTUBUILDIMAGE_311_NAME:$UBUNTUBUILDIMAGE_311_TAG-$UBUNTUBUILDIMAGE_TAG_ARCH
set -gx UBUNTUPACKAGINGIMAGE arangodb/ubuntupackagearangodb-$ARCH:1
set -gx UBUNTUPACKAGINGIMAGE2 arangodb/ubuntupackagearangodb-$ARCH:2
set -gx ALPINEUTILSIMAGE_NAME arangodb/alpineutils-$ARCH
set -gx ALPINEUTILSIMAGE_TAG 4
set -gx ALPINEUTILSIMAGE $ALPINEUTILSIMAGE_NAME:$ALPINEUTILSIMAGE_TAG
set -gx CENTOSPACKAGINGIMAGE_NAME arangodb/centospackagearangodb-$ARCH
set -gx CENTOSPACKAGINGIMAGE_TAG 3
set -gx CENTOSPACKAGINGIMAGE $CENTOSPACKAGINGIMAGE_NAME:$CENTOSPACKAGINGIMAGE_TAG
set -gx CPPCHECKIMAGE_NAME arangodb/cppcheck-$ARCH
set -gx CPPCHECKIMAGE_TAG 8
set -gx CPPCHECKIMAGE $CPPCHECKIMAGE_NAME:$CPPCHECKIMAGE_TAG
set -gx LDAPIMAGE_NAME arangodb/ldap-test-$ARCH
set -gx LDAPIMAGE_TAG 1
set -gx LDAPIMAGE $LDAPIMAGE_NAME:$LDAPIMAGE_TAG
set -gx LDAPDOCKERCONTAINERNAME ldapserver1
set -gx LDAP2DOCKERCONTAINERNAME ldapserver2
set -gx LDAPNETWORK ldaptestnet
set -xg IONICE "ionice -c 3"
set -gx SYSTEM_IS_LINUX true
## #############################################################################
## config
## #############################################################################
function compiler
set -l cversion $argv[1]
if test "$cversion" = ""
set -e COMPILER_VERSION
return 0
end
switch $cversion
case 13.2.0
set -xg COMPILER_VERSION $cversion
case clang16.0.6
set -gx COMPILER_VERSION $cversion
case clang19.1.7
set -gx COMPILER_VERSION $cversion
case '*'
echo "unknown compiler version $cversion"
end
end
function opensslVersion
set -l oversion $argv[1]
if test "$oversion" = ""
set -e OPENSSL_VERSION
return 0
end
switch $oversion
case '3.4'
set -gx OPENSSL_VERSION $oversion
case '*'
echo "unknown openssl version $oversion"
end
end
function findBuildImage
findStaticBuildImage
end
function findStaticBuildImage
if test "$COMPILER_VERSION" = ""
eval echo \$UBUNTUBUILDIMAGE_$ARANGODB_VERSION_MAJOR$ARANGODB_VERSION_MINOR
else
switch $COMPILER_VERSION
case 13.2.0 clang16.0.6 clang19.1.7
eval echo \$UBUNTUBUILDIMAGE_$ARANGODB_VERSION_MAJOR$ARANGODB_VERSION_MINOR
case '*'
echo "unknown compiler version $version"
return 1
end
end
end
function findBuildScript
findStaticBuildScript
end
function findStaticBuildScript
if test "$COMPILER_VERSION" = ""
echo buildArangoDB$ARANGODB_VERSION_MAJOR$ARANGODB_VERSION_MINOR.fish
else
switch $COMPILER_VERSION
case 13.2.0 clang16.0.6 clang19.1.7
echo buildArangoDB$ARANGODB_VERSION_MAJOR$ARANGODB_VERSION_MINOR.fish
case '*'
echo "unknown compiler version $version"
return 1
end
end
end
function findRequiredCompiler
set -l f $WORKDIR/work/ArangoDB/VERSIONS
test -f $f
or begin
echo "Cannot find $f; make sure source is checked out"
return 1
end
#if test "$COMPILER_VERSION" != ""
# echo "Compiler version already set to '$COMPILER_VERSION'"
# return 0
#end
set -l v (fgrep CLANG_LINUX $f | awk '{print $2}' | tr -d '"' | tr -d "'")
if test "$v" = ""
set v (fgrep GCC_LINUX $f | awk '{print $2}' | tr -d '"' | tr -d "'")
else
set v "clang$v"
end
if test "$v" = ""
echo "$f: no CLANG_LINUX or GCC_LINUX specified, using g++ 13.2.0"
compiler 13.2.0
else
echo "Using compiler '$v' from '$f'"
compiler $v
end
end
function findRequiredOpenSSL
set -l f $WORKDIR/work/ArangoDB/VERSIONS
test -f $f
or begin
echo "Cannot find $f; make sure source is checked out"
return 1
end
#if test "$OPENSSL_VERSION" != ""
# echo "OpenSSL version already set to '$OPENSSL_VERSION'"
# return 0
#end
set -l v (fgrep OPENSSL_LINUX $f | awk '{print $2}' | tr -d '"' | tr -d "'" | grep -o '^[0-2]\.[0-2]\.[0-2]\|^[3-9]\.[0-9]')
if test "$v" = ""
echo "$f: no OPENSSL_LINUX specified, using 3.4"
opensslVersion 3.4
else
echo "Using OpenSSL version '$v' from '$f'"
opensslVersion $v
end
end
## #############################################################################
## checkout and switch functions
## #############################################################################
function checkoutMirror
if test (count $argv) -ne 1
echo "usage: checkoutMirror.fish <DIRECTORY>"
exit 1
end
runInContainer -v $argv[1]:/mirror $DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/checkoutMirror.fish
or return $status
end
function checkoutArangoDB
runInContainer $DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/checkoutArangoDB.fish
or return $status
community
end
function checkoutEnterprise
runInContainer $DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/checkoutEnterprise.fish
or return $status
enterprise
end
function checkoutMiniChaos
runInContainer $DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/checkoutMiniChaos.fish
or return $status
end
function checkoutRTA
runInContainer -e RTA_BRANCH="$RTA_BRANCH" $DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/checkoutRTA.fish
or return $status
end
function switchBranches
set -l force_clean false
if test (count $argv) -eq 3
set force_clean $argv[3]
end
if test $force_clean = "true"
if test ! -d $WORKDIR/ArangoDB/.git
rm -rf $INNERWORKDIR/ArangoDB/.git
or return $status
end
end
checkoutIfNeeded
and runInContainer $DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/switchBranches.fish $argv
and convertSItoJSON
and findArangoDBVersion
and findRequiredCompiler
and set -gx MINIMAL_DEBUG_INFO (findMinimalDebugInfo)
and findDefaultArchitecture
and findUseARM
end
## #############################################################################
## LDAP
## #############################################################################
set -gx LDAPEXT ""
if test -n "$NODE_NAME"
set -gx LDAPEXT (echo "$NODE_NAME" | tr -c -d "[:alnum:]")
end
set -gx LDAPHOST "$LDAPDOCKERCONTAINERNAME$LDAPEXT"
set -gx LDAPHOST2 "$LDAP2DOCKERCONTAINERNAME$LDAPEXT"
function stopLdapServer
"$DOCKER" stop "$LDAPDOCKERCONTAINERNAME$LDAPEXT"
and "$DOCKER" rm "$LDAPDOCKERCONTAINERNAME$LDAPEXT"
"$DOCKER" stop "$LDAP2DOCKERCONTAINERNAME$LDAPEXT"
and "$DOCKER" rm "$LDAP2DOCKERCONTAINERNAME$LDAPEXT"
"$DOCKER" network rm "$LDAPNETWORK$LDAPEXT"
echo "LDAP servers stopped"
true
end
function launchLdapServer
stopLdapServer
and "$DOCKER" network create "$LDAPNETWORK$LDAPEXT"
and "$DOCKER" run -d --name "$LDAPHOST" --net="$LDAPNETWORK$LDAPEXT" $LDAPIMAGE
and "$DOCKER" run -d --name "$LDAPHOST2" --net="$LDAPNETWORK$LDAPEXT" $LDAPIMAGE
and echo "LDAP servers launched"
end
## #############################################################################
## build
## #############################################################################
function buildArangoDB
#TODO FIXME - do not change the current directory so people
# have to do a 'cd' for a subsequent call.
# Fix by not relying on relative locations in other functions
checkoutIfNeeded
and findRequiredCompiler
and findRequiredOpenSSL
and findDefaultArchitecture
and findUseARM
and set -xg STATIC_EXECUTABLES Off
and runInContainer $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/(findBuildScript) $argv
and packBuildFiles
set -l s $status
if test $s -ne 0
echo Build error!
return $s
end
end
function makeArangoDB
if test "$COMPILER_VERSION" = ""
findRequiredCompiler
and findRequiredOpenSSL
and findDefaultArchitecture
and findUseARM
end
and runInContainer $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/makeArangoDB.fish $argv
and packBuildFiles
set -l s $status
if test $s -ne 0
echo Build error!
return $s
end
end
function buildStaticArangoDB
checkoutIfNeeded
and findRequiredCompiler
and findRequiredOpenSSL
and findDefaultArchitecture
and findUseARM
and set -xg STATIC_EXECUTABLES On
and if test "$UNPACK_BUILD_FILES" = "On"
echo "UNPACK_BUILD_FILES: $UNPACK_BUILD_FILES"
unpackBuildFiles "$BUILD_FILES_ARCHIVE"
else
echo "UNPACK_BUILD_FILES: $UNPACK_BUILD_FILES"
runInContainer $DOCKER_URL_PREFIX(findStaticBuildImage) $SCRIPTSDIR/(findStaticBuildScript) $argv
and packBuildFiles
and if test "$ENTERPRISEEDITION" = "On"; and test "$ARANGODB_VERSION_MAJOR" -eq 3
if test "$ARANGODB_VERSION_MINOR" -ge 12; or begin; test "$ARANGODB_VERSION_MINOR" -eq 11; and test "$ARANGODB_VERSION_PATCH" -ge 10; end
packObjectFiles
end
end
end
set -l s $status
if test $s -ne 0
echo Build error!
return $s
end
end
function makeStaticArangoDB
if test "$COMPILER_VERSION" = ""
findRequiredCompiler
and findRequiredOpenSSL
and findDefaultArchitecture
and findUseARM
end
and runInContainer $DOCKER_URL_PREFIX(findStaticBuildImage) $SCRIPTSDIR/makeAlpine.fish $argv
and packBuildFiles
set -l s $status
if test $s -ne 0
echo Build error!
return $s
end
end
function buildStaticCoverage
coverageOn
and buildStaticArangoDB -DUSE_FAILURE_TESTS=On
end
function buildExamples
checkoutIfNeeded
and if test "$NO_RM_BUILD" != 1
buildStaticArangoDB
end
and runInContainer $DOCKER_URL_PREFIX(findStaticBuildImage) $SCRIPTSDIR/buildExamples.fish $argv
set -l s $status
if test $s -ne 0
echo Build error!
return $s
end
end
## #############################################################################
## test
## #############################################################################
function oskar
set -l s 1
set -l p $PARALLELISM
checkoutIfNeeded
and findRequiredCompiler
and if test "$SAN" = "On"
parallelism 2
clearSanStatus
runInContainer --security-opt seccomp=unconfined --cap-add SYS_NICE --cap-add SYS_PTRACE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runTests.fish $argv
set s $status
set s (math $s + (getSanStatus))
else
runInContainer --security-opt seccomp=unconfined --cap-add SYS_NICE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runTests.fish $argv
set s $status
end
parallelism $p
return $s
end
function rlogTests
set -l s 1
set -l p $PARALLELISM
checkoutIfNeeded
and findRequiredCompiler
and if test "$SAN" = "On"
parallelism 2
clearSanStatus
runInContainer --cap-add SYS_NICE --cap-add SYS_PTRACE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/rlog/pr.fish $argv
set s $status
set s (math $s + (getSanStatus))
else
runInContainer --cap-add SYS_NICE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/rlog/pr.fish $argv
set s $status
end
parallelism $p
return $s
end
function oskarFull
set -l s 1
set -l p $PARALLELISM
checkoutIfNeeded
and findRequiredCompiler
and if test "$ENTERPRISEEDITION" = "On"
launchLdapServer
and if test "$SAN" = "On"
parallelism 2
runInContainer --net="$LDAPNETWORK$LDAPEXT" --cap-add SYS_NICE --cap-add SYS_PTRACE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runFullTests.fish $argv
else
runInContainer --net="$LDAPNETWORK$LDAPEXT" --cap-add SYS_NICE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runFullTests.fish $argv
end
set s $status
else
if test "$SAN" = "On"
parallelism 2
runInContainer --cap-add SYS_NICE --cap-add SYS_PTRACE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runFullTests.fish $argv
else
runInContainer --cap-add SYS_NICE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runFullTests.fish $argv
end
end
set s $status
if test "$ENTERPRISEEDITION" = "On"
stopLdapServer
end
parallelism $p
return $s
end
function oskarOneTest
set -l s 1
set -l p $PARALLELISM
checkoutIfNeeded
and findRequiredCompiler
and if test "$ENTERPRISEEDITION" = "On"
launchLdapServer
and if test "$SAN" = "On"
parallelism 2
runInContainer --net="$LDAPNETWORK$LDAPEXT" --cap-add SYS_NICE --cap-add SYS_PTRACE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runOneTest.fish $argv
else
runInContainer --net="$LDAPNETWORK$LDAPEXT" --cap-add SYS_NICE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runOneTest.fish $argv
end
set s $status
else
if test "$SAN" = "On"
parallelism 2
runInContainer --cap-add SYS_NICE --cap-add SYS_PTRACE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runOneTest.fish $argv
else
runInContainer --cap-add SYS_NICE $DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/runOneTest.fish $argv
end
end
set s $status
if test "$ENTERPRISEEDITION" = "On"
stopLdapServer
end
parallelism $p
return $s
end
## #############################################################################
## san
## #############################################################################
function clearSanStatus
set files $WORKDIR/work/aulsan.log.* $WORKDIR/work/tsan.log.*
rm -f $files
end
function getSanStatus
echo (count $WORKDIR/work/aulsan.log.* $WORKDIR/work/tsan.log.*)
end
## #############################################################################
## jslint
## #############################################################################
function jslint
checkoutIfNeeded
and pushd $WORKDIR/work/ArangoDB
or begin popd; return 1; end
set -l s 0
findArangoDBVersion
and runInContainer "$DOCKER_URL_PREFIX"arangodb/arangodb:$ARANGODB_VERSION_MAJOR.$ARANGODB_VERSION_MINOR /scripts/jslint.sh
set s $status
popd
return $s
end
## #############################################################################
## cppcheck
## #############################################################################
function cppcheckArangoDB
checkoutIfNeeded
runInContainer $DOCKER_URL_PREFIX$CPPCHECKIMAGE /scripts/cppcheck.sh $argv
return $status
end
function cppcheckPR
if test (count $argv) -ne 1
echo "usage: cppcheckPR <BASE BRANCH>"
return 1
end
checkoutIfNeeded
pushd $WORKDIR/work/ArangoDB
git fetch --all
set -l files (git --no-pager diff --diff-filter=d --name-only (git merge-base --fork-point origin/$argv[1] HEAD) -- arangod/ lib/ client-tools/ arangosh/ | grep -E '\.cp{2}?|\.hp{2}?')
popd
if test "$ENTERPRISEEDITION" = "On"
pushd $WORKDIR/work/ArangoDB/enterprise
git fetch --all
set files $files (git --no-pager diff --diff-filter=d --name-only (git merge-base --fork-point origin/$argv[1] HEAD) -- Enterprise/ | grep -E '\.cp{2}?|\.hp{2}?' | sed -e 's/^/enterprise\//')
popd
end
if test -z "$files"
echo "No suitable (changed in PR to base C/C++ main) files were detected for CPPcheck."
return 0
else
echo "The following files are subject to CPPcheck: $files"
cppcheckArangoDB "$files"
return $status
end
end
## #############################################################################
## coverage
## #############################################################################
function collectCoverage
findRequiredCompiler
and findRequiredOpenSSL
and echo "collecting llvm coverage"
and runInContainer --env LLVM_PROFILE_FILE=/work/gcov/ $DOCKER_URL_PREFIX(findStaticBuildImage) python3 -u "$WORKSPACE/jenkins/helper/aggregate_coverage.py" "$INNERWORKDIR/" gcov coverage
return $status
end
## #############################################################################
## source release
## #############################################################################
function signSourcePackage
set -l SOURCE_TAG $argv[1]
pushd $WORKDIR/work
and runInContainer \
-e ARANGO_SIGN_PASSWD="$ARANGO_SIGN_PASSWD" \
-v $WORKSPACE/signing-keys/.gnupg4:/root/.gnupg \
$DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/signFile.fish \
/work/ArangoDB-$SOURCE_TAG.tar.gz \
/work/ArangoDB-$SOURCE_TAG.tar.bz2 \
/work/ArangoDB-$SOURCE_TAG.zip
and popd
or begin ; popd ; return 1 ; end
end
function createCompleteTar
set -l RELEASE_TAG $argv[1]
pushd $WORKDIR/work and runInContainer \
$DOCKER_URL_PREFIX$ALPINEUTILSIMAGE $SCRIPTSDIR/createCompleteTar.fish \
$RELEASE_TAG
and popd
or begin ; popd ; return 1 ; end
end
## #############################################################################
## linux release
## #############################################################################
function buildPackage
# Must have set ARANGODB_VERSION and ARANGODB_PACKAGE_REVISION and
# ARANGODB_FULL_VERSION, for example by running findArangoDBVersion.
set -l type "$argv[1]"
if test -z "$type"
set type "ALL"
end
if test "$type" = "ALL"
buildDebianPackage
and buildRPMPackage
and buildTarGzPackage
else
switch $type
case DEB
buildDebianPackage
case RPM
buildRPMPackage
case TAR.GZ
buildTarGzPackage
case '*'
echo "fatal, unknown package type \"$type\"!"
exit 1
end
end
end
function buildEnterprisePackage
if test "$DOWNLOAD_SYNC_USER" = ""
echo "Need to set environment variable DOWNLOAD_SYNC_USER."
return 1
end
set -l packages "ALL"
test -n "$argv[1]"; and set packages "$argv[1]"
# Must have set ARANGODB_VERSION and ARANGODB_PACKAGE_REVISION and
# ARANGODB_FULL_VERSION, for example by running findArangoDBVersion.
sanOff
and maintainerOff
and releaseMode
and enterprise
and set -xg NOSTRIP 1
and buildStaticArangoDB
and downloadStarter
and downloadSyncer
and copyRclone "linux"
and buildPackage $packages
if test $status -ne 0
echo Building enterprise release failed, stopping.
return 1
end
end
function buildCommunityPackage
# Must have set ARANGODB_VERSION and ARANGODB_PACKAGE_REVISION and
# ARANGODB_FULL_VERSION, for example by running findArangoDBVersion.
set -l packages "ALL"
test -n "$argv[1]"; and set packages "$argv[1]"
sanOff
and maintainerOff
and releaseMode
and community
and set -xg NOSTRIP 1
and buildStaticArangoDB
and downloadStarter
and buildPackage $packages
if test $status -ne 0
echo Building community release failed.
return 1
end
end
## #############################################################################
## debian release
## #############################################################################
function buildDebianPackage
if test ! -d $WORKDIR/work/ArangoDB/build
echo buildDebianPackage: build directory does not exist
return 1
end
set -l pd "default"
if test -d $WORKDIR/debian/$ARANGODB_PACKAGES
set pd "$ARANGODB_PACKAGES"
end
# This assumes that a static build has already happened
# Must have set ARANGODB_DEBIAN_UPSTREAM and ARANGODB_DEBIAN_REVISION,
# for example by running findArangoDBVersion.
set -l v "$ARANGODB_DEBIAN_UPSTREAM-$ARANGODB_DEBIAN_REVISION"
set -l ch $WORKDIR/work/debian/changelog
set -l SOURCE $WORKDIR/debian/$pd
set -l TARGET $WORKDIR/work/debian
set -l EDITION arangodb3
set -l EDITIONFOLDER $SOURCE/community
set -l ARCH (dpkg --print-architecture)
if test "$ENTERPRISEEDITION" = "On"
echo Building enterprise edition debian package...
set EDITION arangodb3e
set EDITIONFOLDER $SOURCE/enterprise
else
echo Building community edition debian package...
end
rm -rf $TARGET
and cp -a $EDITIONFOLDER $TARGET
and for f in arangodb3.init arangodb3.service compat config templates preinst prerm postinst postrm rules
cp $SOURCE/common/$f $TARGET/$f
sed -e "s/@EDITION@/$EDITION/g" -i $TARGET/$f
if test $PACKAGE_STRIP = All
sed -i -e "s/@DEBIAN_STRIP_ALL@//" -i $TARGET/$f
sed -i -e "s/@DEBIAN_STRIP_EXCEPT_ARANGOD@/echo /" -i $TARGET/$f
sed -i -e "s/@DEBIAN_STRIP_NONE@/echo /" -i $TARGET/$f
else if test $PACKAGE_STRIP = ExceptArangod
sed -i -e "s/@DEBIAN_STRIP_ALL@/echo /" -i $TARGET/$f
sed -i -e "s/@DEBIAN_STRIP_EXCEPT_ARANGOD@//" -i $TARGET/$f
sed -i -e "s/@DEBIAN_STRIP_NONE@/echo /" -i $TARGET/$f
else
sed -i -e "s/@DEBIAN_STRIP_ALL@/echo /" -i $TARGET/$f
sed -i -e "s/@DEBIAN_STRIP_EXCEPT_ARANGOD@/echo /" -i $TARGET/$f
sed -i -e "s/@DEBIAN_STRIP_NONE@//" -i $TARGET/$f
end
end
and echo -n "$EDITION " > $ch
and cp -a $SOURCE/common/source $TARGET
and echo "($v) UNRELEASED; urgency=medium" >> $ch
and echo >> $ch
and echo " * New version." >> $ch
and echo >> $ch
and echo -n " -- ArangoDB <[email protected]> " >> $ch
and date -R >> $ch
and sed -i "s/@ARCHITECTURE@/$ARCH/g" $TARGET/control
and runInContainer $DOCKER_URL_PREFIX$UBUNTUPACKAGINGIMAGE $SCRIPTSDIR/buildDebianPackage.fish
set -l s $status
if test $s -ne 0
echo Error when building a debian package
return $s
end
end
## #############################################################################
## redhat release
## #############################################################################
function buildRPMPackage
if test ! -d $WORKDIR/work/ArangoDB/build
echo buildRPMPackage: build directory does not exist
return 1
end
set -l pd "default"
if test -d $WORKDIR/rpm/$ARANGODB_PACKAGES
set pd "$ARANGODB_PACKAGES"
end
# This assumes that a static build has already happened
# Must have set ARANGODB_RPM_UPSTREAM and ARANGODB_RPM_REVISION,
# for example by running findArangoDBVersion.
if test "$ENTERPRISEEDITION" = "On"
transformSpec "$WORKDIR/rpm/$pd/arangodb3e.spec.in" "$WORKDIR/work/arangodb3.spec"
else
transformSpec "$WORKDIR/rpm/$pd/arangodb3.spec.in" "$WORKDIR/work/arangodb3.spec"
end
and cp $WORKDIR/rpm/$pd/arangodb3.initd $WORKDIR/work
and cp $WORKDIR/rpm/$pd/arangodb3.service $WORKDIR/work
and cp $WORKDIR/rpm/$pd/arangodb3.logrotate $WORKDIR/work
and runInContainer $DOCKER_URL_PREFIX$CENTOSPACKAGINGIMAGE $SCRIPTSDIR/buildRPMPackage.fish
end
## #############################################################################
## Mini-Chaos
## #############################################################################
function runMiniChaos
if test (count $argv) -lt 1
echo "usage: runMiniChaos <package>"
return 1
end
set -l package "$argv[1]"
set -l duration "$argv[2]"
mkdir -p $WORKDIR/work/mini-chaos
test -e $WORKDIR/work/{$package}.tar.gz
and rm -rf $WORKDIR/work/mini-chaos/$package
and mkdir -p $WORKDIR/work/mini-chaos/$package/ArangoDB
and tar -xf $WORKDIR/work/{$package}.tar.gz --strip-components=1 -C $WORKDIR/work/mini-chaos/$package/ArangoDB
and checkoutMiniChaos
and rm -rf "$WORKDIR/work/mini-chaos/$package/output"
and mkdir -p "$WORKDIR/work/mini-chaos/$package/output"
runInContainer \
--pid=host \
-v $WORKDIR/work/ArangoDB/mini-chaos:/mini-chaos \
-v $WORKDIR/work/mini-chaos/$package:/$package \
-e ARANGODB_OVERRIDE_CRASH_HANDLER=0 \
$DOCKER_URL_PREFIX(findBuildImage) $SCRIPTSDIR/startMiniChaos.fish $package $duration
end
## #############################################################################
## TAR server test
## #############################################################################
function makeTestPackageLinux
if test "$ENTERPRISEEDITION" = "On" -a "$DOWNLOAD_SYNC_USER" = "" -a "$ARANGODB_VERSION_MAJOR" -eq 3 -a "$ARANGODB_VERSION_MINOR" -lt 12
echo "Need to set environment variable DOWNLOAD_SYNC_USER for Enterprise package or use Community."
return 1
end
test (findMinimalDebugInfo) = "On"
and begin
packageStripExceptArangod
minimalDebugInfoOn
end
or begin
packageStripAll
minimalDebugInfoOff
end
echo ""
findArangoDBVersion
and sanOff
and releaseMode
and set -xg NOSTRIP 1
and buildStaticArangoDB
and downloadStarter
and if test "$ENTERPRISEEDITION" = "On"; downloadSyncer; and copyRclone "linux"; end
and buildTarGzServerLinuxTestPackage
if test $status -ne 0
echo Building test package failed, stopping!
return 1
end
end
function buildTarGzServerLinuxTestPackage
# This assumes that a static build has already happened
# Must have set ARANGODB_TGZ_UPSTREAM
# for example by running findArangoDBVersion.
set -l v "$ARANGODB_TGZ_UPSTREAM"
set -l name
if test "$ENTERPRISEEDITION" = "On"
set name arangodb3e
else
set name arangodb3
end
pushd $WORKDIR/work
and rm -rf targz
and mkdir targz
and cd $WORKDIR/work/ArangoDB/build/install
and cp -a * $WORKDIR/work/targz
and cd $WORKDIR/work/targz
and rm -rf bin
and cp -a $WORKDIR/binForTarGz bin
and find bin "(" -name "*.bak" -o -name "*~" ")" -delete
and cp bin/README.linux.server ./README
and sed -i$suffix -E "s/@ARANGODB_PACKAGE_NAME@/$name-$os-$v$arch/g" README
and rm -rf ./README.bak
and prepareInstall $WORKDIR/work/targz
and rm -rf "$WORKDIR/work/$name-$v"
and cp -r $WORKDIR/work/targz "$WORKDIR/work/$name-$v"
and cd $WORKDIR/work
or begin ; popd ; return 1 ; end
rm -rf "$name-linux-$v"
and ln -s "$name-$v" "$name-linux-$v"
and tar -c -z -f "$WORKDIR/work/$name-linux-$v.tar.gz" -h --exclude "etc" --exclude "var" --exclude "bin/README*" "$name-linux-$v"
and rm -rf "$name-linux-$v"
set s $status
popd
echo "$WORKDIR/work/$name-linux-$v.tar.gz"
and return $s
or begin ; popd ; return 1 ; end
end
function getTestPackageLinuxName
# This assumes that a static build has already happened
# Must have set ARANGODB_TGZ_UPSTREAM
# for example by running findArangoDBVersion.
set -l v "$ARANGODB_TGZ_UPSTREAM"
set -l name
if test "$ENTERPRISEEDITION" = "On"
set name arangodb3e
else
set name arangodb3
end
echo "$name-linux-$v"
end
## #############################################################################
## TAR release
## #############################################################################
function buildTarGzPackage
if test ! -d $WORKDIR/work/ArangoDB/build
echo buildTarGzPackage: build directory does not exist
return 1
end
buildTarGzPackageHelper "linux"
end
## #############################################################################
## docker release
## #############################################################################
function makeDockerRelease
if test "$DOWNLOAD_SYNC_USER" = ""
echo "Need to set environment variable DOWNLOAD_SYNC_USER."
return 1
end
findArangoDBVersion ; or return 1
if test (count $argv) -ge 1
makeDockerCommunityRelease $argv[1]
makeDockerEnterpriseRelease $argv[1]
else
makeDockerCommunityRelease
makeDockerEnterpriseRelease
end
end
function makeDockerCommunityRelease
findArangoDBVersion ; or return 1
test (findMinimalDebugInfo) = "On"
and begin
packageStripExceptArangod
minimalDebugInfoOn
end
or begin
packageStripAll
minimalDebugInfoOff
end
echo ""
community
and if test (count $argv) -ge 1
buildDockerRelease $argv[1]
else
buildDockerRelease $DOCKER_TAG
end
end
function makeDockerEnterpriseRelease
if test "$DOWNLOAD_SYNC_USER" = ""
echo "Need to set environment variable DOWNLOAD_SYNC_USER."
return 1
end
findArangoDBVersion ; or return 1
test (findMinimalDebugInfo) = "On"
and begin
packageStripExceptArangod
minimalDebugInfoOn
end
or begin
packageStripAll
minimalDebugInfoOff
end
echo ""
enterprise
and if test (count $argv) -ge 1
buildDockerRelease $argv[1]
else
buildDockerRelease $DOCKER_TAG
end
end