-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebscalesql.spec
2082 lines (1608 loc) · 80.1 KB
/
webscalesql.spec
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
# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
# MA 02110-1301 USA.
# NOTE:
# This spec file is based on the MySQL spec file provided by Oracle
# and used to build MySQL rpms, but modified to build WebScaleSQL.
#
# See http:://webscalesql.org/ for more information on WebScaleSQL.
#
# See: https://github.com/sjmudd/webscalesql-rpm/ for more information on
# building these rpms. My blog site may also be of interest.
# See: http://blog.wl0.org/.
#
# Simon J Mudd <sjmudd@pobox.com>
##############################################################################
# Some common macro definitions
##############################################################################
# NOTE: "vendor" is used in upgrade/downgrade check, so you can't
# change these without checking carefully.
%global vendor_mysql MySQL AB
%global vendor_sun Sun Microsystems, Inc.
%global vendor_oracle Oracle and/or its affiliates
%global vendor_wss webscalesql.org
%global webscalesql_version 5.6.19.68
%global mysqld_user mysql
%global mysqld_group mysql
%global mysqldatadir /var/lib/mysql
%global release 1
#
# Macros we use which are not available in all supported versions of RPM
#
# - defined/undefined are missing on RHEL4
#
%if %{expand:%{?defined:0}%{!?defined:1}}
%define defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
%endif
%if %{expand:%{?undefined:0}%{!?undefined:1}}
%define undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
%endif
# ----------------------------------------------------------------------------
# RPM build tools now automatically detect Perl module dependencies. This
# detection causes problems as it is broken in some versions, and it also
# provides unwanted dependencies from mandatory scripts in our package.
# It might not be possible to disable this in all versions of RPM, but here we
# try anyway. We keep the "AutoReqProv: no" for the "test" sub package, as
# disabling here might fail, and that package has the most problems.
# See:
# http://fedoraproject.org/wiki/Packaging/Perl#Filtering_Requires:_and_Provides
# http://www.wideopen.com/archives/rpm-list/2002-October/msg00343.html
# ----------------------------------------------------------------------------
%undefine __perl_provides
%undefine __perl_requires
##############################################################################
# Command line handling
##############################################################################
#
# To set options:
#
# $ rpmbuild --define="option <x>" ...
#
# ----------------------------------------------------------------------------
# Source name
# ----------------------------------------------------------------------------
%if %{undefined src_base}
%define src_base webscalesql
%endif
%define src_dir %{src_base}-%{webscalesql_version}
# ----------------------------------------------------------------------------
# Feature set (storage engines, options). Default to community (everything)
# ----------------------------------------------------------------------------
%if %{undefined feature_set}
%define feature_set community
%endif
# ----------------------------------------------------------------------------
# Server comment strings
# ----------------------------------------------------------------------------
%if %{undefined compilation_comment_debug}
%define compilation_comment_debug WebScaleSQL Server - Debug (GPL)
%endif
%if %{undefined compilation_comment_release}
%define compilation_comment_release WebScaleSQL Server (GPL)
%endif
# ----------------------------------------------------------------------------
# Product and server suffixes
# ----------------------------------------------------------------------------
%if %{undefined product_suffix}
%if %{defined short_product_tag}
%define product_suffix -%{short_product_tag}
%else
%define product_suffix %{nil}
%endif
%endif
%if %{undefined server_suffix}
%define server_suffix %{nil}
%endif
# ----------------------------------------------------------------------------
# Distribution support
# ----------------------------------------------------------------------------
%if %{undefined distro_specific}
%define distro_specific 0
%endif
%if %{distro_specific}
%if %(test -f /etc/enterprise-release && echo 1 || echo 0)
%define oelver %(rpm -qf --qf '%%{version}\\n' /etc/enterprise-release | sed -e 's/^\\([0-9]*\\).*/\\1/g')
%if "%oelver" == "4"
%define distro_description Oracle Enterprise Linux 4
%define distro_releasetag oel4
%define distro_buildreq gcc-c++ gperf ncurses-devel perl time zlib-devel cmake libaio-devel
%define distro_requires chkconfig coreutils grep procps shadow-utils net-tools
%else
%if "%oelver" == "5"
%define distro_description Oracle Enterprise Linux 5
%define distro_releasetag oel5
%define distro_buildreq gcc-c++ gperf ncurses-devel perl time zlib-devel cmake libaio-devel
%define distro_requires chkconfig coreutils grep procps shadow-utils net-tools
%else
%{error:Oracle Enterprise Linux %{oelver} is unsupported}
%endif
%endif
%else
%if %(test -f /etc/oracle-release && echo 1 || echo 0)
%define elver %(rpm -qf --qf '%%{version}\\n' /etc/oracle-release | sed -e 's/^\\([0-9]*\\).*/\\1/g')
%if "%elver" == "6"
%define distro_description Oracle Linux 6
%define distro_releasetag el6
# gcc-c++ and build requirement deliberately removed. FIXME and do this cleanly.
%define distro_buildreq ncurses-devel perl time zlib-devel cmake libaio-devel readline-devel
%define distro_requires chkconfig coreutils grep procps shadow-utils net-tools readline libaio
%else
%{error:Oracle Linux %{elver} is unsupported}
%endif
%else
%if %(test -f /etc/redhat-release && echo 1 || echo 0)
%define rhelver %(rpm -qf --qf '%%{version}\\n' /etc/redhat-release | sed -e 's/^\\([0-9]*\\).*/\\1/g')
%if "%rhelver" == "4"
%define distro_description Red Hat Enterprise Linux 4
%define distro_releasetag rhel4
%define distro_buildreq gcc-c++ gperf ncurses-devel perl time zlib-devel cmake libaio-devel
%define distro_requires chkconfig coreutils grep procps shadow-utils net-tools
%else
%if "%rhelver" == "5"
%define distro_description Red Hat Enterprise Linux 5
%define distro_releasetag rhel5
%define distro_buildreq gcc-c++ gperf ncurses-devel perl time zlib-devel cmake libaio-devel
%define distro_requires chkconfig coreutils grep procps shadow-utils net-tools
%else
%if "%rhelver" == "6"
%define distro_description Red Hat Enterprise Linux 6
%define distro_releasetag rhel6
# gcc-c++ and build requirement deliberately removed. FIXME and do this cleanly.
%define distro_buildreq ncurses-devel perl time zlib-devel cmake libaio-devel readline-devel
%define distro_requires chkconfig coreutils grep procps shadow-utils net-tools readline libaio
%else
%{error:Red Hat Enterprise Linux %{rhelver} is unsupported}
%endif
%endif
%endif
%else
%if %(test -f /etc/SuSE-release && echo 1 || echo 0)
%define susever %(rpm -qf --qf '%%{version}\\n' /etc/SuSE-release | cut -d. -f1)
%if "%susever" == "10"
%define distro_description SUSE Linux Enterprise Server 10
%define distro_releasetag sles10
%define distro_buildreq gcc-c++ gdbm-devel gperf ncurses-devel openldap2-client zlib-devel cmake libaio-devel
%define distro_requires aaa_base coreutils grep procps pwdutils
%else
%if "%susever" == "11"
%define distro_description SUSE Linux Enterprise Server 11
%define distro_releasetag sles11
%define distro_buildreq gcc-c++ gdbm-devel gperf ncurses-devel openldap2-client procps pwdutils zlib-devel cmake libaio-devel
%define distro_requires aaa_base coreutils grep procps pwdutils
%else
%{error:SuSE %{susever} is unsupported}
%endif
%endif
%else
%{error:Unsupported distribution}
%endif
%endif
%endif
%endif
%else
%define glibc_version %(/lib/libc.so.6 | grep stable | cut -d, -f1 | cut -c38-)
%define distro_description Generic Linux (glibc %{glibc_version})
%define distro_releasetag linux_glibc%{glibc_version}
%define distro_buildreq gcc-c++ gperf ncurses-devel perl time zlib-devel
%define distro_requires coreutils grep procps /sbin/chkconfig /usr/sbin/useradd /usr/sbin/groupadd
%endif
# Avoid debuginfo RPMs, leaves binaries unstripped
%define debug_package %{nil}
# Hack to work around bug in RHEL5 __os_install_post macro, wrong inverted
# test for __debug_package
%define __strip /bin/true
# ----------------------------------------------------------------------------
# Support optional "tcmalloc" library (experimental)
# ----------------------------------------------------------------------------
%if %{defined malloc_lib_target}
%define WITH_TCMALLOC 1
%else
%define WITH_TCMALLOC 0
%endif
##############################################################################
# Configuration based upon above user input, not to be set directly
##############################################################################
%define license_files_server %{src_dir}/COPYING %{src_dir}/README
%define license_type GPL
##############################################################################
# Main spec file section
##############################################################################
Name: webscalesql%{product_suffix}
Summary: WebScaleSQL: a very fast and reliable SQL database server
Group: Applications/Databases
Version: %{webscalesql_version}
Release: %{release}%{?distro_releasetag:.%{distro_releasetag}}
Distribution: %{distro_description}
License: GPL v2
Source: webscalesql-%{webscalesql_version}.tar.gz
URL: http://www.webscalesql.org/
Packager: Simon J Mudd <sjmudd@pobox.com>
Vendor: %{vendor_wss}
BuildRequires: %{distro_buildreq}
# Regression tests may take a long time, override the default to skip them
%{!?runselftest:%global runselftest 1}
# Think about what you use here since the first step is to
# run a rm -rf
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# From the WebScaleSQL page
%description
WebScaleSQL is a collaboration among engineers from several companies
that face similar challenges in running MySQL at scale, and seek greater
performance from a database technology tailored for their needs.
Our goal in launching WebScaleSQL is to enable the scale-oriented
members of the MySQL community to work more closely together in order to
prioritize the aspects that are most important to us. We aim to create a
more integrated system of knowledge-sharing to help companies leverage the
great features already found in MySQL 5.6, while building and adding more
features that are specific to deployments in large scale environments. In
the last few months, engineers from all four companies have contributed
code and provided feedback to each other to develop a new, more unified,
and more collaborative branch of MySQL.
But as effective as this collaboration has been so far, we know we’re
not the only ones who are trying to solve these particular challenges. So
we will keep WebScaleSQL open as we go, to encourage others who have
the scale and resources to customize MySQL to join in our efforts. And
of course we will welcome input from anyone who wants to contribute,
regardless of what they are currently working on.
##############################################################################
# Sub package definition
##############################################################################
%package -n webscalesql-server%{product_suffix}
Summary: WebScaleSQL: a very fast and reliable SQL database server
Group: Applications/Databases
Requires: %{distro_requires}
Obsoletes: MySQL-server
Obsoletes: MySQL-server-advanced
Obsoletes: mysql-server < %{version}-%{release}
Obsoletes: mysql-server-advanced
Obsoletes: MySQL-server-classic MySQL-server-community MySQL-server-enterprise
Obsoletes: MySQL-server-advanced-gpl MySQL-server-enterprise-gpl
Provides: mysql-server = %{version}-%{release}
Provides: mysql-server%{?_isa} = %{version}-%{release}
%description -n webscalesql-server%{product_suffix}
WebScaleSQL provides a fast SQL database server based on MySQL.
The WebScaleSQL web site (http://webscalesql.org/) provides the latest news and
information about the WebScaleSQL software. Also please see the documentation
and the manual for more information.
This package includes the WebScaleSQL server binary as well as related utilities
to run and administer a WebScaleSQL server.
If you want to access and work with the database, you have to install
package "webscalesql-client%{product_suffix}" as well!
# ----------------------------------------------------------------------------
%package -n webscalesql-client%{product_suffix}
Summary: WebScaleSQL - Client
Group: Applications/Databases
Obsoletes: MySQL-client
Obsoletes: MySQL-client-advanced
Obsoletes: mysql < %{version}-%{release}
Obsoletes: mysql-advanced < %{version}-%{release}
Obsoletes: MySQL-client-classic MySQL-client-community MySQL-client-enterprise
Obsoletes: MySQL-client-advanced-gpl MySQL-client-enterprise-gpl
Provides: mysql = %{version}-%{release}
Provides: mysql%{?_isa} = %{version}-%{release}
%description -n webscalesql-client%{product_suffix}
This package contains the standard WebScaleSQL clients and administration tools.
For a description of WebScaleSQL see the base webscalesql RPM or http://www.webscalesql.org/
# ----------------------------------------------------------------------------
%package -n webscalesql-test%{product_suffix}
Summary: WebScaleSQL - Test suite
Group: Applications/Databases
Requires: webscalesql-client perl
Obsoletes: MySQL-test
Obsoletes: MySQL-test-advanced
Obsoletes: mysql-test < %{version}-%{release}
Obsoletes: mysql-test-advanced
Obsoletes: MySQL-test-classic MySQL-test-community MySQL-test-enterprise
Obsoletes: MySQL-test-advanced-gpl MySQL-test-enterprise-gpl
Provides: mysql-test = %{version}-%{release}
Provides: mysql-test%{?_isa} = %{version}-%{release}
AutoReqProv: no
%description -n webscalesql-test%{product_suffix}
This package contains the WebScaleSQL regression test suite.
For a description of WebScaleSQL see the base webscalesql RPM or http://www.webscalesql.org/
# ----------------------------------------------------------------------------
%package -n webscalesql-devel%{product_suffix}
Summary: WebScaleSQL - Development header files and libraries
Group: Applications/Databases
Obsoletes: MySQL-devel
Obsoletes: MySQL-devel-advanced
Obsoletes: mysql-devel < %{version}-%{release}
Obsoletes: mysql-embedded-devel mysql-devel-advanced mysql-embedded-devel-advanced
Obsoletes: MySQL-devel-classic MySQL-devel-community MySQL-devel-enterprise
Obsoletes: MySQL-devel-advanced-gpl MySQL-devel-enterprise-gpl
Provides: mysql-devel = %{version}-%{release}
Provides: mysql-devel%{?_isa} = %{version}-%{release}
%description -n webscalesql-devel%{product_suffix}
This package contains the development header files and libraries necessary
to develop WebScaleSQL client applications.
For a description of WebScaleSQL see the base webscalesql RPM or http://www.webscalesql.org/
# ----------------------------------------------------------------------------
%package -n webscalesql-shared%{product_suffix}
Summary: WebScaleSQL - Shared libraries
Group: Applications/Databases
Obsoletes: MySQL-shared
Obsoletes: MySQL-shared-advanced
Obsoletes: MySQL-shared-standard MySQL-shared-pro
Obsoletes: MySQL-shared-pro-cert MySQL-shared-pro-gpl
Obsoletes: MySQL-shared-pro-gpl-cert
Obsoletes: MySQL-shared-classic MySQL-shared-community MySQL-shared-enterprise
Obsoletes: MySQL-shared-advanced-gpl MySQL-shared-enterprise-gpl
%description -n webscalesql-shared%{product_suffix}
This package contains the shared libraries (*.so*) which certain languages
and applications need to dynamically load and use WebScaleSQL.
# ----------------------------------------------------------------------------
%package -n webscalesql-embedded%{product_suffix}
Summary: WebScaleSQL - Embedded library
Group: Applications/Databases
Requires: webscalesql-devel
Obsoletes: MySQL-embedded
Obsoletes: MySQL-embedded-advanced
Obsoletes: mysql-embedded < %{version}-%{release}
Obsoletes: mysql-embedded-advanced
Obsoletes: MySQL-embedded-pro
Obsoletes: MySQL-embedded-classic MySQL-embedded-community MySQL-embedded-enterprise
Obsoletes: MySQL-embedded-advanced-gpl MySQL-embedded-enterprise-gpl
Provides: mysql-embedded = %{version}-%{release}
Provides: mysql-emdedded%{?_isa} = %{version}-%{release}
%description -n webscalesql-embedded%{product_suffix}
This package contains the WebScaleSQL server as an embedded library.
The embedded WebScaleSQL server library makes it possible to run a full-featured
WebScaleSQL server inside the client application. The main benefits are increased
speed and more simple management for embedded applications.
The API is identical for the embedded WebScaleSQL version and the
client/server version.
For a description of WebScaleSQL see the base webscalesql RPM or http://www.webscalesql.org/
##############################################################################
%prep
%setup -T -a 0 -c -n %{src_dir}
##############################################################################
%build
# Fail quickly and obviously if user tries to build as root
%if %runselftest
if [ x"`id -u`" = x0 ]; then
echo "The WebScaleSQL regression tests may fail if run as root."
echo "If you really need to build the RPM as root, use"
echo "--define='runselftest 0' to skip the regression tests."
exit 1
fi
%endif
# Be strict about variables, bail at earliest opportunity, etc.
set -eu
# Optional package files
touch optional-files-devel
#
# Set environment in order of preference, MYSQL_BUILD_* first, then variable
# name, finally a default. RPM_OPT_FLAGS is assumed to be a part of the
# default RPM build environment.
#
# This is a hack, $RPM_OPT_FLAGS on ia64 hosts contains flags which break
# the compile in cmd-line-utils/libedit - needs investigation, but for now
# we simply unset it and use those specified directly in cmake.
%if "%{_arch}" == "ia64"
RPM_OPT_FLAGS=
%endif
export PATH=${MYSQL_BUILD_PATH:-$PATH}
export CC=${MYSQL_BUILD_CC:-${CC:-gcc}}
export CXX=${MYSQL_BUILD_CXX:-${CXX:-g++}}
export CFLAGS=${MYSQL_BUILD_CFLAGS:-${CFLAGS:-$RPM_OPT_FLAGS}}
export CXXFLAGS=${MYSQL_BUILD_CXXFLAGS:-${CXXFLAGS:-$RPM_OPT_FLAGS -felide-constructors}}
export LDFLAGS=${MYSQL_BUILD_LDFLAGS:-${LDFLAGS:-}}
export CMAKE=${MYSQL_BUILD_CMAKE:-${CMAKE:-cmake}}
export MAKE_JFLAG=${MYSQL_BUILD_MAKE_JFLAG:-}
# By default, a build will include the bundeled "yaSSL" library for SSL.
# However, there may be a need to override.
# Protect against undefined variables if there is no override option.
%if %{undefined with_ssl}
%define ssl_option %{nil}
%else
%define ssl_option -DWITH_SSL=%{with_ssl}
%endif
# Build debug mysqld and libmysqld.a
mkdir debug
(
cd debug
# Attempt to remove any optimisation flags from the debug build
CFLAGS=`echo " ${CFLAGS} " | \
sed -e 's/ -O[0-9]* / /' \
-e 's/ -unroll2 / /' \
-e 's/ -ip / /' \
-e 's/^ //' \
-e 's/ $//'`
CXXFLAGS=`echo " ${CXXFLAGS} " | \
sed -e 's/ -O[0-9]* / /' \
-e 's/ -unroll2 / /' \
-e 's/ -ip / /' \
-e 's/^ //' \
-e 's/ $//'`
# XXX: MYSQL_UNIX_ADDR should be in cmake/* but webscalesql_version is included before
# XXX: install_layout so we can't just set it based on INSTALL_LAYOUT=RPM
${CMAKE} ../%{src_dir} -DBUILD_CONFIG=mysql_release -DINSTALL_LAYOUT=RPM \
-DWITH_INNODB_MEMCACHED=1 -DCMAKE_BUILD_TYPE=Debug \
-DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \
-DFEATURE_SET="%{feature_set}" \
%{ssl_option} \
-DCOMPILATION_COMMENT="%{compilation_comment_debug}" \
-DMYSQL_SERVER_SUFFIX="%{server_suffix}"
echo BEGIN_DEBUG_CONFIG ; egrep '^#define' include/config.h ; echo END_DEBUG_CONFIG
make ${MAKE_JFLAG} VERBOSE=1
)
# Build full release
mkdir release
(
cd release
# XXX: MYSQL_UNIX_ADDR should be in cmake/* but webscalesql_version is included before
# XXX: install_layout so we can't just set it based on INSTALL_LAYOUT=RPM
${CMAKE} ../%{src_dir} -DBUILD_CONFIG=mysql_release -DINSTALL_LAYOUT=RPM \
-DWITH_INNODB_MEMCACHED=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \
-DFEATURE_SET="%{feature_set}" \
%{ssl_option} \
-DCOMPILATION_COMMENT="%{compilation_comment_release}" \
-DMYSQL_SERVER_SUFFIX="%{server_suffix}"
echo BEGIN_NORMAL_CONFIG ; egrep '^#define' include/config.h ; echo END_NORMAL_CONFIG
make ${MAKE_JFLAG} VERBOSE=1
)
%if %runselftest
MTR_BUILD_THREAD=auto
export MTR_BUILD_THREAD
(cd release && make test-bt-fast || true)
%endif
##############################################################################
%install
RBR=$RPM_BUILD_ROOT
MBD=$RPM_BUILD_DIR/%{src_dir}
# Ensure that needed directories exists
install -d $RBR%{_sysconfdir}/{logrotate.d,init.d}
install -d $RBR%{mysqldatadir}/mysql
install -d $RBR%{_datadir}/mysql-test
install -d $RBR%{_datadir}/mysql/SELinux/RHEL4
install -d $RBR%{_includedir}
install -d $RBR%{_libdir}
install -d $RBR%{_mandir}
install -d $RBR%{_sbindir}
# Install all binaries
(
cd $MBD/release
make DESTDIR=$RBR install
)
# FIXME: at some point we should stop doing this and just install everything
# FIXME: directly into %{_libdir}/mysql - perhaps at the same time as renaming
# FIXME: the shared libraries to use libmysql*-$major.$minor.so syntax
mv -v $RBR/%{_libdir}/*.a $RBR/%{_libdir}/mysql/
# Install logrotate and autostart
install -m 644 $MBD/release/support-files/mysql-log-rotate $RBR%{_sysconfdir}/logrotate.d/mysql
install -m 755 $MBD/release/support-files/mysql.server $RBR%{_sysconfdir}/init.d/mysql
# Create a symlink "rcmysql", pointing to the init.script. SuSE users
# will appreciate that, as all services usually offer this.
ln -s %{_sysconfdir}/init.d/mysql $RBR%{_sbindir}/rcmysql
# Touch the place where the my.cnf config file might be located
# Just to make sure it's in the file list and marked as a config file
touch $RBR%{_sysconfdir}/my.cnf
# Install SELinux files in datadir
install -m 600 $MBD/%{src_dir}/support-files/RHEL4-SElinux/mysql.{fc,te} \
$RBR%{_datadir}/mysql/SELinux/RHEL4
%if %{WITH_TCMALLOC}
# Even though this is a shared library, put it under /usr/lib*/mysql, so it
# doesn't conflict with possible shared lib by the same name in /usr/lib*. See
# `mysql_config --variable=pkglibdir` and mysqld_safe for how this is used.
install -m 644 "%{malloc_lib_source}" \
"$RBR%{_libdir}/mysql/%{malloc_lib_target}"
%endif
# Remove man pages we explicitly do not want to package, avoids 'unpackaged
# files' warning.
# This has become obsolete: rm -f $RBR%{_mandir}/man1/make_win_bin_dist.1*
##############################################################################
# Post processing actions, i.e. when installed
##############################################################################
%pre -n webscalesql-server%{product_suffix}
# This is the code running at the beginning of a RPM upgrade action,
# before replacing the old files with the new ones.
# ATTENTION: Parts of this are duplicated in the "triggerpostun" !
# There are users who deviate from the default file system layout.
# Check local settings to support them.
if [ -x %{_bindir}/my_print_defaults ]
then
mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
PID_FILE_PATT=`%{_bindir}/my_print_defaults server mysqld | grep '^--pid-file=' | sed -n 's/--pid-file=//p'`
fi
if [ -z "$mysql_datadir" ]
then
mysql_datadir=%{mysqldatadir}
fi
if [ -z "$PID_FILE_PATT" ]
then
PID_FILE_PATT="$mysql_datadir/*.pid"
fi
# Check if we can safely upgrade. An upgrade is only safe if it's from one
# of our RPMs in the same version family.
# Handle both ways of spelling the capability.
installed=`rpm -q --whatprovides mysql-server 2> /dev/null`
if [ $? -ne 0 -o -z "$installed" ]; then
installed=`rpm -q --whatprovides MySQL-server 2> /dev/null`
fi
if [ $? -eq 0 -a -n "$installed" ]; then
installed=`echo $installed | sed 's/\([^ ]*\) .*/\1/'` # Tests have shown duplicated package names
vendor=`rpm -q --queryformat='%{VENDOR}' "$installed" 2>&1`
version=`rpm -q --queryformat='%{VERSION}' "$installed" 2>&1`
# vendor fun!
vendor_mysql='%{vendor_mysql}'
vendor_sun='%{vendor_sun}'
vendor_wss='%{vendor_wss}'
vendor_oracle='%{vendor_oracle}'
myversion='%{webscalesql_version}'
old_family=`echo $version \
| sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
new_family=`echo $myversion \
| sed -n -e 's,^\([1-9][0-9]*\.[0-9][0-9]*\)\..*$,\1,p'`
[ -z "$vendor" ] && vendor='<unknown>'
[ -z "$old_family" ] && old_family="<unrecognized version $version>"
[ -z "$new_family" ] && new_family="<bad package specification: version $myversion>"
error_text=
if [ "$vendor" != "$vendor_wss" \
-a "$vendor" != "$vendor_oracle" \
-a "$vendor" != "$vendor_sun" \
-a "$vendor" != "$vendor_mysql" ]; then
error_text="$error_text
The current WebScaleSQL server package is provided by a different
vendor ($vendor) than $vendor_wss, $vendor_oracle, $vendor_sun or $vendor_mysql.
Some files may be installed to different locations, including log
files and the service startup script in %{_sysconfdir}/init.d/.
"
fi
if [ "$old_family" != "$new_family" ]; then
error_text="$error_text
Upgrading directly from MySQL $old_family to MySQL $new_family may not
be safe in all cases. A manual dump and restore using mysqldump is
recommended. It is important to review the MySQL manual's Upgrading
section for version-specific incompatibilities.
"
fi
if [ -n "$error_text" ]; then
cat <<HERE >&2
******************************************************************
A MySQL server package ($installed) is installed.
$error_text
A manual upgrade is required.
- Ensure that you have a complete, working backup of your data and my.cnf
files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages. Usually this command will
list the packages you should remove:
rpm -qa | grep -i '^mysql-'
You may choose to use 'rpm --nodeps -ev <package-name>' to remove
the package which contains the mysqlclient shared library. The
library will be reinstalled by the webscalesql-shared-compat package.
- Install the new WebScaleSQL packages supplied by $vendor_wss
- Ensure that the WebScaleSQL server is started
- Run the 'mysql_upgrade' program
This is a brief description of the upgrade process. Important details
can be found in the MySQL manual, in the Upgrading section.
******************************************************************
HERE
exit 1
fi
fi
# We assume that if there is exactly one ".pid" file,
# it contains the valid PID of a running MySQL server.
NR_PID_FILES=`ls -1 $PID_FILE_PATT 2>/dev/null | wc -l`
case $NR_PID_FILES in
0 ) SERVER_TO_START='' ;; # No "*.pid" file == no running server
1 ) SERVER_TO_START='true' ;;
* ) SERVER_TO_START='' # Situation not clear
SEVERAL_PID_FILES=true ;;
esac
# That logic may be debated: We might check whether it is non-empty,
# contains exactly one number (possibly a PID), and whether "ps" finds it.
# OTOH, if there is no such process, it means a crash without a cleanup -
# is that a reason not to start a new server after upgrade?
STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER
if [ -f $STATUS_FILE ]; then
echo "Some previous upgrade was not finished:"
ls -ld $STATUS_FILE
echo "Please check its status, then do"
echo " rm $STATUS_FILE"
echo "before repeating the MySQL upgrade."
exit 1
elif [ -n "$SEVERAL_PID_FILES" ] ; then
echo "You have more than one PID file:"
ls -ld $PID_FILE_PATT
echo "Please check which one (if any) corresponds to a running server"
echo "and delete all others before repeating the MySQL upgrade."
exit 1
fi
NEW_VERSION=%{webscalesql_version}-%{release}
# The "pre" section code is also run on a first installation,
# when there is no data directory yet. Protect against error messages.
# Check for the existence of subdirectory "mysql/", the database of system
# tables like "mysql.user".
if [ -d $mysql_datadir/mysql ] ; then
echo "MySQL RPM upgrade to version $NEW_VERSION" > $STATUS_FILE
echo "'pre' step running at `date`" >> $STATUS_FILE
echo >> $STATUS_FILE
fcount=`ls -ltr $mysql_datadir/*.err 2>/dev/null | wc -l`
if [ $fcount -gt 0 ] ; then
echo "ERR file(s):" >> $STATUS_FILE
ls -ltr $mysql_datadir/*.err >> $STATUS_FILE
echo >> $STATUS_FILE
echo "Latest 'Version' line in latest file:" >> $STATUS_FILE
grep '^Version' `ls -tr $mysql_datadir/*.err | tail -1` | \
tail -1 >> $STATUS_FILE
echo >> $STATUS_FILE
fi
if [ -n "$SERVER_TO_START" ] ; then
# There is only one PID file, race possibility ignored
echo "PID file:" >> $STATUS_FILE
ls -l $PID_FILE_PATT >> $STATUS_FILE
cat $PID_FILE_PATT >> $STATUS_FILE
echo >> $STATUS_FILE
echo "Server process:" >> $STATUS_FILE
ps -fp `cat $PID_FILE_PATT` >> $STATUS_FILE
echo >> $STATUS_FILE
echo "SERVER_TO_START=$SERVER_TO_START" >> $STATUS_FILE
else
# Take a note we checked it ...
echo "PID file:" >> $STATUS_FILE
ls -l $PID_FILE_PATT >> $STATUS_FILE 2>&1
fi
fi
# Shut down a previously installed server first
# Note we *could* make that depend on $SERVER_TO_START, but we rather don't,
# so a "stop" is attempted even if there is no PID file.
# (Maybe the "stop" doesn't work then, but we might fix that in itself.)
if [ -x %{_sysconfdir}/init.d/mysql ] ; then
%{_sysconfdir}/init.d/mysql stop > /dev/null 2>&1
echo "Giving mysqld 5 seconds to exit nicely"
sleep 5
fi
%post -n webscalesql-server%{product_suffix}
# This is the code running at the end of a RPM install or upgrade action,
# after the (new) files have been written.
# ATTENTION: Parts of this are duplicated in the "triggerpostun" !
# There are users who deviate from the default file system layout.
# Check local settings to support them.
if [ -x %{_bindir}/my_print_defaults ]
then
mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
fi
if [ -z "$mysql_datadir" ]
then
mysql_datadir=%{mysqldatadir}
fi
NEW_VERSION=%{webscalesql_version}-%{release}
STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER
# ----------------------------------------------------------------------
# Create data directory if needed, check whether upgrade or install
# ----------------------------------------------------------------------
if [ ! -d $mysql_datadir ] ; then mkdir -m 755 $mysql_datadir; fi
if [ -f $STATUS_FILE ] ; then
SERVER_TO_START=`grep '^SERVER_TO_START=' $STATUS_FILE | cut -c17-`
else
SERVER_TO_START=''
fi
# echo "Analyzed: SERVER_TO_START=$SERVER_TO_START"
if [ ! -d $mysql_datadir/mysql ] ; then
mkdir $mysql_datadir/mysql $mysql_datadir/test
echo "MySQL RPM installation of version $NEW_VERSION" >> $STATUS_FILE
else
# If the directory exists, we may assume it is an upgrade.
echo "MySQL RPM upgrade to version $NEW_VERSION" >> $STATUS_FILE
fi
# ----------------------------------------------------------------------
# Make MySQL start/shutdown automatically when the machine does it.
# ----------------------------------------------------------------------
# NOTE: This still needs to be debated. Should we check whether these links
# for the other run levels exist(ed) before the upgrade?
# use chkconfig on Enterprise Linux and newer SuSE releases
if [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --add mysql
# use insserv for older SuSE Linux versions
elif [ -x /sbin/insserv ] ; then
/sbin/insserv %{_sysconfdir}/init.d/mysql
fi
# ----------------------------------------------------------------------
# Create a MySQL user and group. Do not report any problems if it already
# exists.
# ----------------------------------------------------------------------
groupadd -r %{mysqld_group} 2> /dev/null || true
useradd -M -r -d $mysql_datadir -s /bin/bash -c "MySQL server" \
-g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
# The user may already exist, make sure it has the proper group nevertheless
# (BUG#12823)
usermod -g %{mysqld_group} %{mysqld_user} 2> /dev/null || true
# ----------------------------------------------------------------------
# Change permissions so that the user that will run the MySQL daemon
# owns all database files.
# ----------------------------------------------------------------------
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
# ----------------------------------------------------------------------
# Initiate databases if needed
# ----------------------------------------------------------------------
if ! grep '^MySQL RPM upgrade' $STATUS_FILE >/dev/null 2>&1 ; then
# Fix bug#45415: no "mysql_install_db" on an upgrade
# Do this as a negative to err towards more "install" runs
# rather than to miss one.
%{_bindir}/mysql_install_db --rpm --user=%{mysqld_user} --random-passwords
# Attention: Now 'root' is the only database user,
# its password is a random value found in ~/.mysql_secret,
# and the "password expired" flag is set:
# Any client needs that password, and the first command
# executed must be a new "set password"!
fi
# ----------------------------------------------------------------------
# Upgrade databases if needed would go here - but it cannot be automated yet
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Change permissions again to fix any new files.
# ----------------------------------------------------------------------
chown -R %{mysqld_user}:%{mysqld_group} $mysql_datadir
# ----------------------------------------------------------------------
# Fix permissions for the permission database so that only the user
# can read them.
# ----------------------------------------------------------------------
chmod -R og-rw $mysql_datadir/mysql
# ----------------------------------------------------------------------
# install SELinux files - but don't override existing ones
# ----------------------------------------------------------------------
SETARGETDIR=/etc/selinux/targeted/src/policy
SEDOMPROG=$SETARGETDIR/domains/program
SECONPROG=$SETARGETDIR/file_contexts/program
if [ -f /etc/redhat-release ] \
&& (grep -q "Red Hat Enterprise Linux .. release 4" /etc/redhat-release \
|| grep -q "CentOS release 4" /etc/redhat-release) ; then
echo
echo
echo 'Notes regarding SELinux on this platform:'
echo '========================================='
echo
echo 'The default policy might cause server startup to fail because it is'
echo 'not allowed to access critical files. In this case, please update'
echo 'your installation.'
echo
echo 'The default policy might also cause inavailability of SSL related'
echo 'features because the server is not allowed to access /dev/random'
echo 'and /dev/urandom. If this is a problem, please do the following:'
echo
echo ' 1) install selinux-policy-targeted-sources from your OS vendor'
echo ' 2) add the following two lines to '$SEDOMPROG/mysqld.te':'
echo ' allow mysqld_t random_device_t:chr_file read;'
echo ' allow mysqld_t urandom_device_t:chr_file read;'
echo ' 3) cd to '$SETARGETDIR' and issue the following command:'
echo ' make load'
echo
echo
fi
if [ -x sbin/restorecon ] ; then
sbin/restorecon -R var/lib/mysql
fi
# Was the server running before the upgrade? If so, restart the new one.
if [ "$SERVER_TO_START" = "true" ] ; then
# Restart in the same way that mysqld will be started normally.
if [ -x %{_sysconfdir}/init.d/mysql ] ; then
%{_sysconfdir}/init.d/mysql start
echo "Giving mysqld 5 seconds to start"
sleep 5
fi
fi
# Collect an upgrade history ...
echo "Upgrade/install finished at `date`" >> $STATUS_FILE
echo >> $STATUS_FILE
echo "=====" >> $STATUS_FILE
STATUS_HISTORY=$mysql_datadir/RPM_UPGRADE_HISTORY
cat $STATUS_FILE >> $STATUS_HISTORY
mv -f $STATUS_FILE ${STATUS_FILE}-LAST # for "triggerpostun"
#echo "Thank you for installing the MySQL Community Server! For Production
#systems, we recommend MySQL Enterprise, which contains enterprise-ready
#software, intelligent advisory services, and full production support with
#scheduled service packs and more. Visit www.mysql.com/enterprise for more
#information."
%preun -n webscalesql-server%{product_suffix}
# Which '$1' does this refer to? Fedora docs have info:
# " ... a count of the number of versions of the package that are installed.
# Action Count
# Install the first time 1
# Upgrade 2 or higher (depending on the number of versions installed)
# Remove last version of package 0 "
#
# http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s04s05.html
if [ $1 = 0 ] ; then
# Stop MySQL before uninstalling it
if [ -x %{_sysconfdir}/init.d/mysql ] ; then
%{_sysconfdir}/init.d/mysql stop > /dev/null
# Remove autostart of MySQL
# use chkconfig on Enterprise Linux and newer SuSE releases
if [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --del mysql
# For older SuSE Linux versions
elif [ -x /sbin/insserv ] ; then
/sbin/insserv -r %{_sysconfdir}/init.d/mysql
fi
fi
fi
# We do not remove the mysql user since it may still own a lot of
# database files.
%triggerpostun -n webscalesql-server%{product_suffix} --MySQL-server-community
# Setup: We renamed this package, so any existing "server-community"
# package will be removed when this "server" is installed.
# Problem: RPM will first run the "pre" and "post" sections of this script,
# and only then the "preun" of that old community server.
# But this "preun" includes stopping the server and uninstalling the service,
# "chkconfig --del mysql" which removes the symlinks to the start script.
# Solution: *After* the community server got removed, restart this server
# and re-install the service.
#
# For information about triggers in spec files, see the Fedora docs:
# http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch10s02.html
# For all details of this code, see the "pre" and "post" sections.
# There are users who deviate from the default file system layout.
# Check local settings to support them.
if [ -x %{_bindir}/my_print_defaults ]
then
mysql_datadir=`%{_bindir}/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`
fi
if [ -z "$mysql_datadir" ]
then
mysql_datadir=%{mysqldatadir}
fi
NEW_VERSION=%{webscalesql_version}-%{release}
STATUS_FILE=$mysql_datadir/RPM_UPGRADE_MARKER-LAST # Note the difference!
STATUS_HISTORY=$mysql_datadir/RPM_UPGRADE_HISTORY
if [ -f $STATUS_FILE ] ; then
SERVER_TO_START=`grep '^SERVER_TO_START=' $STATUS_FILE | cut -c17-`
else
# This should never happen, but let's be prepared
SERVER_TO_START=''
fi
echo "Analyzed: SERVER_TO_START=$SERVER_TO_START"
if [ -x /sbin/chkconfig ] ; then
/sbin/chkconfig --add mysql
# use insserv for older SuSE Linux versions
elif [ -x /sbin/insserv ] ; then
/sbin/insserv %{_sysconfdir}/init.d/mysql
fi
# Was the server running before the upgrade? If so, restart the new one.