-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
executable file
·1311 lines (1155 loc) · 39.9 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
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
#!/bin/bash
#
# Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
#
# 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; either version 2 of the License, or
# (at your option) any later version.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# Build and package script for CUBRID
# Requirements
# - Bash shell
# - Build tool - autotools, make, gcc
# - Utils - GNU tar, ...
# - RPM tool - rpmbuild
# scrtip directory
script_dir=$(dirname $(readlink -f $0))
# variables for options
build_target="x86_64"
build_mode="release"
increase_build_number="no"
source_dir=`pwd`
run_autogen="no"
default_java_dir="/usr/java/default"
java_dir=""
configure_options=""
# default build_dir = "$source_dir/build_${build_target}_${build_mode}"
build_dir=""
install_dir=""
prefix_dir=""
output_dir=""
build_args="all"
default_packages="all"
packages=""
# variables
product_name="CUBRID"
product_name_lower=$(echo $product_name | tr '[:upper:]' '[:lower:]')
typeset -i major
typeset -i minor
typeset -i maintanance
typeset -i serial
build_number=""
last_checking_msg=""
output_packages=""
without_cmserver=""
function print_check ()
{
echo ""
last_checking_msg="$@"
echo " $last_checking_msg..."
}
function print_result ()
{
[ -n "$last_checking_msg" ] && echo -n " "
echo " [$@] $last_checking_msg."
last_checking_msg=""
}
function print_info ()
{
[ -n "$last_checking_msg" ] && echo -n " "
echo " [INFO] $@"
}
function print_error ()
{
echo ""
echo " [ERROR] $@"
}
function print_fatal ()
{
echo ""
echo " [FATAL] $@"
echo ""
echo "[`date +'%F %T'`] QUITTING..."
echo ""
exit 1
}
function build_initialize ()
{
# check for source dir
print_check "Checking for root source path [$source_dir]"
if [ -d $source_dir -a -d $source_dir/src -a -f $source_dir/BUILD_NUMBER ]
then
print_result "OK"
else
print_fatal "Root path for source is not valid"
fi
print_check "Checking for compiler"
which_gcc=$(which gcc)
[ $? -eq 0 ] && print_info "$which_gcc" || print_fatal "GCC not found"
gcc_version=$(gcc --version | grep GCC)
[ $? -eq 0 ] && print_info "$gcc_version" || print_info "unknown GCC version"
print_result "OK"
# check version
print_check "Checking BUILD NUMBER"
build_number=$(cat $source_dir/BUILD_NUMBER)
major=$(echo $build_number | cut -d . -f 1)
minor=$(echo $build_number | cut -d . -f 2)
maintanance=$(echo $build_number | cut -d . -f 3)
serial=10#$(echo $build_number | cut -d . -f 4)
print_info "version: $build_number ($major.$minor.$maintanance.$serial)"
print_result "OK"
}
function build_increase_version ()
{
# check for increase_build_number
if [ "$increase_build_number" = "yes" ]; then
print_check "Increasing BUILD NUMBER"
serial_num=$(printf "%04d" $(expr $serial + 1))
build_number="$major.$minor.$maintanance.$serial_num"
#build_number=$(cat $source_dir/BUILD_NUMBER | awk -F'.' '{ printf("%d.%d.%d.%04d\n", $1, $2, $3, $4+1) }')
print_info "Modifing Version to $build_number"
# BUILD_NUMBER
echo $build_number > $source_dir/BUILD_NUMBER
# copy right
current_year=`date +"%Y"`
sed --in-place -r "s/Copyright \(C\) 2008-[0-9]{4} Search Solution/Copyright (C) 2008-${current_year} Search Solution/g" $source_dir/COPYING
sed --in-place -r "s/Copyright \(C\) 2008-[0-9]{4} Search Solution/Copyright (C) 2008-${current_year} Search Solution/g" "$source_dir/win/install/Installshield/Setup Files/Compressed Files/Language Independent/OS Independent/license.txt"
# win version
win_version_h="$source_dir/win/version.h"
echo "#define RELEASE_STRING ${major}.${minor}.${maintanance}" > ${win_version_h}
echo "#define MAJOR_RELEASE_STRING ${major}.${minor}" >> ${win_version_h}
echo "#define BUILD_NUMBER ${build_number}" >> ${win_version_h}
echo "#define MAJOR_VERSION ${major}" >> ${win_version_h}
echo "#define MINOR_VERSION ${minor}" >> ${win_version_h}
echo "#define PATCH_VERSION ${maintanance}" >> ${win_version_h}
echo "#define BUILD_SERIAL_NUMBER ${serial_num}" >> ${win_version_h}
echo "#define VERSION_STRING \"${build_number}\"" >> ${win_version_h}
echo "#define PRODUCT_STRING \"${major}.${minor}\"" >> ${win_version_h}
echo "#define PACKAGE_STRING \"CUBRID ${major}.${minor}\"" >> ${win_version_h}
echo "" >> ${win_version_h}
# Install-Shield's release number
sed --in-place -r "s|<td>[0-9]+\.[0-9]+</td>|<td>${major}.${minor}</td>|g" $source_dir/win/install/Installshield/CUBRID.ism
sed --in-place -r "s|<td>ProductVersion</td><td>.*</td><td/>|<td>ProductVersion</td><td>${build_number}</td><td/>|g" $source_dir/win/install/Installshield/CUBRID.ism
sed --in-place -r "s|<td>[0-9]+\.[0-9]+</td>|<td>${major}.${minor}</td>|g" $source_dir/win/install/Installshield/CUBRID_x64.ism
sed --in-place -r "s|<td>ProductVersion</td><td>.*</td><td/>|<td>ProductVersion</td><td>${build_number}</td><td/>|g" $source_dir/win/install/Installshield/CUBRID_x64.ism
# php's release number
sed --in-place -r "s/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/${build_number}/g" $source_dir/contrib/php4/src/php_cubrid_version.h
sed --in-place -r "s/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/${build_number}/g" $source_dir/contrib/php5/php_cubrid_version.h
# RPM spec's release number
sed --in-place -r -e "s/cubrid_version [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/cubrid_version ${build_number}/g" -e "s/build_version [0-9]+\.[0-9]+\.[0-9]+/build_version ${major}.${minor}.${maintanance}/g" $source_dir/contrib/rpm/cubrid.spec
print_result "OK"
fi
}
function build_clean ()
{
print_check "Cleaning packaging directory"
if [ -d $install_dir ]; then
if [ "$install_dir" = "/" ]; then
print_fatal "Do not set root dir as install directory"
fi
print_info "All files in $install_dir is removing"
rm -rf $install_dir/*
fi
print_result "OK"
print_check "Cleaning build directory"
if [ -d $build_dir ]; then
if [ "$build_dir" = "/" ]; then
print_fatal "Do not set root dir as build directory"
fi
if [ $build_dir -ef $source_dir ]; then
[ -f "$build_dir/Makefile" ] && make -C $build_dir distclean
else
print_info "All files in $build_dir is removing"
rm -rf $build_dir/*
fi
fi
print_result "OK"
}
function build_autogen ()
{
# run autogen if needed
if [ $run_autogen = "yes" -o $source_dir/BUILD_NUMBER -nt $source_dir/configure ]; then
print_check "Running autogen.sh"
(cd $source_dir && sh ./autogen.sh)
[ $? -eq 0 ] && print_result "OK" || print_fatal "Result failed"
fi
# run autogen of cubrid manager if needed
print_check "Checking manager server directory"
if [ -d "$source_dir/cubridmanager" -a -d "$source_dir/cubridmanager/server" ]; then
print_result "OK"
print_check "Running autogen.sh of cubrid manager"
(cd $source_dir/cubridmanager/server && sh ./autogen.sh)
[ $? -eq 0 ] && print_result "OK" || print_fatal "Result failed"
else
print_info "Manager server source path is not exist. It will not be built"
fi
}
function build_configure ()
{
# configure with target and options
print_check "Preparing build directory"
if [ ! -d $build_dir ]; then
mkdir -p $build_dir
fi
print_result "OK"
print_check "Checking manager server directory"
if [ ! -d "$source_dir/cubridmanager" -o ! -d "$source_dir/cubridmanager/server" ]; then
without_cmserver="true"
print_error "Manager server source path is not exist. It will not be built"
fi
print_check "Setting environment variables"
if [ "x$java_dir" != "x" ]; then
export JAVA_HOME="$java_dir"
elif [ "x$JAVA_HOME" = "x" -a "x$JAVA_HOME" = "x" ]; then
export JAVA_HOME="$default_java_dir"
fi
export PATH="$JAVA_HOME/bin:$PATH"
print_result "OK"
print_check "Prepare configure options"
# set up prefix
configure_prefix="--prefix=$prefix_dir"
# set up target
case "$build_target" in
i386);;
x86_64)
configure_options="--enable-64bit $configure_options" ;;
*)
print_fatal "Build target [$build_target] is not valid target" ;;
esac
# set up build mode
case "$build_mode" in
release) ;;
debug)
configure_options="$configure_options --enable-debug" ;;
coverage)
configure_options="$configure_options --enable-debug --enable-coverage" ;;
*)
print_fatal "Build mode [$build_mode] is not valid build mode" ;;
esac
configure_options="$configure_options --enable-dbgw --with-nbase-t=yes --enable-nclavis"
if [ $build_mode = "release" ]; then
# check conflict
case "$configure_options" in
*"--enable-debug"*)
print_fatal "Conflict release mode with debug mode. check options";;
esac
fi
print_result "OK"
print_check "Configuring [with $configure_options]"
if [ "$(readlink -f $build_dir/..)" = "$source_dir" ]; then
configure_dir=".."
else
configure_dir="$source_dir"
fi
(cd $build_dir && $configure_dir/configure $configure_prefix $configure_options)
[ $? -eq 0 ] && print_result "OK" || print_fatal "Configuring failed"
}
function build_compile ()
{
# make
print_check "Building"
(cd $build_dir && make -j)
[ $? -eq 0 ] && print_result "OK" || print_fatal "Building failed"
}
function build_install ()
{
# make install
print_check "Installing"
(cd $build_dir && make install)
[ $? -eq 0 ] && print_result "OK" || print_fatal "Installation failed"
}
function print_install_sh ()
{
cat << \END_OF_FILE
#!/bin/sh
PRODUCT_NAME=CUBRID
install_file="$0"
tail +20 "$install_file" > install.${PRODUCT_NAME}.tmp 2> /dev/null
if [ "$?" != "0" ]
then
tail -n +20 "$install_file" > install.${PRODUCT_NAME}.tmp 2> /dev/null
fi
tar xf install.${PRODUCT_NAME}.tmp
./${PRODUCT_NAME}_Setup.sh "$0"
rm -f ./${PRODUCT_NAME}_Setup.sh ${PRODUCT_NAME}-product.tar.gz ${PRODUCT_NAME}-product.tar ./install.${PRODUCT_NAME}.tmp ./confcp.sh ./version.sh check_glibc_version COPYING
exit 0
END_OF_FILE
}
function print_setup_sh ()
{
cat << \END_OF_FILE
#!/bin/sh
PRODUCT_CODE=cubrid
PRODUCT_NAME=CUBRID
target_input=""
cp_old_dbtxt="no"
cwd=`pwd`
is_protego="no"
cat COPYING | more -d
while true; do
echo -n "Do you agree to the above license terms? (yes or no) : "
read agree_terms
if [ "$agree_terms" = "yes" ]; then
break
elif [ "$agree_terms" = "no" ]; then
echo "If you don't agree to the license you can't install this software."
exit 0
fi
done
echo -n "Do you want to install this software($PRODUCT_NAME) to the default(${cwd}/${PRODUCT_NAME}) directory? (yes or no) [Default: yes] : "
read ans_install_dir
if [ "$ans_install_dir" = "no" ] || [ "$ans_install_dir" = "n" ]; then
echo -n "Input the $PRODUCT_NAME install directory. [Default: ${cwd}/${PRODUCT_NAME}] : "
read target_input
fi
if [ "$target_input" = "" ]; then
target_dir=$cwd/$PRODUCT_NAME
else
target_dir=$target_input
fi
echo "Install ${PRODUCT_NAME} to '$target_dir' ..."
XDBMS_ENV_FILE1=$HOME/.${PRODUCT_CODE}.csh
XDBMS_ENV_FILE2=$HOME/.${PRODUCT_CODE}.sh
if [ -d $target_dir ]; then
echo "Directory '$target_dir' exist! "
echo "If a ${PRODUCT_NAME} service is running on this directory, it may be terminated abnormally."
echo "And if you don't have right access permission on this directory(subdirectories or files), install operation will be failed."
echo -n "Overwrite anyway? (yes or no) [Default: no] : "
read overwrite
if [ "$overwrite" != "y" ] && [ "$overwrite" != "yes" ]; then
exit 0
fi
else
mkdir -p $target_dir
fi
. ./version.sh
echo "Since CUBRID broker and server versions should match, please make sure that you are running the same version if you operate them in separate machines. For installation of CUBRID tools like Query Browser, Manager and Web Manager, please refer to http://www.cubrid.org/wiki_tools."
echo -n "Do you want to continue? (yes or no) [Default: yes] : "
read cont
if [ "$cont" = "n" ] || [ "$cont" = "no" ]; then
exit 0
fi
if [ -w $XDBMS_ENV_FILE1 ]; then
echo "Copying old .${PRODUCT_CODE}.csh to .${PRODUCT_CODE}.csh.bak ..."
rm -f ${XDBMS_ENV_FILE1}.bak
cp $XDBMS_ENV_FILE1 ${XDBMS_ENV_FILE1}.bak
fi
if [ -w $XDBMS_ENV_FILE2 ]; then
echo "Copying old .${PRODUCT_CODE}.sh to .${PRODUCT_CODE}.sh.bak ..."
rm -f ${XDBMS_ENV_FILE2}.bak
cp $XDBMS_ENV_FILE2 ${XDBMS_ENV_FILE2}.bak
fi
if [ ! -w $target_dir/databases/databases.txt ]; then
if [ -w $target_dir/CUBRID_DATABASES/databases.txt ]; then
cp_old_dbtxt="yes"
fi
fi
#gzip -d ${PRODUCT_CODE}-product.tar.gz
gzip -d ${PRODUCT_NAME}-product.tar.gz
(cd $target_dir && tar --extract --no-same-owner --file=$cwd/${PRODUCT_NAME}-product.tar > /dev/null 2>&1)
if [ $? != 0 ]; then
(cd $target_dir && tar xfo $cwd/${PRODUCT_NAME}-product.tar)
if [ $? != 0 ]; then
exit 1
fi
fi
mkdir -p $target_dir/var/log/error_log
chmod 777 $target_dir/var/log/error_log
target_dir=`readlink -f $target_dir`
sh_profile=""
if [ -w $target_dir/protego_manager ]; then
is_protego="yes"
fi
case $SHELL in
*/csh ) sh_profile=$HOME/.cshrc;;
*/tcsh )
if [ ! -r "$HOME/.tcshrc" ]; then
sh_profile=$HOME/.cshrc
else
sh_profile=$HOME/.tcshrc
fi
;;
*/bash )
if [ -r $HOME/.bash_profile ]; then
sh_profile=$HOME/.bash_profile
elif [ -r $HOME/.bashrc ]; then
sh_profile=$HOME/.bashrc
elif [ -r $HOME/.bash_login ]; then
sh_profile=$HOME/.bash_login
else
sh_profile=$HOME/.profile
fi
;;
*/zsh )
if [ -r $HOME/.zprofile ]; then
sh_profile=$HOME/.zprofile
elif [ -r $HOME/.zshrc ]; then
sh_profile=$HOME/.zshrc
elif [ -r $HOME/.zshenv ]; then
sh_profile=$HOME/.zshenv
elif [ -r $HOME/.zlogin ]; then
sh_profile=$HOME/.zlogin
else
sh_profile=$HOME/.profile
fi
;;
*/sh | */ksh | */ash | */bsh )
sh_profile=$HOME/.profile
;;
esac
case $SHELL in
*/csh | */tcsh )
echo "setenv CUBRID $target_dir" > $XDBMS_ENV_FILE1
echo "setenv CUBRID_DATABASES $target_dir/databases" >> $XDBMS_ENV_FILE1
echo 'if (${?LD_LIBRARY_PATH}) then' >> $XDBMS_ENV_FILE1
echo 'setenv LD_LIBRARY_PATH $CUBRID/lib:${LD_LIBRARY_PATH}' >> $XDBMS_ENV_FILE1
echo 'else' >> $XDBMS_ENV_FILE1
echo 'setenv LD_LIBRARY_PATH $CUBRID/lib' >> $XDBMS_ENV_FILE1
echo 'endif' >> $XDBMS_ENV_FILE1
echo 'setenv SHLIB_PATH $LD_LIBRARY_PATH' >> $XDBMS_ENV_FILE1
echo 'setenv LIBPATH $LD_LIBRARY_PATH' >> $XDBMS_ENV_FILE1
echo 'set path=($CUBRID/{bin,cubridmanager} $path)' >> $XDBMS_ENV_FILE1
;;
esac
#
# make $XDBMS_ENV_FILE2 (.cubrid.sh) to make demodb/subway in this script
#
echo "CUBRID=$target_dir" > $XDBMS_ENV_FILE2
echo "CUBRID_DATABASES=$target_dir/databases" >> $XDBMS_ENV_FILE2
echo 'ld_lib_path=`printenv LD_LIBRARY_PATH`' >> $XDBMS_ENV_FILE2
echo 'if [ "$ld_lib_path" = "" ]' >> $XDBMS_ENV_FILE2
echo 'then' >> $XDBMS_ENV_FILE2
echo 'LD_LIBRARY_PATH=$CUBRID/lib' >> $XDBMS_ENV_FILE2
echo 'else' >> $XDBMS_ENV_FILE2
echo 'LD_LIBRARY_PATH=$CUBRID/lib:$LD_LIBRARY_PATH' >> $XDBMS_ENV_FILE2
echo 'fi' >> $XDBMS_ENV_FILE2
echo 'SHLIB_PATH=$LD_LIBRARY_PATH' >> $XDBMS_ENV_FILE2
echo 'LIBPATH=$LD_LIBRARY_PATH' >> $XDBMS_ENV_FILE2
echo 'PATH=$CUBRID/bin:$CUBRID/cubridmanager:$PATH' >> $XDBMS_ENV_FILE2
echo "export CUBRID" >> $XDBMS_ENV_FILE2
echo "export CUBRID_DATABASES" >> $XDBMS_ENV_FILE2
echo 'export LD_LIBRARY_PATH' >> $XDBMS_ENV_FILE2
echo 'export SHLIB_PATH' >> $XDBMS_ENV_FILE2
echo 'export LIBPATH' >> $XDBMS_ENV_FILE2
echo 'export PATH' >> $XDBMS_ENV_FILE2
append_profile=""
if [ -n $sh_profile ]; then
append_profile=`grep "${PRODUCT_NAME} environment" ${sh_profile}`
fi
if [ -z "${append_profile}" ]; then
echo '' >> $sh_profile
echo '#-------------------------------------------------------------------------------' >> $sh_profile
echo '# set '${PRODUCT_NAME}' environment variables' >> $sh_profile
echo '#-------------------------------------------------------------------------------' >> $sh_profile
case $SHELL in
*/csh | */tcsh )
echo "source $XDBMS_ENV_FILE1" >> $sh_profile
;;
* )
echo ". $XDBMS_ENV_FILE2" >> $sh_profile
;;
esac
echo '' >> $sh_profile
echo '' >> $sh_profile
fi
if [ $? = 0 ]; then
echo ""
echo "${PRODUCT_NAME} has been successfully installed."
echo ""
else
echo ""
echo "Cannot install CUBRID."
echo ""
exit 1
fi
# Make demodb
if [ -r "$XDBMS_ENV_FILE2" ]; then
. $XDBMS_ENV_FILE2
if [ $cp_old_dbtxt = "yes" ]; then
rm -f $target_dir/databases/databases.txt
cp $target_dir/CUBRID_DATABASES/databases.txt $target_dir/databases
fi
if [ $is_protego = "no" ]; then
if [ -r $CUBRID/demo/make_cubrid_demo.sh ]; then
# echo 'Create demodb...'
(mkdir -p $CUBRID_DATABASES/demodb ; cd $CUBRID_DATABASES/demodb ; $CUBRID/demo/make_cubrid_demo.sh > /dev/null 2>&1)
if [ $? = 0 ]; then
echo "demodb has been successfully created."
else
echo "Cannot create demodb."
fi
fi
fi
fi
echo ""
echo "If you want to use ${PRODUCT_NAME}, run the following commands"
case $SHELL in
*/csh | */tcsh )
echo " % source $XDBMS_ENV_FILE1"
;;
* )
echo " % . $XDBMS_ENV_FILE2"
;;
esac
echo " % cubrid service start"
echo ""
#if (${?demodb} && $demodb == 'true') then
# echo 'If you want to start up demodb, run the following commans'
# echo " % start_server demodb"
#endif
#./confcp.sh $target_dir
targets=$(ls $target_dir/conf/*-dist)
for arg in $targets
do
file=${arg%%-dist}
# save old conf file
if [ -f $file ]; then
mv -f "$file" "$file".save > /dev/null 2>&1
fi
mv -f "$file"-dist "$file" > /dev/null 2>&1
done
cp -f COPYING $CUBRID
END_OF_FILE
}
function print_check_glibc_version_c ()
{
cat << \END_OF_FILE
#include <stdio.h>
#include <gnu/libc-version.h>
int build_version = BUILD_VERSION;
int (main)(void)
{
const char *v = gnu_get_libc_version();
if (v == NULL)
return 1;
switch (build_version) {
case 232:
if (strcmp(v, "2.3.2") == 0)
return 0;
break;
case 234:
if (strcmp(v, "2.3.4") >= 0)
return 0;
break;
}
return 1;
}
END_OF_FILE
}
function build_bin_pack ()
{
if [ $# -lt 2 ]; then
print_error "Missing product name or target"
return 1
else
package_file="$1"
pack_target="$2"
fi
archive_dir="$install_dir/$product_name"
if [ "$prefix_dir" != "$archive_dir" ]; then
cp -rf $prefix_dir $archive_dir
fi
if [ "$pack_target" = "tarball" ]; then
(cd $install_dir && tar czf $package_file $product_name)
return $?
elif [ "$pack_target" != "shell" ]; then
print_error "Unknown target"
return 1
fi
# prepare extra files
cp $source_dir/COPYING $install_dir
print_install_sh > $install_dir/CUBRID_Install.sh
chmod a+x $install_dir/CUBRID_Install.sh
print_setup_sh > $install_dir/CUBRID_Setup.sh
chmod a+x $install_dir/CUBRID_Setup.sh
print_check_glibc_version_c > $install_dir/check_glibc_version.c
if ! gcc -o $install_dir/check_glibc_version -DBUILD_VERSION=234 $install_dir/check_glibc_version.c; then
print_fatal "Check_glibc_version build error"
fi
echo "version=\"$major.$minor\"" > $install_dir/version.sh
echo "BuildNumber=$build_number" >> $install_dir/version.sh
conf_files=$(ls $archive_dir/conf/*.conf $archive_dir/conf/*.pass $archive_dir/conf/*.txt 2> /dev/null)
for file in $conf_files; do
if [ -f $file ]; then
mv -f $file $file-dist
fi
if [ ! -f $file-dist ]; then
print_fatal "Config file [$file-dist] not found"
fi
done
(cd $install_dir/$product_name &&
tar zcf $install_dir/CUBRID-product.tar.gz * &&
cd $install_dir && mv -f CUBRID_Install.sh $package_file &&
tar cf - CUBRID-product.tar.gz CUBRID_Setup.sh COPYING version.sh check_glibc_version >> $package_file)
for file in $conf_files; do
mv -f $file-dist $file
done
}
function build_rpm ()
{
print_check "Preparing RPM package directory"
if [ $# -lt 2 ]; then
print_error "Missing source tarball filename or target"
return 1
else
source_tarball="$1"
rpm_target="$2"
fi
if [ ! -f "$source_tarball" ]; then
print_error "Source tarball [$source_tarball] is not exist"
return 1
else
print_info "Using source tarball [$source_tarball]"
rpm_output_dir=$(dirname $source_tarball)
fi
mkdir -p $install_dir/rpmbuild/{BUILD,RPMS,SPECS,SOURCES,SRPMS}
print_result "OK"
case $rpm_target in
srpm)
rpmbuild --define="_topdir $install_dir/rpmbuild" --clean -ts $source_tarball
[ $? -eq 0 ] && mv -f $install_dir/rpmbuild/SRPMS/$product_name_lower-$build_number-*.src.rpm $rpm_output_dir
;;
rpm)
rpmbuild --define="_topdir $install_dir/rpmbuild" --define="_tmppath $install_dir/rpmbuild/tmp" --clean -tb --target=$build_target $source_tarball
[ $? -eq 0 ] && mv -f $install_dir/rpmbuild/RPMS/$build_target/$product_name_lower-$build_number-*.$build_target.rpm $rpm_output_dir
;;
*)
print_error "Unknown target"
return 1
;;
esac
}
function build_package ()
{
print_check "Preparing package directory"
if [ ! -d "$build_dir" ]; then
print_fatal "Build directory not found. please build first"
fi
print_check "Checking manager server directory"
if [ ! -d "$source_dir/cubridmanager" -o ! -d "$source_dir/cubridmanager/server" ]; then
without_cmserver="true"
print_error "Manager server source path is not exist. It will not be packaged"
fi
if [ ! -d $output_dir ]; then
mkdir -p $output_dir
fi
# create additional dirs for binary package
pre_created_dirs="databases var var/log var/tmp var/run var/lock var/manager log log/manager"
for dir in $pre_created_dirs; do
mkdir -p "$prefix_dir/$dir"
done
# copy files for binary package
pre_installed_files="COPYING README CREDITS"
for file in $pre_installed_files; do
cp $source_dir/$file "$prefix_dir"
done
src_package_name="$product_name_lower-$build_number.tar.gz"
print_result "OK"
for package in $packages; do
print_check "Packing package for $package"
case $package in
src)
if [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode source tarball is not supported. Skip"
package_name="NONE"
else
package_name="$src_package_name"
# make dist for pack sources
(cd $build_dir && make dist)
if [ $? -eq 0 ]; then
output_packages="$output_packages $package_name"
[ $build_dir -ef $output_dir ] || mv -f $build_dir/$package_name $output_dir
else
false
fi
fi
;;
zip_src)
if [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode source zip is not supported. Skip"
package_name="NONE"
else
package_name="$product_name_lower-$build_number.zip"
# make dist-zip for pack sources
(cd $build_dir && make dist-zip)
if [ $? -eq 0 ]; then
output_packages="$output_packages $package_name"
[ $build_dir -ef $output_dir ] || mv -f $build_dir/$package_name $output_dir
else
false
fi
fi
;;
cci_src)
if [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode cci source tarball is not supported. Skip"
package_name="NONE"
else
package_basename="$product_name_lower-cci"
package_name="$package_basename-$build_number.tar.gz"
# make dist for pack cci sources
if [ -d "$build_dir/$package_basename" ]; then
rm -rf $build_dir/$package_basename
fi
mkdir $build_dir/$package_basename
if [ "$(readlink -f $build_dir/..)" = "$source_dir" ]; then
configure_dir="../.."
else
configure_dir="$source_dir"
fi
(cd $build_dir/$package_basename && $configure_dir/configure --with-cci-only && make PACKAGE=$package_basename dist && mv $package_name $build_dir)
if [ $? -eq 0 ]; then
output_packages="$output_packages $package_name"
[ $build_dir -ef $output_dir ] || mv -f $build_dir/$package_name $output_dir
else
false
fi
fi
;;
php_src)
if [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode php source tarball is not supported. Skip"
package_name="NONE"
else
package_basename="$product_name-php-$build_number"
package_name="$package_basename.tar.gz"
if [ -d "$build_dir/$package_basename" ]; then
rm -rf $build_dir/$package_basename
fi
mkdir $build_dir/$package_basename
cp -r $source_dir/contrib/php* $build_dir/$package_basename/
(cd $build_dir && tar czf $output_dir/$package_name $package_basename)
if [ $? -eq 0 ]; then
output_packages="$output_packages $package_name"
rm -rf $build_dir/$package_basename
else
false
fi
fi
;;
tarball|shell)
if [ ! -d "$install_dir" -o ! -d "$prefix_dir" ]; then
print_fatal "Installed directory or prefix directory not found"
fi
package_basename="$product_name-$build_number-linux.$build_target"
if [ ! "$build_mode" = "release" ]; then
package_basename="$package_basename-$build_mode"
fi
if [ "$package" = tarball ]; then
package_name="$package_basename.tar.gz"
else
package_name="$package_basename.sh"
fi
if [ "$package" = "shell" -a "$without_cmserver" = "true" ]; then
print_info "CUBRID manager server is disabled. Skip shell package"
else
build_bin_pack $output_dir/$package_name $package
fi
[ $? -eq 0 ] && output_packages="$output_packages $package_name"
;;
cci)
if [ ! -d "$install_dir" ]; then
print_fatal "Installed directory not found"
fi
package_basename="$product_name-CCI-$build_number-$build_target"
if [ ! "$build_mode" = "release" ]; then
package_name="$package_basename-$build_mode.tar.gz"
else
package_name="$package_basename.tar.gz"
fi
cci_headers="include/cas_cci.h include/cas_error.h"
cci_libs="lib/libcascci.a lib/libcascci.so*"
for file in $cci_headers $cci_libs; do
pack_file_list="$pack_file_list $product_name/$file"
done
(cd $install_dir && tar czf $output_dir/$package_name $pack_file_list)
[ $? -eq 0 ] && output_packages="$output_packages $package_name"
;;
jdbc)
if [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode JDBC is not supported. Skip"
package_name="NONE"
else
package_name="JDBC-$build_number-$product_name_lower"
jar_files=$(cd $build_dir/jdbc && ls $package_name*.jar)
cp $build_dir/jdbc/$package_name*.jar $output_dir
[ $? -eq 0 ] && output_packages="$output_packages $jar_files"
fi
;;
srpm)
if [ "$without_cmserver" = "true" ]; then
print_info "CUBRID manager server is disabled. Skip SRPM build"
elif [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode SRPM is not supported. Skip"
package_name="NONE"
else
package_name="$product_name-$build_number...src.rpm"
build_rpm $output_dir/$src_package_name $package
if [ $? -eq 0 ]; then
rpm_pkgs=$(cd $output_dir && ls $product_name_lower-$build_number-*.src.rpm)
[ $? -eq 0 ] && output_packages="$output_packages $rpm_pkgs"
else
false
fi
fi
;;
rpm)
if [ "$without_cmserver" = "true" ]; then
print_info "CUBRID manager server is disabled. Skip RPM build"
elif [ ! "$build_mode" = "release" ]; then
print_info "$build_mode mode RPM or SRPM is not supported. Skip"
package_name="NONE"
else
package_name="$product_name-$build_number...rpm"
build_rpm $output_dir/$src_package_name $package
if [ $? -eq 0 ]; then
rpm_pkgs=$(cd $output_dir && ls $product_name_lower-$build_number-*.$build_target.rpm)
[ $? -eq 0 ] && output_packages="$output_packages $rpm_pkgs"
else
false
fi
fi
;;
dbgwci)
if [ ! -d "$install_dir" ]; then
print_fatal "Installed directory not found"
fi
package_basename="$product_name-DBGWCI-$build_number-$build_target"
if [ ! "$build_mode" = "release" ]; then
package_name="$package_basename-$build_mode.tar.gz"
else
package_name="$package_basename.tar.gz"
fi
cci_headers="include/cas_cci.h include/cas_error.h"
dbgw_headers="
include/cci_log.h
include/DBGWClient.h
include/DBGWConnector3.h
include/dbgw3/Common.h
include/dbgw3/Exception.h
include/dbgw3/Lob.h
include/dbgw3/Logger.h
include/dbgw3/Value.h
include/dbgw3/ValueSet.h
include/dbgw3/SynchronizedResource.h
include/dbgw3/system/ThreadEx.h
include/dbgw3/system/DBGWPorting.h
include/dbgw3/sql/CallableStatement.h
include/dbgw3/sql/Connection.h
include/dbgw3/sql/DatabaseInterface.h
include/dbgw3/sql/DriverManager.h
include/dbgw3/sql/PreparedStatement.h
include/dbgw3/sql/ResultSet.h
include/dbgw3/sql/ResultSetMetaData.h
include/dbgw3/sql/Statement.h
include/dbgw3/client/Interface.h
include/dbgw3/client/Mock.h
include/dbgw3/client/ConfigurationObject.h
include/dbgw3/client/Configuration.h
include/dbgw3/client/ClientResultSet.h
include/dbgw3/client/Resource.h
include/dbgw3/client/QueryMapper.h
include/dbgw3/client/Client.h
"
cci_libs="lib/libcascci.a lib/libcascci.so*"
dbgw_libs="lib/libdbgw3.a"
dbgw_libs="lib/libdbgw3.so* $dbgw_libs"
if [ "$build_target" == "x86_64" ]; then
dbgw_libs="lib/libdbgw3_all.a $dbgw_libs"
dbgw_libs="lib/libdbgw3_mysql.a $dbgw_libs"
dbgw_libs="lib/libdbgw3_oracle.a $dbgw_libs"
dbgw_libs="lib/libdbgw3_nbase_t.a* $dbgw_libs"