Tue, 28 Aug 2012 18:28:40 +0200
Import package vendor original specs for necessary manipulations.
1 ##
2 ## mysql.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2012 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package version
25 %define V_major 5.1
26 %define V_minor 63
27 %define V_mysql %{V_major}.%{V_minor}
28 %define V_opkg %{V_major}.%{V_minor}
29 %define V_jdbc 5.1.21
31 # package information
32 Name: mysql
33 Summary: Fast Relational Database Management System
34 URL: http://www.mysql.com/products/mysql/
35 Vendor: ORACLE
36 Packager: OpenPKG Foundation e.V.
37 Distribution: OpenPKG Community
38 Class: BASE
39 Group: Database
40 License: GPL
41 Version: %{V_opkg}
42 Release: 20120704
44 # package options
45 %option with_server yes
46 %option with_innobase yes
47 %option with_archive no
48 %option with_blackhole no
49 %option with_federated no
50 %option with_ndbcluster no
51 %option with_partition no
52 %option with_ssl no
53 %option with_embedded no
54 %option with_charset utf8
55 %option with_collation utf8_unicode_ci
56 %option with_jdbc no
58 # fixing implicit inter-plugin dependencies and correlations
59 %if "%{with_ndbcluster}" == "yes"
60 %undefine with_partition
61 %define with_partition yes
62 %endif
64 # list of sources
65 Source0: http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
66 Source1: http://ftp.gwdg.de/pub/misc/mysql/Downloads/Connector-J/mysql-connector-java-%{V_jdbc}.tar.gz
67 Source2: my.cnf
68 Source3: my.pwd
69 Source4: rc.mysql
70 Patch0: mysql.patch
72 # build information
73 BuildPreReq: OpenPKG, openpkg >= 20100101, perl, make, gcc, gcc::with_cxx = yes
74 PreReq: OpenPKG, openpkg >= 20100101, perl
75 BuildPreReq: zlib, readline, ncurses
76 PreReq: zlib, readline, ncurses
77 %if "%{with_ssl}" == "yes"
78 BuildPreReq: openssl
79 PreReq: openssl
80 %endif
81 %if "%{with_jdbc}" == "yes"
82 PreReq: java, JAVA-JDK
83 %endif
85 %description
86 MySQL is a multi-user Relational Database Management System (RDBMS),
87 which is controlled through Structured Query Language (SQL)
88 operating in full multi-threading mode. The main goals of MySQL are
89 speed, robustness and ease of use. MySQL was originally developed
90 because of the need for a SQL server that could handle very big
91 databases with magnitude higher speed than what any database vendor
92 could offer.
94 %track
95 prog mysql = {
96 version = %{V_mysql}
97 url = http://dev.mysql.com/downloads/mysql/%{V_major}.html
98 regex = mysql-(__VER__)\.tar\.gz
99 }
100 prog mysql:connector-jdbc = {
101 version = %{V_jdbc}
102 url = http://dev.mysql.com/downloads/connector/j/%{V_major}.html
103 regex = mysql-connector-java-(__VER__)\.tar\.gz
104 }
106 %prep
107 %setup -q
108 %if "%{with_jdbc}" == "yes"
109 %setup -q -T -D -a 1
110 %endif
111 %patch -p0
113 %build
114 # patch file search path
115 %{l_shtool} subst %{l_value -s -a} \
116 mysys/default.c
118 # fix shebang on supplemental Perl scripts
119 rm -f scripts/*.orig
120 %{l_shtool} subst \
121 -e 's;^#!/usr/bin/perl;#!%{l_prefix}/bin/perl;' \
122 scripts/*
124 # determine additional configure options
125 case "%{l_platform -t}" in
126 *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
127 *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
128 *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;;
129 esac
131 # configure source tree
132 CC="%{l_cc}" \
133 CXX="%{l_cxx}" \
134 CFLAGS="%{l_cflags -O}" \
135 CXXFLAGS="%{l_cxxflags -O}" \
136 CPPFLAGS="%{l_cppflags ncurses}" \
137 LDFLAGS="-L`pwd`/libmysql %{l_ldflags}" \
138 LIBS="-lz" \
139 ./configure \
140 --prefix=%{l_prefix} \
141 --mandir=%{l_prefix}/man \
142 --infodir=%{l_prefix}/info \
143 --sysconfdir=%{l_prefix}/etc/mysql \
144 --localstatedir=%{l_prefix}/var/mysql \
145 --libexecdir=%{l_prefix}/libexec/mysql \
146 --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \
147 --with-mysqld-user=%{l_musr} \
148 --enable-thread-safe-client \
149 --with-comment="%{l_openpkg_release}" \
150 %if "%{with_server}" != "yes"
151 --without-server \
152 %else
153 --with-server \
154 --with-plugin-csv \
155 --with-plugin-heap \
156 --with-plugin-myisam \
157 --with-plugin-myisammrg \
158 %if "%{with_innobase}" == "yes"
159 --with-plugin-innobase \
160 %else
161 --without-plugin-innobase \
162 %endif
163 %if "%{with_archive}" == "yes"
164 --with-plugin-archive \
165 %else
166 --without-plugin-archive \
167 %endif
168 %if "%{with_blackhole}" == "yes"
169 --with-plugin-blackhole \
170 %else
171 --without-plugin-blackhole \
172 %endif
173 %if "%{with_federated}" == "yes"
174 --with-plugin-federated \
175 %else
176 --without-plugin-federated \
177 %endif
178 %if "%{with_ndbcluster}" == "yes"
179 --with-plugin-ndbcluster \
180 %else
181 --without-plugin-ndbcluster \
182 %endif
183 %if "%{with_partition}" == "yes"
184 --with-plugin-partition \
185 %else
186 --without-plugin-partition \
187 %endif
188 %endif
189 --with-zlib-dir=%{l_prefix} \
190 %if "%{with_ssl}" == "yes"
191 --with-ssl=%{l_prefix} \
192 %endif
193 %if "%{with_embedded}" == "yes"
194 --with-embedded-server \
195 %endif
196 --with-charset=%{with_charset} \
197 --with-collation=%{with_collation} \
198 --without-readline \
199 --without-libedit \
200 --with-big-tables \
201 --with-low-memory \
202 --disable-shared \
203 $opt
205 # build source tree
206 %{l_make} %{l_mflags}
208 %install
210 # patch init script
211 %{l_shtool} subst %{l_value -s -a} \
212 scripts/mysql_install_db.sh
214 # perform standard installation procedure
215 %{l_make} %{l_mflags} install \
216 AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \
217 DESTDIR=$RPM_BUILD_ROOT
219 # cleanup mysql_config script
220 %{l_shtool} subst \
221 -e 's;^\(ldflags=.\).*\(.\)$;\1%{l_ldflags}\2;' \
222 $RPM_BUILD_ROOT%{l_prefix}/bin/mysql_config
224 # move utility 'replace', msql2mysql is patched for new path
225 mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
226 $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
228 # strip installation area
229 rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
230 rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
231 rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
232 rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec
233 rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
234 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution
235 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution
236 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err
237 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
238 strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
239 %if "%{with_ndbcluster}" == "yes"
240 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ndb*
241 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/ndb*
242 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/ndb*
243 rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/mysql/storage/ndb
244 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/libndb*
245 rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/ndb*
246 rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/ndb-config-2-node.ini
247 %endif
249 # install global configuration
250 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
251 sed <%{SOURCE my.cnf} >my.cnf \
252 %if "%{with_innobase}" == "yes"
253 -e '/<\/\{0,1\}with_innobase>/d'
254 %else
255 -e '/<with_innobase>/,/<\/with_innobase>/d'
256 %endif
257 %{l_shtool} install -c -m 644 %{l_value -s -a} \
258 my.cnf \
259 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
260 %{l_shtool} install -c -m 600 \
261 %{SOURCE my.pwd} \
262 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
264 # install run-command script
265 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
266 %{l_shtool} install -c -m 755 %{l_value -s -a} \
267 %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
269 # make sure the database directory exists
270 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
272 # directory for temporary tables
273 %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
275 # optional client-only installation
276 %if "%{with_server}" != "yes"
277 rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
278 ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
279 for bin in *; do
280 case "$bin" in
281 mysql | mysql_config ) ;;
282 * ) rm -f $bin ;;
283 esac
284 done
285 ) || exit $?
286 ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
287 for man in *; do
288 case "$man" in
289 mysql.1 | mysql_config.1 ) ;;
290 * ) rm -f $man ;;
291 esac
292 done
293 ) || exit $?
294 %endif
296 # install JDBC driver
297 %if "%{with_jdbc}" == "yes"
298 ( cd mysql-connector-java-%{V_jdbc}
299 %{l_shtool} install -c -m 644 \
300 mysql-connector-java-%{V_jdbc}-bin.jar \
301 $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/mysql.jar
302 ) || exit $?
303 %endif
305 # determine the package files
306 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
307 %if "%{with_server}" == "yes"
308 %{l_files_std} \
309 '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
310 '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
311 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
312 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
313 %else
314 %{l_files_std}
315 %endif
317 %files -f files
319 %clean
321 %pre
322 %if "%{with_server}" == "yes"
323 # before upgrade, save status and stop service
324 [ $1 -eq 2 ] || exit 0
325 eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
326 %{l_rc} mysql stop 2>/dev/null
327 %endif
328 exit 0
330 %post
331 %if "%{with_server}" == "yes"
332 if [ $1 -eq 1 ]; then
333 # after install, create initial database
334 $RPM_INSTALL_PREFIX/bin/mysql_install_db \
335 --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1
336 chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/*
337 ( echo "An initial MySQL DB was created. The owner of the database"
338 echo "is the DB user 'root'. Its initial password is empty."
339 echo "After starting MySQL with..."
340 echo ""
341 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
342 echo ""
343 echo "...you should change the password as soon as possible with:"
344 echo ""
345 echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
346 echo " -u root password '<new-password>'"
347 echo ""
348 echo "Additionally, because the MySQL package includes automated"
349 echo "maintenance procedures that require administrator access to"
350 echo "the database, you must maintain a (plain text) copy of the"
351 echo "administrator account name and password:"
352 echo ""
353 echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
354 ) | %{l_rpmtool} msg -b -t notice
355 fi
356 if [ $1 -eq 2 ]; then
357 # after upgrade, restore status
358 { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
359 [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
360 fi
361 %endif
362 exit 0
364 %preun
365 %if "%{with_server}" == "yes"
366 # before erase, stop service and remove log files
367 [ $1 -eq 0 ] || exit 0
368 %{l_rc} mysql stop 2>/dev/null
369 rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
370 rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
371 %endif
372 exit 0