1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mysql/mysql.spec Tue Aug 28 18:28:40 2012 +0200 1.3 @@ -0,0 +1,373 @@ 1.4 +## 1.5 +## mysql.spec -- OpenPKG RPM Package Specification 1.6 +## Copyright (c) 2000-2012 OpenPKG Foundation e.V. <http://openpkg.net/> 1.7 +## 1.8 +## Permission to use, copy, modify, and distribute this software for 1.9 +## any purpose with or without fee is hereby granted, provided that 1.10 +## the above copyright notice and this permission notice appear in all 1.11 +## copies. 1.12 +## 1.13 +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 1.14 +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1.15 +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1.16 +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 1.17 +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.18 +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.19 +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 1.20 +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 1.21 +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1.22 +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1.23 +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1.24 +## SUCH DAMAGE. 1.25 +## 1.26 + 1.27 +# package version 1.28 +%define V_major 5.1 1.29 +%define V_minor 63 1.30 +%define V_mysql %{V_major}.%{V_minor} 1.31 +%define V_opkg %{V_major}.%{V_minor} 1.32 +%define V_jdbc 5.1.21 1.33 + 1.34 +# package information 1.35 +Name: mysql 1.36 +Summary: Fast Relational Database Management System 1.37 +URL: http://www.mysql.com/products/mysql/ 1.38 +Vendor: ORACLE 1.39 +Packager: OpenPKG Foundation e.V. 1.40 +Distribution: OpenPKG Community 1.41 +Class: BASE 1.42 +Group: Database 1.43 +License: GPL 1.44 +Version: %{V_opkg} 1.45 +Release: 20120704 1.46 + 1.47 +# package options 1.48 +%option with_server yes 1.49 +%option with_innobase yes 1.50 +%option with_archive no 1.51 +%option with_blackhole no 1.52 +%option with_federated no 1.53 +%option with_ndbcluster no 1.54 +%option with_partition no 1.55 +%option with_ssl no 1.56 +%option with_embedded no 1.57 +%option with_charset utf8 1.58 +%option with_collation utf8_unicode_ci 1.59 +%option with_jdbc no 1.60 + 1.61 +# fixing implicit inter-plugin dependencies and correlations 1.62 +%if "%{with_ndbcluster}" == "yes" 1.63 +%undefine with_partition 1.64 +%define with_partition yes 1.65 +%endif 1.66 + 1.67 +# list of sources 1.68 +Source0: http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz 1.69 +Source1: http://ftp.gwdg.de/pub/misc/mysql/Downloads/Connector-J/mysql-connector-java-%{V_jdbc}.tar.gz 1.70 +Source2: my.cnf 1.71 +Source3: my.pwd 1.72 +Source4: rc.mysql 1.73 +Patch0: mysql.patch 1.74 + 1.75 +# build information 1.76 +BuildPreReq: OpenPKG, openpkg >= 20100101, perl, make, gcc, gcc::with_cxx = yes 1.77 +PreReq: OpenPKG, openpkg >= 20100101, perl 1.78 +BuildPreReq: zlib, readline, ncurses 1.79 +PreReq: zlib, readline, ncurses 1.80 +%if "%{with_ssl}" == "yes" 1.81 +BuildPreReq: openssl 1.82 +PreReq: openssl 1.83 +%endif 1.84 +%if "%{with_jdbc}" == "yes" 1.85 +PreReq: java, JAVA-JDK 1.86 +%endif 1.87 + 1.88 +%description 1.89 + MySQL is a multi-user Relational Database Management System (RDBMS), 1.90 + which is controlled through Structured Query Language (SQL) 1.91 + operating in full multi-threading mode. The main goals of MySQL are 1.92 + speed, robustness and ease of use. MySQL was originally developed 1.93 + because of the need for a SQL server that could handle very big 1.94 + databases with magnitude higher speed than what any database vendor 1.95 + could offer. 1.96 + 1.97 +%track 1.98 + prog mysql = { 1.99 + version = %{V_mysql} 1.100 + url = http://dev.mysql.com/downloads/mysql/%{V_major}.html 1.101 + regex = mysql-(__VER__)\.tar\.gz 1.102 + } 1.103 + prog mysql:connector-jdbc = { 1.104 + version = %{V_jdbc} 1.105 + url = http://dev.mysql.com/downloads/connector/j/%{V_major}.html 1.106 + regex = mysql-connector-java-(__VER__)\.tar\.gz 1.107 + } 1.108 + 1.109 +%prep 1.110 + %setup -q 1.111 +%if "%{with_jdbc}" == "yes" 1.112 + %setup -q -T -D -a 1 1.113 +%endif 1.114 + %patch -p0 1.115 + 1.116 +%build 1.117 + # patch file search path 1.118 + %{l_shtool} subst %{l_value -s -a} \ 1.119 + mysys/default.c 1.120 + 1.121 + # fix shebang on supplemental Perl scripts 1.122 + rm -f scripts/*.orig 1.123 + %{l_shtool} subst \ 1.124 + -e 's;^#!/usr/bin/perl;#!%{l_prefix}/bin/perl;' \ 1.125 + scripts/* 1.126 + 1.127 + # determine additional configure options 1.128 + case "%{l_platform -t}" in 1.129 + *-freebsd* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;; 1.130 + *-linux* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;; 1.131 + *-sunos* ) opt="--with-client-ldflags=-static --with-mysqld-ldflags=-static" ;; 1.132 + esac 1.133 + 1.134 + # configure source tree 1.135 + CC="%{l_cc}" \ 1.136 + CXX="%{l_cxx}" \ 1.137 + CFLAGS="%{l_cflags -O}" \ 1.138 + CXXFLAGS="%{l_cxxflags -O}" \ 1.139 + CPPFLAGS="%{l_cppflags ncurses}" \ 1.140 + LDFLAGS="-L`pwd`/libmysql %{l_ldflags}" \ 1.141 + LIBS="-lz" \ 1.142 + ./configure \ 1.143 + --prefix=%{l_prefix} \ 1.144 + --mandir=%{l_prefix}/man \ 1.145 + --infodir=%{l_prefix}/info \ 1.146 + --sysconfdir=%{l_prefix}/etc/mysql \ 1.147 + --localstatedir=%{l_prefix}/var/mysql \ 1.148 + --libexecdir=%{l_prefix}/libexec/mysql \ 1.149 + --with-unix-socket-path=%{l_prefix}/var/mysql/mysql.sock \ 1.150 + --with-mysqld-user=%{l_musr} \ 1.151 + --enable-thread-safe-client \ 1.152 + --with-comment="%{l_openpkg_release}" \ 1.153 +%if "%{with_server}" != "yes" 1.154 + --without-server \ 1.155 +%else 1.156 + --with-server \ 1.157 + --with-plugin-csv \ 1.158 + --with-plugin-heap \ 1.159 + --with-plugin-myisam \ 1.160 + --with-plugin-myisammrg \ 1.161 +%if "%{with_innobase}" == "yes" 1.162 + --with-plugin-innobase \ 1.163 +%else 1.164 + --without-plugin-innobase \ 1.165 +%endif 1.166 +%if "%{with_archive}" == "yes" 1.167 + --with-plugin-archive \ 1.168 +%else 1.169 + --without-plugin-archive \ 1.170 +%endif 1.171 +%if "%{with_blackhole}" == "yes" 1.172 + --with-plugin-blackhole \ 1.173 +%else 1.174 + --without-plugin-blackhole \ 1.175 +%endif 1.176 +%if "%{with_federated}" == "yes" 1.177 + --with-plugin-federated \ 1.178 +%else 1.179 + --without-plugin-federated \ 1.180 +%endif 1.181 +%if "%{with_ndbcluster}" == "yes" 1.182 + --with-plugin-ndbcluster \ 1.183 +%else 1.184 + --without-plugin-ndbcluster \ 1.185 +%endif 1.186 +%if "%{with_partition}" == "yes" 1.187 + --with-plugin-partition \ 1.188 +%else 1.189 + --without-plugin-partition \ 1.190 +%endif 1.191 +%endif 1.192 + --with-zlib-dir=%{l_prefix} \ 1.193 +%if "%{with_ssl}" == "yes" 1.194 + --with-ssl=%{l_prefix} \ 1.195 +%endif 1.196 +%if "%{with_embedded}" == "yes" 1.197 + --with-embedded-server \ 1.198 +%endif 1.199 + --with-charset=%{with_charset} \ 1.200 + --with-collation=%{with_collation} \ 1.201 + --without-readline \ 1.202 + --without-libedit \ 1.203 + --with-big-tables \ 1.204 + --with-low-memory \ 1.205 + --disable-shared \ 1.206 + $opt 1.207 + 1.208 + # build source tree 1.209 + %{l_make} %{l_mflags} 1.210 + 1.211 +%install 1.212 + 1.213 + # patch init script 1.214 + %{l_shtool} subst %{l_value -s -a} \ 1.215 + scripts/mysql_install_db.sh 1.216 + 1.217 + # perform standard installation procedure 1.218 + %{l_make} %{l_mflags} install \ 1.219 + AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT" \ 1.220 + DESTDIR=$RPM_BUILD_ROOT 1.221 + 1.222 + # cleanup mysql_config script 1.223 + %{l_shtool} subst \ 1.224 + -e 's;^\(ldflags=.\).*\(.\)$;\1%{l_ldflags}\2;' \ 1.225 + $RPM_BUILD_ROOT%{l_prefix}/bin/mysql_config 1.226 + 1.227 + # move utility 'replace', msql2mysql is patched for new path 1.228 + mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \ 1.229 + $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/ 1.230 + 1.231 + # strip installation area 1.232 + rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test 1.233 + rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench 1.234 + rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir 1.235 + rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/mysql-%{V_mysql}.spec 1.236 + rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure 1.237 + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_src_distribution 1.238 + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/make_win_binary_distribution 1.239 + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/comp_err 1.240 + strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true 1.241 + strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true 1.242 +%if "%{with_ndbcluster}" == "yes" 1.243 + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ndb* 1.244 + rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/ndb* 1.245 + rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/ndb* 1.246 + rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/mysql/storage/ndb 1.247 + rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/libndb* 1.248 + rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/ndb* 1.249 + rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/ndb-config-2-node.ini 1.250 +%endif 1.251 + 1.252 + # install global configuration 1.253 + %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql 1.254 + sed <%{SOURCE my.cnf} >my.cnf \ 1.255 +%if "%{with_innobase}" == "yes" 1.256 + -e '/<\/\{0,1\}with_innobase>/d' 1.257 +%else 1.258 + -e '/<with_innobase>/,/<\/with_innobase>/d' 1.259 +%endif 1.260 + %{l_shtool} install -c -m 644 %{l_value -s -a} \ 1.261 + my.cnf \ 1.262 + $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/ 1.263 + %{l_shtool} install -c -m 600 \ 1.264 + %{SOURCE my.pwd} \ 1.265 + $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/ 1.266 + 1.267 + # install run-command script 1.268 + %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d 1.269 + %{l_shtool} install -c -m 755 %{l_value -s -a} \ 1.270 + %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ 1.271 + 1.272 + # make sure the database directory exists 1.273 + %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql 1.274 + 1.275 + # directory for temporary tables 1.276 + %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp 1.277 + 1.278 + # optional client-only installation 1.279 +%if "%{with_server}" != "yes" 1.280 + rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql 1.281 + ( cd $RPM_BUILD_ROOT%{l_prefix}/bin 1.282 + for bin in *; do 1.283 + case "$bin" in 1.284 + mysql | mysql_config ) ;; 1.285 + * ) rm -f $bin ;; 1.286 + esac 1.287 + done 1.288 + ) || exit $? 1.289 + ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1 1.290 + for man in *; do 1.291 + case "$man" in 1.292 + mysql.1 | mysql_config.1 ) ;; 1.293 + * ) rm -f $man ;; 1.294 + esac 1.295 + done 1.296 + ) || exit $? 1.297 +%endif 1.298 + 1.299 + # install JDBC driver 1.300 +%if "%{with_jdbc}" == "yes" 1.301 + ( cd mysql-connector-java-%{V_jdbc} 1.302 + %{l_shtool} install -c -m 644 \ 1.303 + mysql-connector-java-%{V_jdbc}-bin.jar \ 1.304 + $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/mysql.jar 1.305 + ) || exit $? 1.306 +%endif 1.307 + 1.308 + # determine the package files 1.309 + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ 1.310 +%if "%{with_server}" == "yes" 1.311 + %{l_files_std} \ 1.312 + '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \ 1.313 + '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \ 1.314 + '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \ 1.315 + '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp' 1.316 +%else 1.317 + %{l_files_std} 1.318 +%endif 1.319 + 1.320 +%files -f files 1.321 + 1.322 +%clean 1.323 + 1.324 +%pre 1.325 +%if "%{with_server}" == "yes" 1.326 + # before upgrade, save status and stop service 1.327 + [ $1 -eq 2 ] || exit 0 1.328 + eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}` 1.329 + %{l_rc} mysql stop 2>/dev/null 1.330 +%endif 1.331 + exit 0 1.332 + 1.333 +%post 1.334 +%if "%{with_server}" == "yes" 1.335 + if [ $1 -eq 1 ]; then 1.336 + # after install, create initial database 1.337 + $RPM_INSTALL_PREFIX/bin/mysql_install_db \ 1.338 + --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf >/dev/null 2>&1 1.339 + chown -R %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/* 1.340 + ( echo "An initial MySQL DB was created. The owner of the database" 1.341 + echo "is the DB user 'root'. Its initial password is empty." 1.342 + echo "After starting MySQL with..." 1.343 + echo "" 1.344 + echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start" 1.345 + echo "" 1.346 + echo "...you should change the password as soon as possible with:" 1.347 + echo "" 1.348 + echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ " 1.349 + echo " -u root password '<new-password>'" 1.350 + echo "" 1.351 + echo "Additionally, because the MySQL package includes automated" 1.352 + echo "maintenance procedures that require administrator access to" 1.353 + echo "the database, you must maintain a (plain text) copy of the" 1.354 + echo "administrator account name and password:" 1.355 + echo "" 1.356 + echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd" 1.357 + ) | %{l_rpmtool} msg -b -t notice 1.358 + fi 1.359 + if [ $1 -eq 2 ]; then 1.360 + # after upgrade, restore status 1.361 + { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1 1.362 + [ ".$mysql_active" = .yes ] && %{l_rc} mysql start 1.363 + fi 1.364 +%endif 1.365 + exit 0 1.366 + 1.367 +%preun 1.368 +%if "%{with_server}" == "yes" 1.369 + # before erase, stop service and remove log files 1.370 + [ $1 -eq 0 ] || exit 0 1.371 + %{l_rc} mysql stop 2>/dev/null 1.372 + rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true 1.373 + rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true 1.374 +%endif 1.375 + exit 0 1.376 +