mysql/mysql.spec

Tue, 28 Aug 2012 18:28:40 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 28 Aug 2012 18:28:40 +0200
changeset 527
7b145ccff1e9
child 528
3b08e6396b45
permissions
-rw-r--r--

Import package vendor original specs for necessary manipulations.

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

mercurial