/
mysql.spec.in
853 lines (748 loc) · 32.3 KB
/
mysql.spec.in
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
#
# spec file for package {{pkg-name}}
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
### WARNING!!!! ##############################################################
# This package is developed on http://github.com/openSUSE/mysql-packaging/
# Do not change anything here in OBS.
##############################################################################
%define pretty_name {{display-name}}
%define libname {{lib-name}}
%define soname {{lib-version}}
%define preferred {{preferred}}
%define builtin_plugins {{builtin_plugins}}
%define extra_provides {{extra_provides}}
%define with_mandatory_lz4 {{mandatory_lz4}}
%define build_readline {{build_readline}}
%define build_extras {{build_extras}}
# _tmpfilesdir is not defined in systemd macros up to openSUSE 13.2
%{!?_tmpfilesdir: %global _tmpfilesdir %{_libexecdir}/tmpfiles.d }
%if 0%{build_extras} > 0
%define with_jemalloc 1
#temporarily disable OQGraph (see MDEV-9479)
#%define with_oqgraph 1
%define with_oqgraph 0
%define with_cassandra 1
%else
%define with_jemalloc 0
%define with_oqgraph 0
%define with_cassandra 0
%endif
Name: {{pkg-name}}
Version: {{pkg-version}}
Release: 0
Summary: Server part of %{pretty_name}
License: SUSE-GPL-2.0-with-FLOSS-exception
Group: Productivity/Databases/Servers
Url: {{url}}
Source: {{source}}
Source2: baselibs.conf
Source3: README.debug
Source4: suse-test-run
Source5: mysql.SuSEfirewall2
Source7: README.install
Source8: README.SUSE
Source9: mysql-patches.tar.xz
Source12: series
Source13: configuration-tweaks.tar.xz
Source14: my.ini
Source15: mysql.service
Source16: mysql.target
Source17: mysql-systemd-helper
Source18: mysql@.service
BuildRequires: bison
BuildRequires: cmake
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: libaio-devel
BuildRequires: libbz2-devel
BuildRequires: libevent-devel
BuildRequires: libtool
BuildRequires: libxml2-devel
BuildRequires: lzo-devel
BuildRequires: ncurses-devel
BuildRequires: openssl-devel
BuildRequires: pam-devel
BuildRequires: pcre-devel
BuildRequires: perl(Data::Dumper)
BuildRequires: perl(Env)
BuildRequires: perl(Exporter)
BuildRequires: perl(Fcntl)
BuildRequires: perl(File::Temp)
BuildRequires: perl(Getopt::Long)
BuildRequires: perl(IPC::Open3)
BuildRequires: perl(Socket)
BuildRequires: perl(Sys::Hostname)
BuildRequires: perl(Test::More)
BuildRequires: perl(Time::HiRes)
BuildRequires: pkgconfig
# Tests requires time and ps and some perl modules
# Keep in sync with Requires of mysql-testsuite
BuildRequires: procps
BuildRequires: pwdutils
BuildRequires: sqlite
BuildRequires: tcpd-devel
BuildRequires: time
BuildRequires: unixODBC-devel
BuildRequires: zlib-devel
# Do not ever switch away from pkgconfig(libsystemd) BuildRequires; systemd/systemd-devel causes build cycles
BuildRequires: pkgconfig(libsystemd)
# required by rcmysql
Requires: %{name}-client
Requires: %{name}-errormessages = %{version}
Requires: perl-base
Requires(pre): pwdutils
Recommends: logrotate
Conflicts: otherproviders(mariadb-server)
Conflicts: otherproviders(mysql)
Conflicts: otherproviders(mysql-debug)
Conflicts: otherproviders(mysql-server)
# Compatibility with Fedora/CentOS
Provides: mysql-server = %{version}
Provides: mariadb-server = %{version}
# Compatibility with old version
Provides: %{name}-debug-version = %{version}
Obsoletes: %{name}-debug-version < %{version}
Provides: %{name}-debug = %{version}
Obsoletes: %{name}-debug < %{version}
Provides: mysql = %{version}
Provides: mysql-debug = %{version}
Provides: %{extra_provides} = %{version}
Obsoletes: %{extra_provides} < %{version}
Provides: %{extra_provides}-debug-version = %{version}
Obsoletes: %{extra_provides}-debug-version < %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}
%if 0%{with_mandatory_lz4} > 0
# Dependency introduced in 5.7 mysql
BuildRequires: liblz4-devel
%endif
# On mariadb we want readline5 (except for SLE12) and on mysql we use libedit from system
%if 0%{build_readline} > 0 && ! (( 0%{?suse_version} == 1315 ) && ( ! 0%{?is_opensuse} ))
BuildRequires: readline5-devel
%else
BuildRequires: libedit-devel
%endif
%if 0%{with_oqgraph} > 0 || 0%{with_cassandra} > 0
BuildRequires: boost-devel
%endif
# Build with jemalloc even for mariadb-100 to enable TokuDB there (bnc#970287)
%if 0%{with_jemalloc} > 0 || "%{extra_provides}" == "mariadb_100"
BuildRequires: jemalloc-devel
%endif
%if 0%{with_oqgraph} > 0
BuildRequires: judy-devel
%endif
%if 0%{with_cassandra} > 0
BuildRequires: libthrift-devel
%endif
%if 0%{?preferred} > 0
Obsoletes: mysql < %{version}
Obsoletes: mysql-debug < %{version}
%endif
%description
{{description}}
This package only contains the server-side programs.
%if 0%{?preferred} > 0
%package -n libmysqlclient-devel
Summary: %{pretty_name} development header files and libraries
Group: Development/Libraries/C and C++
Requires: glibc-devel
Requires: libaio-devel
Requires: libmysqlclient%{soname} = %{version}
Requires: libmysqlclient_r%{soname} = %{version}
Requires: lzo-devel
Requires: pkgconfig(libssl)
Requires: zlib-devel
# mysql-devel needs to be provided as some pkgs still depend on it
Provides: mysql-devel = %{version}
Obsoletes: mysql-devel < %{version}
%description -n libmysqlclient-devel
This package contains the development header files and libraries
necessary to develop client applications for %{pretty_name}.
%package -n libmysqld%{soname}
Summary: %{pretty_name} embedded server
Group: System/Libraries
Requires: %{name}-errormessages = %{version}
%description -n libmysqld%{soname}
This package contains the embedded MySQL engine.
%package -n libmysqld-devel
Summary: %{pretty_name} embedded server development files
Group: Development/Libraries/C and C++
# the headers files are the shared
Requires: libmysqlclient-devel = %{version}
Requires: libmysqld%{soname} = %{version}
Requires: tcpd-devel
%description -n libmysqld-devel
This package contains the development header files and libraries
for developing applications that embed the %{pretty_name}.
%endif
%package -n lib%{libname}%{soname}
Summary: Shared libraries for %{pretty_name}
Group: System/Libraries
%description -n lib%{libname}%{soname}
This package contains the shared libraries (.so) which certain
languages and applications need to dynamically load and use %{pretty_name}.
%package -n lib%{libname}_r%{soname}
Summary: Shared libraries for %{pretty_name}
Group: System/Libraries
Requires: lib%{libname}%{soname}
%description -n lib%{libname}_r%{soname}
This package contains the shared libraries (.so) which certain
languages and applications need to dynamically load and use %{pretty_name}.
%package client
Summary: Client for %{pretty_name}
Group: Productivity/Databases/Clients
Requires: %{name}-errormessages = %{version}
# Explicit requires to pull in charsets for errormessages
Requires: lib%{libname}%{soname}
Requires(pre): pwdutils
Conflicts: otherproviders(mysql-client)
Provides: mysql-client = %{version}
Provides: %{extra_provides}-client = %{version}
Obsoletes: %{extra_provides}-client < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-client < %{version}
%endif
%description client
This package contains the standard clients for %{pretty_name}.
%package errormessages
Summary: MySQL Community Server error message translations
Group: System/Localization
BuildArch: noarch
%description errormessages
This package provides the translated error messages for the standalone
server daemon as well as the embedded server.
%package bench
Summary: Benchmarks for %{pretty_name}
Group: Productivity/Databases/Tools
Requires: %{name}-client
Requires: perl-DBD-mysql
Conflicts: otherproviders(mysql-bench)
Provides: mysql-bench = %{version}
Provides: %{extra_provides}-bench = %{version}
Obsoletes: %{extra_provides}-bench < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-bench < %{version}
%endif
%description bench
This package contains benchmark scripts and data for %{pretty_name}.
To run these database benchmarks, start the script "run-all-tests" in
the directory %{_datadir}/sql-bench after starting %{pretty_name}.
%package test
Summary: Testsuite for %{pretty_name}
Group: Productivity/Databases/Servers
Requires: %{name} = %{version}
Requires: %{name}-bench = %{version}
Requires: %{name}-client = %{version}
Requires: %{name}-tools = %{version}
# Tests requires time and ps and some perl modules
Requires: perl(Data::Dumper)
Requires: perl(Env)
Requires: perl(Exporter)
Requires: perl(Fcntl)
Requires: perl(File::Temp)
Requires: perl(Getopt::Long)
Requires: perl(IPC::Open3)
Requires: perl(Socket)
Requires: perl(Sys::Hostname)
Requires: perl(Test::More)
Requires: perl(Time::HiRes)
Requires: perl-DBD-mysql
Requires: procps
Requires: time
Conflicts: otherproviders(mysql-test)
Provides: mysql-test = %{version}
Provides: %{extra_provides}-test = %{version}
Obsoletes: %{extra_provides}-test < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-test < %{version}
%endif
%description test
This package contains the test scripts and data for %{pretty_name}.
To run the testsuite, run %{_datadir}/mysql-test/suse-test-run.
%package tools
Summary: %{pretty_name} tools
Group: Productivity/Databases/Servers
Requires: perl-DBD-mysql
Requires: socat
Conflicts: otherproviders(mysql-tools)
# make sure this package is installed when updating from 10.2 and older
Provides: mysql-client:%{_bindir}/perror
Provides: mysql:%{_bindir}/mysqlhotcopy
Provides: mysql-tools = %{version}
Provides: %{extra_provides}-tools = %{version}
Obsoletes: %{extra_provides}-tools < %{version}
%if 0%{?preferred} > 0
Obsoletes: mysql-tools < %{version}
%endif
%description tools
A set of scripts for administering a %{pretty_name} or developing
applications with %{pretty_name}.
%prep
%setup -q -n {{src-dir}} -D -a 9
cp %{_sourcedir}/README.SUSE .
cp %{_sourcedir}/suse-test-run .
# apply patches from series
mysql-patches/tools/quilt-setup.sh "%{SOURCE12}"
mysql-patches/tools/apply-series.sh "%{SOURCE12}"
# remove unneeded manpages ('make install' basically installs everything under
# man/*)
rm -f man/mysqlman.1 # dummy fallback manpage
[ \! -f man/CMakeLists.txt ] || sed -i 's|mysqlman.1||' man/CMakeLists.txt
rm -f man/mysql.server.1 # init script, not installed in our rpm
[ \! -f man/CMakeLists.txt ] || sed -i 's|mysql.server.1||' man/CMakeLists.txt
rm -f man/make_win_*.1 # windows build scripts
rm -f man/comp_err.1 # built-time utility
# 5.1 Carrier Grade Edition only / still under development as of 5.1.22
rm -f man/ndbd_redo_log_reader.1
# breaks VPATH builds when in sourcedir, is generated in the builddirs
rm -f sql/sql_builtin.cc
sed -i 's|@localstatedir@|%{_localstatedir}/log|' support-files/mysql-log-rotate.sh
%if 0%{preferred} < 1
for i in `grep -Rl mysqlclient .`; do
sed -i 's|mysqlclient|%{libname}|g' $i
sed -i 's|-lib%{libname}-symbols.patch|-libmysqlclient-symbols.patch|g' $i
done
mv scripts/mysqlclient.pc.in scripts/%{libname}.pc.in || continue
%endif
# Broken test that needs sources
rm -f mysql-test/t/file_contents.test mysql-test/r/file_contents.result
# Specify perl path on shebangs
for i in `grep -Rl '^#!@PERL@$' .`; do
sed -i 's|@PERL@|%{_bindir}/perl|' $i
done
%build
EXTRA_FLAGS="-Wno-unused-but-set-variable -fno-strict-aliasing -Wno-unused-parameter"
# Mariadb devs seems to fall in love with -Werror option
EXTRA_FLAGS="${EXTRA_FLAGS} -Wno-error"
export CFLAGS="%{optflags} -DOPENSSL_LOAD_CONF -DPIC -fPIC -DFORCE_INIT_OF_VARS $EXTRA_FLAGS"
export CXXFLAGS="$CFLAGS -felide-constructors"
%cmake -DWITH_SSL=system \
-DWITH_ASAN=OFF \
-DWITH_LIBWRAP=ON \
-DENABLED_PROFILING=ON \
-DENABLE_DEBUG_SYNC=OFF \
-DWITH_PIC=ON \
-DWITH_ZLIB=system \
-DWITH_LIBEVENT=system \
-DWITH_JEMALLOC=auto \
-DWITH_READLINE=0 \
-DWITH_LIBEDIT=0 \
-DWITH_EDITLINE=system \
-DINSTALL_LAYOUT=RPM \
-DWITH_SYSTEMD=ON \
-DWITH_LZ4=system \
-DMYSQL_UNIX_ADDR="%{_localstatedir}/run/mysql/mysql.sock" \
-DINSTALL_UNIX_ADDRDIR="%{_localstatedir}/run/mysql/mysql.sock" \
-DINSTALL_MYSQLSHAREDIR=share/%{name} \
-DWITH_COMMENT="openSUSE {{pkg-name}} rpm" \
-DWITH_EXTRA_CHARSET=all \
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
%if 0%{with_oqgraph} > 0
-DWITH_OQGRAPH_STORAGE_ENGINE=1 \
%endif
%if 0%{with_cassandra} > 0
-DWITH_CASSANDRA_STORAGE_ENGINE=1 \
%endif
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_HANDLERSOCKET_STORAGE_ENGINE=1 \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_EMBEDDED_SERVER=true \
-DWITH_WSREP=ON \
-DWITH_INNODB_DISALLOW_WRITES=1 \
-DWITH_BOOST=../boost/ \
-DCOMPILATION_COMMENT="openSUSE package" \
-DDENABLE_DOWNLOADS=false \
-DINSTALL_PLUGINDIR_RPM="%{_lib}/mysql/plugin" \
-DINSTALL_LIBDIR_RPM="%{_lib}" \
-DINSTALL_SYSCONF2DIR="%{_sysconfdir}/my.cnf.d" \
-DCMAKE_C_FLAGS_RELWITHDEBINFO="$CFLAGS" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$CXXFLAGS" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DINSTALL_SQLBENCHDIR=share \
-DCMAKE_C_FLAGS="$CFLAGS" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -pie -Wl,-z,relro,-z,now" \
-DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed -pie -Wl,-z,relro,-z,now" \
-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed -pie -Wl,-z,relro,-z,now" \
-Wno-dev "$@" ..
make %{?_smp_mflags}
nm --numeric-sort sql/mysqld > sql/mysqld.sym
%install
# Helper function to generate filelist for binaries and their manpages
filelist()
{
echo '%%defattr(-, root, root)'
pushd %{buildroot} >/dev/null
for i; do
if test -e usr/sbin/"$i"; then
echo %{_sbindir}/"$i"
fi
if test -e usr/bin/"$i"; then
echo %{_bindir}/"$i"
fi
if test -d usr/share/*/"$i"; then
echo "/`echo usr/share/*/"$i"`"
fi
if test -n "`ls -1 %{buildroot}$i 2> /dev/null`"; then
echo "$i"
fi
if ls usr/share/man/*/"$i".[1-9]* >/dev/null 2>&1; then
echo "%{_mandir}/*/$i.[1-9]*"
fi
done
popd >/dev/null
}
# Install the package itself
%cmake_install benchdir_root=%{_datadir}/
# Logrotate file should be named as the package
if [ ! -e %{buildroot}%{_sysconfdir}/logrotate.d/mysql ]; then
# some versions do not install it automatically
install -D -m 644 build/support-files/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/mysql
fi
mv %{buildroot}%{_sysconfdir}/logrotate.d/mysql %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
# Create log directory with the expected perms of mysql
install -d -m 700 %{buildroot}%{_localstatedir}/log/mysql/
# Symbols from build to go into libdir
install -m 644 build/sql/mysqld.sym %{buildroot}%{_libdir}/mysql/mysqld.sym
# INFO_BIN and INFO_SRC binaries
install -p -m 644 build/Docs/INFO_SRC %{buildroot}%{_libdir}/mysql/
install -p -m 644 build/Docs/INFO_BIN %{buildroot}%{_libdir}/mysql/
# Remove debug management for keys Mariadb 101+
rm -f %{buildroot}%{_libdir}/mysql/plugin/debug_key_management.so
# Remove most static libs (FIXME: don't build them at all...)
[ \! -f "%{buildroot}%{_libdir}/"libmysqld.a ] || mv "%{buildroot}%{_libdir}/"libmysqld.a "%{buildroot}%{_libdir}/"libmysqld.static
rm -f %{buildroot}%{_libdir}/*.a
[ \! -f "%{buildroot}%{_libdir}/"libmysqld.static ] || mv "%{buildroot}%{_libdir}/"libmysqld.static "%{buildroot}%{_libdir}/"libmysqld.a
# Rename mytop to have name prefixed with the implementation
[ \! -f "%{buildroot}%{_bindir}/mytop" ] || mv %{buildroot}%{_bindir}/mytop %{buildroot}%{_bindir}/%{name}_mytop
# Remove few configure/examples
rm -f %{buildroot}%{_datadir}/mysql/{binary-configure,errmsg-utf8.txt,magic,mysql-log-rotate,mysql*.server}
rm -f %{buildroot}%{_libdir}/mysql/plugin/daemon_example.ini
mv %{buildroot}%{_datadir}/mysql-test/lib/My/SafeProcess/my_safe_process %{buildroot}%{_bindir}
# Remove unused services for mariadb_101
%if "%{extra_provides}" == "mariadb_101"
rm -f %{buildroot}'%{_unitdir}/mariadb.service'
rm -f %{buildroot}'%{_unitdir}/mariadb@.service'
rm -f %{buildroot}'%{_unitdir}/mariadb@bootstrap.service.d/use_galera_new_cluster.conf'
%endif
# Generate various filelists
filelist galera_new_cluster galera_recovery innochecksum mariadb-service-convert my_print_defaults myisam_ftdump myisamchk myisamlog myisampack mysql_fix_extensions mysql_fix_privilege_tables mysql_ssl_rsa_setup mysql_install_db mysql_secure_installation mysql_upgrade mysqlbug mysqld mysqld_multi mysqld_safe mysqlbinlog mysqldumpslow mysqlmanager mroonga resolve_stack_dump resolveip {m,}aria_chk {m,}aria_dump_log {m,}aria_ftdump {m,}aria_pack {m,}aria_read_log xtstat tokuft_logprint tokuft_logdump tokuftdump >mysql.files
filelist mysql mysqladmin mysqlcheck mysqldump mysqlimport mysqlshow mysql_config_editor mysqld_safe_helper >mysql-client.files
# The dialog stuff is mariadb only
if [ "`ls '%{buildroot}'%{_libdir}/mysql/plugin/dialog*.so 2> /dev/null`" ]; then
echo '%%dir %%_libdir/mysql' >> mysql-client.files
echo '%%dir %%_libdir/mysql/plugin' >> mysql-client.files
echo '%%_libdir/mysql/plugin/dialog*.so' >> mysql-client.files
fi
# Mysql has configuration file in _bindir
if [ -f scripts/mysqlaccess.conf ] ; then
install -m 640 scripts/mysqlaccess.conf %{buildroot}%{_sysconfdir}/mysqlaccess.conf
rm -f %{buildroot}%{_bindir}/mysqlaccess.conf
echo '%config(noreplace) %attr(0640, root, mysql) %{_sysconfdir}/mysqlaccess.conf' >> mysql-client.files
fi
filelist mysql_config %{_datadir}/pkgconfig/mariadb.pc >libmysqlclient-devel.files
filelist mysqlslap >mysql-bench.files
filelist mysql_client_test mysql_client_test_embedded mysql_waitpid mysqltest mysqltest_embedded >mysql-test.files
filelist msql2mysql mysql_plugin mysql_convert_table_format mysql_find_rows mysql_setpermission mysql_tzinfo_to_sql mysql_zap mysqlaccess mysqlhotcopy perror replace mysql_embedded %{name}_mytop hsclient wsrep_sst_common wsrep_sst_mariabackup wsrep_sst_mysqldump wsrep_sst_rsync wsrep_sst_xtrabackup-v2 wsrep_sst_xtrabackup %{_datadir}/mysql/wsrep_notify >mysql-tools.files
filelist ndbd ndbmtd ndbd_redo_log_reader >mysql-ndb-storage.files
filelist ndb_mgmd >mysql-ndb-management.files
filelist ndb_{config,desc,error_reporter,mgm,print_backup_file,print_schema_file,print_sys_file,restore,select_all,select_count,show_tables,size.pl,test_platform,waiter} >mysql-ndb-tools.files
filelist ndb_{cpcd,delete_all,drop_index,index_stat,print_file,redo_log_reader,drop_table} ndbinfo_select_all memcached >mysql-ndb-extra.files
# All configuration files
echo '%{_datadir}/mysql/*.cnf' >> mysql.files
# Mysql-community server has dictionary file in datadir
if [ -f "%{buildroot}%{_datadir}/%{name}"/dictionary.txt ]; then
echo "%{_datadir}/%{name}/dictionary.txt" >> mysql.files
fi
# Special errormessages approach
echo '%%defattr(-, root, root)' > %{_builddir}/errormessages.files
pushd %{buildroot} >/dev/null
for f in usr/share/%{name}/*; do
if test -e $f/errmsg.sys; then
echo "%%dir /$f" >> %{_builddir}/errormessages.files
fi
done
echo %{_datadir}/%{name}/errmsg-utf8.txt >> %{_builddir}/errormessages.files
popd >/dev/null
mv %{_builddir}/errormessages.files errormessages.files
### files not installed by make install
# Some of the documentation we need to have installed
DOCS=(COPYING README EXCEPTIONS-CLIENT %{_sourcedir}/README.debug %{_sourcedir}/README.SUSE plugin/daemon_example/daemon_example.ini)
DOCDIR=%{buildroot}%{_defaultdocdir}/%{name}
install -d -m 755 ${DOCDIR}
for i in "${DOCS[@]}"; do
install -m 644 "${i}" "${DOCDIR}" || true
done
# Default configuration file
install -m 664 %{SOURCE14} %{buildroot}%{_sysconfdir}/my.cnf
# Systemd/initscript
install -D -m 755 %{_sourcedir}/mysql-systemd-helper '%{buildroot}'%{_libexecdir}/mysql/mysql-systemd-helper
sed -i 's|@MYSQLVER@|%{version}|' '%{buildroot}'%{_libexecdir}/mysql/mysql-systemd-helper
ln -sf service '%{buildroot}'%{_sbindir}/rcmysql
install -D -m 644 %{_sourcedir}/mysql.service '%{buildroot}'%{_unitdir}/mysql.service
install -D -m 644 %{_sourcedir}/mysql@.service '%{buildroot}'%{_unitdir}/mysql@.service
install -D -m 644 %{_sourcedir}/mysql.target '%{buildroot}'%{_unitdir}/mysql.target
rm -rf '%{buildroot}'%{_sysconfdir}/init.d
# Tmpfiles file to exclude mysql tempfiles that are auto-cleaned up
# bnc#852451
mkdir -p %{buildroot}%{_tmpfilesdir}
cat > %{buildroot}%{_tmpfilesdir}/mysql.conf <<EOF
x %{_localstatedir}/tmp/mysql.*
EOF
# SuSEfirewall service description
install -D -m 644 %{_sourcedir}/mysql.SuSEfirewall2 %{buildroot}%{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/mysql
# testsuite
install -d -m 755 '%{buildroot}'%{_datadir}/mysql-test/
install -m 755 suse-test-run '%{buildroot}'%{_datadir}/mysql-test/
mkdir '%{buildroot}'%{_datadir}/mysql-test/var
# Final fixes
find '%{buildroot}'%{_datadir}/mysql-test -name '*.orig' -delete
%fdupes -s '%{buildroot}'%{_datadir}/mysql-test
fdupes -q -n -r '%{buildroot}'%{_datadir}/mysql-test
for i in `grep -Rl '\r' '%{buildroot}'%{_datadir}/sql-bench`; do
dos2unix "$i"
done
# Fix libmysqlclient_r.so.18 symlinking to be done against plain .so file
# and thus broken later on. Fixes bnc#906147
pushd "%{buildroot}%{_libdir}"
rm -f lib%{libname}_r.so*
ln -sf lib%{libname}.so.%{soname}.0.0 lib%{libname}_r.so
ln -sf lib%{libname}.so.%{soname}.0.0 lib%{libname}_r.so.%{soname}
ln -sf lib%{libname}.so.%{soname}.0.0 lib%{libname}_r.so.%{soname}.0.0
popd
# If not preffered simply reduce main develpackage to NULL
%if ! 0%{preferred} > 0
cat libmysqlclient-devel.files | sed 's|%%doc\ ||' | while read tmp; do
cd '%{buildroot}'
rm -f ."$tmp"
done
rm -rf '%{buildroot}'/%{_libdir}/libmysqld.*
rm -rf '%{buildroot}'/%{_libdir}/{*.so,*.a}
rm -rf '%{buildroot}'/%{_mandir}/*/mysql_config.1*
rm -rf '%{buildroot}'/%{_includedir}
rm -rf '%{buildroot}'/%{_datadir}/aclocal
%endif
# Compat with old scripts
ln -s mysqlcheck '%{buildroot}'%{_bindir}/mysqlrepair
ln -s mysqlcheck '%{buildroot}'%{_bindir}/mysqlanalyze
ln -s mysqlcheck '%{buildroot}'%{_bindir}/mysqloptimize
# Use our configuration stuff instead of upstream one
rm -rf '%{buildroot}'%{_sysconfdir}/my.cnf.d
install -d -m 755 '%{buildroot}'%{_sysconfdir}/my.cnf.d
tar -C '%{buildroot}'%{_sysconfdir}/my.cnf.d -xvf %{SOURCE13}
# Documentation that was copied to wrong folder
rm -f '%{buildroot}'%{_datadir}/doc/* 2> /dev/null || true
# Unwanted packaged stuff
rm -rf '%{buildroot}'%{_datadir}/mysql/{solaris,SELinux}
# Create the directory specified in 'secure-file-priv' option
mkdir -p '%{buildroot}'/var/lib/mysql-files
%check
cd build
# First run simple ctest unittests
LD_LIBRARY_PATH=$(pwd)/unittest/mytap make test %{?_smp_mflags}
# And then run discustingly HUGE testsuite that might fail here and there
# Basically we run it to have overview to check how it goes
cd mysql-test
./mysql-test-run.pl \
--parallel=%{?jobs:%{jobs}} \
--force \
--retry=0 \
--ssl \
--suite-timeout=720 \
--testcase-timeout=30 \
--mysqld=--binlog-format=mixed \
--force-restart \
--shutdown-timeout=60 \
--max-test-fail=0 || :
# client does not require server and needs the user too
%pre client
getent group mysql >/dev/null || groupadd -r mysql
getent passwd mysql >/dev/null || useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
-s /bin/false -d %{_localstatedir}/lib/mysql mysql
# if mysql user is not in mysql group or if mysql user doesn't have '/bin/false' shell set, do so
id -Gn mysql | grep '\bmysql\b' &>/dev/null || usermod -g mysql mysql
getent passwd mysql | cut -d: -f7 | grep '\b/bin/false\b' &>/dev/null || usermod -s /bin/false mysql
exit 0
%pre
getent group mysql >/dev/null || groupadd -r mysql
getent passwd mysql >/dev/null || useradd -r -o -g mysql -u 60 -c "MySQL database admin" \
-s /bin/false -d %{_localstatedir}/lib/mysql mysql
# if mysql user is not in mysql group or if mysql user doesn't have '/bin/false' shell set, do so
id -Gn mysql | grep '\bmysql\b' &>/dev/null || usermod -g mysql mysql
getent passwd mysql | cut -d: -f7 | grep '\b/bin/false\b' &>/dev/null || usermod -s /bin/false mysql
%service_add_pre mysql.service
%post
%service_add_post mysql.service
# Use %%tmpfiles_create when 13.2 is oldest in support scope
%{_bindir}/systemd-tmpfiles --create %{_tmpfilesdir}/mysql.conf || :
# SLE11 Migration support
for i in protected tmp; do
rmdir "$datadir"/.$i 2>/dev/null || :
done
# Remove any messages that could've been in place about the upgrade
rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something
# During package rename (migration maria->mysql-community-server),
# there might be config file move and we get rpmsave that we should keep
if [ -f %{_sysconfdir}/my.cnf.rpmsave ]; then
mv %{_sysconfdir}/my.cnf{,.rpmnew}
mv %{_sysconfdir}/my.cnf{.rpmsave,}
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something << EOF
WARNING: %{_sysconfdir}/my.cnf.rpmsave file detected!
This probably means that you are migrating from different variant of MySQL.
Your configuration was left intact and you can see the new configuration in
%{_sysconfdir}/my.cnf.rpmnew
EOF
fi
# warn on first run
datadir="`%{_bindir}/my_print_defaults mysqld mysql_server | sed -n 's|--datadir=||p'`"
[ -n "$datadir" ] || datadir="%{_localstatedir}/lib/mysql"
if [ -d "$datadir/mysql" ]; then
touch "$datadir/.run-mysql_upgrade"
fi
if [ \! -f "$datadir/mysql_upgrade_info" ]; then
if [ $1 -eq 1 ]; then
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something << EOF
%(cat %{_sourcedir}/README.install)
EOF
fi
else
MYSQLVER="`echo %{version} | sed 's|\.[0-9]\+$||'`"
if [ -f "$datadir/mysql_upgrade_info" ] && \
[ -z "`grep "^$MYSQLVER" "$datadir/mysql_upgrade_info" 2> /dev/null`" ]; then
cat >> %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something << EOF
WARNING: You are upgrading from different stable version of MySQL!
Your database will be migrated automatically during next restart of MySQL.
Before you do that make sure you have up to date backup of your data. It
should be mainly in $datadir directory.
EOF
fi
fi
exit 0
%preun
%service_del_preun mysql.service
%postun
%service_del_postun mysql.service
# Remove the /var/adm updatemsg that was hand-created and thus not on filelist
rm -f %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something
%post -n lib%{libname}%{soname} -p /sbin/ldconfig
%postun -n lib%{libname}%{soname} -p /sbin/ldconfig
%post -n lib%{libname}_r%{soname} -p /sbin/ldconfig
%postun -n lib%{libname}_r%{soname} -p /sbin/ldconfig
%if 0%{preferred} > 0
%post -n libmysqld%{soname} -p /sbin/ldconfig
%postun -n libmysqld%{soname} -p /sbin/ldconfig
%endif
%files -f mysql.files
%defattr(-, root, root)
%config(noreplace) %attr(0644, root, mysql) %{_sysconfdir}/my.cnf
%dir %attr(0755, root, mysql) %{_sysconfdir}/my.cnf.d
%config(noreplace) %attr(0644, root, mysql) %{_sysconfdir}/my.cnf.d/*
%config %{_sysconfdir}/logrotate.d/%{name}
%doc %{_defaultdocdir}/%{name}
%dir %{_libexecdir}/mysql
%dir %attr(0700, mysql, mysql) %{_localstatedir}/log/mysql
%{_libexecdir}/mysql/mysql-systemd-helper
%{_unitdir}/mysql.service
%{_unitdir}/mysql@.service
%{_unitdir}/mysql.target
%{_tmpfilesdir}/mysql.conf
%{_sbindir}/rcmysql
%dir %{_datadir}/%{name}
%dir %{_datadir}/mysql
%{_datadir}/%{name}/charsets/
%{_datadir}/%{name}/*.sql
%dir %{_libdir}/mysql
%{_libdir}/mysql/mysqld.sym
%{_libdir}/mysql/INFO_BIN
%{_libdir}/mysql/INFO_SRC
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/mysql
%dir %{_libdir}/mysql/plugin
%{_libdir}/mysql/plugin/[!d]*.so
%ghost %{_localstatedir}/adm/update-messages/%{name}-%{version}-%{release}-something
%dir %attr(0750, mysql, mysql) /var/lib/mysql-files
# Pack files for mariadb_101
%if "%{extra_provides}" == "mariadb_101"
%{_bindir}/galera_new_cluster
%{_bindir}/galera_recovery
%{_bindir}/mariadb-service-convert
%{_bindir}/mariabackup
%{_bindir}/mbstream
%dir %{_datadir}/mysql/policy
%dir %{_datadir}/mysql/policy/apparmor
%{_datadir}/mysql/policy/apparmor/README
%{_datadir}/mysql/policy/apparmor/usr.sbin.mysqld*
%dir %{_datadir}/mysql/policy/selinux
%{_datadir}/mysql/policy/selinux/README
%{_datadir}/mysql/policy/selinux/mariadb-server.*
%{_datadir}/mysql/policy/selinux/mariadb.te
%dir %{_datadir}/mysql/systemd
%{_datadir}/mysql/systemd/mariadb.service
%{_datadir}/mysql/systemd/mariadb@.service
%{_datadir}/mysql/systemd/use_galera_new_cluster.conf
%endif
%files errormessages -f errormessages.files
%defattr(-, root, root)
%{_datadir}/%{name}/*/errmsg.sys
%files client -f mysql-client.files
%defattr(-, root, root)
%if 0%{preferred} > 0
%files -n libmysqlclient-devel -f libmysqlclient-devel.files
%defattr(-, root, root)
%{_includedir}/mysql
%{_libdir}/libmysqlclient.so
%dir %{_datadir}/aclocal
%{_datadir}/aclocal/mysql.m4
%files -n libmysqld-devel
%defattr(-,root,root)
%{_libdir}/libmysqld.a
%{_libdir}/libmysqld.so
%files -n libmysqld%{soname}
%defattr(-,root,root)
%{_libdir}/libmysqld.so.*
%endif
%files -n lib%{libname}%{soname}
%defattr(-, root, root)
%{_libdir}/lib%{libname}.so.*
%files -n lib%{libname}_r%{soname}
%defattr(-, root, root)
# We need .so file here as few apps still rely on it to be present.
# Currently known are Mysql workbench and Libreoffice
%{_libdir}/lib%{libname}_r.so*
%files bench -f mysql-bench.files
%defattr(-, root, root)
%{_datadir}/sql-bench
%files test -f mysql-test.files
%defattr(-, root, root)
%{_bindir}/my_safe_process
%if "%{extra_provides}" == "mariadb_101"
%{_mandir}/man1/my_safe_process.1*
%endif
%{_mandir}/man1/mysql-test-run.pl.1*
%{_mandir}/man1/mysql-stress-test.pl.1*
%{_datadir}/mysql-test/valgrind.supp
%dir %attr(755, root, root)%{_datadir}/mysql-test
%{_datadir}/mysql-test/[^v]*
%dir %attr(755, mysql, mysql) %{_datadir}/mysql-test/var
%files tools -f mysql-tools.files
%defattr(-, root, root)
%{_bindir}/mysqlrepair
%{_bindir}/mysqlanalyze
%{_bindir}/mysqloptimize
%changelog