summaryrefslogtreecommitdiff
path: root/storage/mroonga/packages/rpm/centos/percona-server-56-mroonga.spec.in
blob: f0306cace24ed74cbc1917167f4e71b0fa4410bd (plain)
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
%{!?centos_ver:%define centos_ver 6}

%define mysql_version_default 5.6.23
%define mysql_release_default rel72.1
%define mysql_dist_default    %{?dist}
%define mysql_download_base_url_default http://repo.percona.com/centos/%{centos_ver}/SRPMS
%define mysql_spec_file_default percona-server.spec

%{!?mysql_version:%define mysql_version %{mysql_version_default}}
%{!?mysql_release:%define mysql_release %{mysql_release_default}}
%{!?mysql_dist:%define mysql_dist %{mysql_dist_default}}
%{!?mysql_download_base_url:%define mysql_download_base_url %{mysql_download_base_url_default}}
%{!?mysql_spec_file:%define mysql_spec_file %{mysql_spec_file_default}}

%define groonga_required_version @REQUIRED_GROONGA_VERSION@

Name:		percona-server-56-mroonga
Version:	@VERSION@
Release:	1%{?dist}
Summary:	A fast fulltext searchable storage engine for MySQL

Group:		Applications/Databases
License:	LGPLv2.1
URL:		http://mroonga.org/
Source0:	http://packages.groonga.org/source/mroonga/mroonga-%{version}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
BuildRequires:	groonga-devel >= %{groonga_required_version}
BuildRequires:	groonga-normalizer-mysql-devel
BuildRequires:	wget
BuildRequires:	which
BuildRequires:	gcc
BuildRequires:	gcc-c++
BuildRequires:	Percona-Server-devel-56 = %{mysql_version}-%{mysql_release}%{mysql_dist}
BuildRequires:	selinux-policy-devel
Requires:	Percona-Server-server-56 = %{mysql_version}-%{mysql_release}%{mysql_dist}
Requires:	Percona-Server-client-56 = %{mysql_version}-%{mysql_release}%{mysql_dist}
Requires:	groonga-libs >= %{groonga_required_version}
Requires:	groonga-normalizer-mysql

%description
Mroonga is a fast fulltext searchable storage plugin for MySQL.
It is based on Groonga that is a fast fulltext search engine and
column store. Groonga is good at real-time update.

%package doc
Summary:	Documentation for Mroonga
Group:		Documentation
License:	LGPLv2.1

%description doc
Documentation for Mroonga


%prep
%setup -q -n mroonga-%{version}

mysql_full_version=%{mysql_version}-%{mysql_release}.generic
srpm=Percona-Server-56-${mysql_full_version}.src.rpm
if [ ! -f ../../SRPMS/$srpm ]; then
    wget --continue -O ../../SRPMS/$srpm %{mysql_download_base_url}/$srpm
    rpm -Uvh ../../SRPMS/$srpm
fi

%build
mysql_source=../percona-server-%{mysql_version}-$(echo %{mysql_release} | sed -e 's/rel//')
if [ ! -d ${mysql_source} ]; then
    specs_dir=
    rpmbuild -bp \
	--define 'runselftest 0' \
	--define 'optflags -O0' \
	../../SPECS/%{mysql_spec_file}
fi
%configure --disable-static --with-mysql-source=${mysql_source} \
    %{?mroonga_configure_options}
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
rm $RPM_BUILD_ROOT%{_libdir}/mysql/plugin/*.la
mv $RPM_BUILD_ROOT%{_datadir}/doc/mroonga/ mysql-mroonga-doc/

%clean
rm -rf $RPM_BUILD_ROOT

%post
mysql_command=`which mysql`
password_option=""
$mysql_command -u root -e "quit"
if [ $? -ne 0 ]; then
    password_option="-p"
fi
current_version=0
version=`echo %{groonga_required_version} | sed -e 's/\.//g'`
required_version=`expr $version`
version=`$mysql_command -e "SHOW VARIABLES LIKE 'mroonga_libgroonga_version'" | \
    grep mroonga | cut -f 2 | sed -e 's/\.//g'`
if [ -n "$version" ]; then
    current_version=`expr $version`
fi
install_sql=%{_datadir}/mroonga/install.sql
uninstall_sql=%{_datadir}/mroonga/uninstall.sql

if [ "$1" = 2 ] ; then
    if [ $current_version -lt $required_version ]; then
	command="$mysql_command -u root $password_option"
	echo "run the following command after restarting MySQL server:";
	echo "  $command < ${uninstall_sql}"
	echo "  $command < ${install_sql}"
	exit 0
    else
	command="$mysql_command -u root $password_option < ${uninstall_sql}"
	echo $command
	eval $command || \
	    (echo "run the following command to unregister Mroonga:"; \
	     echo "  $command")
    fi
fi
command="$mysql_command -u root $password_option < ${install_sql}"
echo $command
eval $command || \
	(echo "run the following command to register Mroonga:"; \
	 echo "  $command")

%preun
uninstall_sql=%{_datadir}/mroonga/uninstall.sql
mysql_command=`which mysql`
if $mysql_command -u root -e "quit"; then
    password_option=""
else
    password_option="-p"
fi
if [ "$1" = 0 ]; then
    command="$mysql_command -u root $password_option < ${uninstall_sql}"
    echo $command
    eval $command || \
	(echo "run the following command to unregister Mroonga:"; \
	 echo "  $command")
fi

%files
%defattr(-,root,root,-)
%{_libdir}/mysql/plugin/
%{_datadir}/mroonga/*
%{_datadir}/man/man1/*
%{_datadir}/man/*/man1/*

%files doc
%defattr(-,root,root,-)
%doc README COPYING
%doc mysql-mroonga-doc/*

%changelog
* Tue Mar 17 2015 Kouhei Sutou <kou@clear-code.com> - 5.00-1
- initial release.