mysql/mysql.spec

Sun, 24 Aug 2014 13:49:27 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sun, 24 Aug 2014 13:49:27 +0200
changeset 794
07be25b95aca
parent 528
3b08e6396b45
permissions
-rw-r--r--

Accommodate architecture segregated lib(32|64|...) library paths.

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@528 25 %define V_major 5.5
michael@528 26 %define V_minor 27
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@528 42 Release: 20120800
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@528 52 %option with_perfschema no
michael@527 53 %option with_ssl no
michael@527 54 %option with_embedded no
michael@527 55 %option with_charset utf8
michael@527 56 %option with_collation utf8_unicode_ci
michael@527 57 %option with_jdbc no
michael@527 58
michael@528 59 # fixing implicit interplugin dependencies and correlations
michael@527 60 %if "%{with_ndbcluster}" == "yes"
michael@527 61 %undefine with_partition
michael@527 62 %define with_partition yes
michael@527 63 %endif
michael@527 64
michael@527 65 # list of sources
michael@528 66 Source0: http://www.mysql.com/Downloads/MySQL-%{V_major}/mysql-%{V_mysql}.tar.gz
michael@527 67 Source1: http://ftp.gwdg.de/pub/misc/mysql/Downloads/Connector-J/mysql-connector-java-%{V_jdbc}.tar.gz
michael@527 68 Source2: my.cnf
michael@527 69 Source3: my.pwd
michael@527 70 Source4: rc.mysql
michael@527 71 Patch0: mysql.patch
michael@527 72
michael@527 73 # build information
michael@698 74 BuildPreReq: OpenPKG, openpkg >= 20100101, perl, make, cmake, gcc, gcc::with_cxx = yes
michael@527 75 PreReq: OpenPKG, openpkg >= 20100101, perl
michael@527 76 BuildPreReq: zlib, readline, ncurses
michael@527 77 PreReq: zlib, readline, ncurses
michael@527 78 %if "%{with_ssl}" == "yes"
michael@527 79 BuildPreReq: openssl
michael@527 80 PreReq: openssl
michael@527 81 %endif
michael@527 82 %if "%{with_jdbc}" == "yes"
michael@527 83 PreReq: java, JAVA-JDK
michael@527 84 %endif
michael@527 85
michael@527 86 %description
michael@528 87 MySQL is a multiuser Relational Database Management System (RDBMS),
michael@527 88 which is controlled through Structured Query Language (SQL)
michael@528 89 operating in full multithreading mode. The main goals of MySQL are
michael@527 90 speed, robustness and ease of use. MySQL was originally developed
michael@527 91 because of the need for a SQL server that could handle very big
michael@527 92 databases with magnitude higher speed than what any database vendor
michael@527 93 could offer.
michael@527 94
michael@527 95 %track
michael@527 96 prog mysql = {
michael@527 97 version = %{V_mysql}
michael@527 98 url = http://dev.mysql.com/downloads/mysql/%{V_major}.html
michael@527 99 regex = mysql-(__VER__)\.tar\.gz
michael@527 100 }
michael@527 101 prog mysql:connector-jdbc = {
michael@527 102 version = %{V_jdbc}
michael@527 103 url = http://dev.mysql.com/downloads/connector/j/%{V_major}.html
michael@527 104 regex = mysql-connector-java-(__VER__)\.tar\.gz
michael@527 105 }
michael@527 106
michael@527 107 %prep
michael@527 108 %setup -q
michael@527 109 %if "%{with_jdbc}" == "yes"
michael@527 110 %setup -q -T -D -a 1
michael@527 111 %endif
michael@527 112 %patch -p0
michael@527 113
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@528 124 %build
michael@528 125 # create build subdirectory
michael@528 126 %{l_shtool} mkdir -p objbld
michael@528 127 cd objbld
michael@527 128
michael@528 129 # configure environment
michael@528 130 export CC="%{l_cc}"
michael@528 131 export CXX="%{l_cxx}"
michael@528 132 export CFLAGS="%{l_cflags -O}"
michael@528 133 export CXXFLAGS="%{l_cxxflags -O} -felide-constructors -fno-exceptions -fno-rtti"
michael@528 134 export CPPFLAGS="%{l_cppflags ncurses}"
michael@528 135 export LDFLAGS="-L`pwd`/libmysql %{l_ldflags}"
michael@528 136 export LIBS="-lz"
michael@528 137
michael@528 138 # Configure source tree.
michael@528 139 # Tips are in mysql_release.cmake
michael@528 140 # or run cmake(1) -L for all opts
michael@528 141 # Disable dtrace(1) to avoid 'mysqld_dtrace_all.o: file not recognized: Bad value'
michael@528 142 %{l_prefix}/bin/cmake \
michael@528 143 -DCMAKE_INSTALL_PREFIX="%{l_prefix}" \
michael@528 144 -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
michael@528 145 -DINSTALL_DOCDIR="share/mysql/doc" \
michael@528 146 -DINSTALL_DOCREADMEDIR="share/mysql/doc" \
michael@528 147 -DINSTALL_INCLUDEDIR="include/mysql" \
michael@528 148 -DINSTALL_INFODIR:STRING="info" \
michael@528 149 -DINSTALL_MYSQLSHAREDIR="share/mysql" \
michael@528 150 -DINSTALL_SBINDIR="libexec/mysql" \
michael@528 151 -DINSTALL_SHAREDIR="share/mysql" \
michael@528 152 -DINSTALL_SCRIPTDIR="bin" \
michael@528 153 -DINSTALL_SUPPORTFILESDIR="share/mysql" \
michael@528 154 -DMYSQL_UNIX_ADDR="%{l_prefix}/var/mysql/mysql.sock" \
michael@528 155 -DFEATURE_SET="community" \
michael@528 156 -DCOMPILATION_COMMENT="%{l_openpkg_release}" \
michael@528 157 -DMANUFACTURER="Built from OpenPKG sources" \
michael@528 158 -DDEFAULT_CHARSET="%{with_charset}" \
michael@528 159 -DDEFAULT_COLLATION="%{with_collation}" \
michael@528 160 -DMYSQL_USER="%{l_musr}" \
michael@528 161 -DWITH_ZLIB=system \
michael@528 162 -DWITH_READLINE=YES \
michael@528 163 -DWITH_LIBEDIT=NO \
michael@528 164 -DWITH_LIBWRAP=NO \
michael@528 165 -DDISABLE_SHARED=YES \
michael@528 166 -DENABLE_DTRACE=NO \
michael@528 167 -DZLIB_INCLUDE_DIR=%{l_cppflags zlib} \
michael@528 168 -DPKG_CONFIG_EXECUTABLE="PKG_CONFIG_EXECUTABLE-NOTFOUND" \
michael@527 169 %if "%{with_server}" != "yes"
michael@528 170 -DWITHOUT_SERVER=YES \
michael@528 171 %endif
michael@528 172 %if "%{with_ssl}" == "yes"
michael@528 173 -DWITH_SSL=system \
michael@528 174 -DOPENSSL_INCLUDE_DIR="%{l_cppflags openssl}" \
michael@528 175 -DOPENSSL_SSL_LIBRARY="%{l_prefix}/lib/libssl.a" \
michael@528 176 -DOPENSSL_CRYPTO_LIBRARY="%{l_prefix}/lib/libcrypto.a" \
michael@528 177 -DCRYPTO_LIBRARY="%{l_prefix}/lib/libcrypto.a" \
michael@527 178 %else
michael@528 179 -DWITH_SSL=NO \
michael@528 180 %endif
michael@527 181 %if "%{with_innobase}" == "yes"
michael@528 182 -DWITH_INNOBASE_STORAGE_ENGINE=YES \
michael@527 183 %else
michael@528 184 -DWITH_INNOBASE_STORAGE_ENGINE=NO \
michael@527 185 %endif
michael@527 186 %if "%{with_archive}" == "yes"
michael@528 187 -DWITH_ARCHIVE_STORAGE_ENGINE=YES \
michael@527 188 %else
michael@528 189 -DWITH_ARCHIVE_STORAGE_ENGINE=NO \
michael@527 190 %endif
michael@527 191 %if "%{with_blackhole}" == "yes"
michael@528 192 -DWITH_BLACKHOLE_STORAGE_ENGINE=YES \
michael@527 193 %else
michael@528 194 -DWITH_BLACKHOLE_STORAGE_ENGINE=NO \
michael@527 195 %endif
michael@527 196 %if "%{with_federated}" == "yes"
michael@528 197 -DWITH_FEDERATED_STORAGE_ENGINE=YES \
michael@527 198 %else
michael@528 199 -DWITH_FEDERATED_STORAGE_ENGINE=NO \
michael@527 200 %endif
michael@527 201 %if "%{with_ndbcluster}" == "yes"
michael@528 202 -DWITH_NDBCLUSTER_STORAGE_ENGINE=YES \
michael@527 203 %else
michael@528 204 -DWITH_NDBCLUSTER_STORAGE_ENGINE=NO \
michael@527 205 %endif
michael@527 206 %if "%{with_partition}" == "yes"
michael@528 207 -DWITH_PARTITION_STORAGE_ENGINE=YES \
michael@527 208 %else
michael@528 209 -DWITH_PARTITION_STORAGE_ENGINE=NO \
michael@527 210 %endif
michael@528 211 %if "%{with_perfschema}" == "yes"
michael@528 212 -DWITH_PERFSCHEMA_STORAGE_ENGINE=YES \
michael@528 213 %else
michael@528 214 -DWITH_PERFSCHEMA_STORAGE_ENGINE=NO \
michael@527 215 %endif
michael@527 216 %if "%{with_embedded}" == "yes"
michael@528 217 -DWITH_EMBEDDED_SERVER=YES \
michael@528 218 %else
michael@528 219 -DWITH_EMBEDDED_SERVER=NO \
michael@527 220 %endif
michael@528 221 ..
michael@527 222
michael@528 223 # build source tree (VERBOSE=1)
michael@528 224 %{l_make} %{l_mflags -O}
michael@527 225
michael@527 226 %install
michael@528 227 # install from build subdirectory
michael@528 228 cd objbld
michael@527 229
michael@528 230 ## patch init script (this broken)
michael@528 231 #%{l_shtool} subst %{l_value -s -a} \
michael@528 232 # bin/mysql_install_db.sh
michael@527 233
michael@527 234 # perform standard installation procedure
michael@527 235 %{l_make} %{l_mflags} install \
michael@527 236 DESTDIR=$RPM_BUILD_ROOT
michael@527 237
michael@528 238 # cleanup scripts
michael@527 239 %{l_shtool} subst \
michael@527 240 -e 's;^\(ldflags=.\).*\(.\)$;\1%{l_ldflags}\2;' \
michael@527 241 $RPM_BUILD_ROOT%{l_prefix}/bin/mysql_config
michael@527 242
michael@528 243 # move utilities, patched for new paths
michael@527 244 mv $RPM_BUILD_ROOT%{l_prefix}/bin/replace \
michael@527 245 $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/
michael@527 246
michael@527 247 # strip installation area
michael@528 248 rm -rf $RPM_BUILD_ROOT%{l_prefix}/data
michael@527 249 rm -rf $RPM_BUILD_ROOT%{l_prefix}/mysql-test
michael@527 250 rm -rf $RPM_BUILD_ROOT%{l_prefix}/sql-bench
michael@527 251 rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/binary-configure
michael@528 252 rm -f $RPM_BUILD_ROOT%{l_prefix}/share/mysql/ndb-config-2-node.ini
michael@527 253 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* 2>/dev/null || true
michael@527 254 strip $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/* 2>/dev/null || true
michael@527 255 %if "%{with_ndbcluster}" == "yes"
michael@527 256 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/ndb*
michael@527 257 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/ndb*
michael@527 258 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/ndb*
michael@527 259 rm -rf $RPM_BUILD_ROOT%{l_prefix}/include/mysql/storage/ndb
michael@527 260 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/libndb*
michael@527 261 rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql/ndb*
michael@527 262 %endif
michael@527 263
michael@527 264 # install global configuration
michael@527 265 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql
michael@527 266 sed <%{SOURCE my.cnf} >my.cnf \
michael@527 267 %if "%{with_innobase}" == "yes"
michael@527 268 -e '/<\/\{0,1\}with_innobase>/d'
michael@527 269 %else
michael@527 270 -e '/<with_innobase>/,/<\/with_innobase>/d'
michael@527 271 %endif
michael@527 272 %{l_shtool} install -c -m 644 %{l_value -s -a} \
michael@527 273 my.cnf \
michael@527 274 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
michael@527 275 %{l_shtool} install -c -m 600 \
michael@527 276 %{SOURCE my.pwd} \
michael@527 277 $RPM_BUILD_ROOT%{l_prefix}/etc/mysql/
michael@527 278
michael@528 279 # install runcommand script
michael@527 280 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
michael@527 281 %{l_shtool} install -c -m 755 %{l_value -s -a} \
michael@527 282 %{SOURCE rc.mysql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
michael@527 283
michael@528 284 # mitigate complex buildconf
michael@528 285 %{l_shtool} install -c -m 644 \
michael@698 286 ../INSTALL-SOURCE $RPM_BUILD_ROOT%{l_prefix}/share/mysql/doc/
michael@528 287
michael@527 288 # make sure the database directory exists
michael@527 289 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/mysql
michael@527 290
michael@527 291 # directory for temporary tables
michael@527 292 %{l_shtool} mkdir -f -p -m 700 $RPM_BUILD_ROOT%{l_prefix}/var/mysql/tmp
michael@527 293
michael@527 294 # optional client-only installation
michael@527 295 %if "%{with_server}" != "yes"
michael@527 296 rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/mysql
michael@527 297 ( cd $RPM_BUILD_ROOT%{l_prefix}/bin
michael@527 298 for bin in *; do
michael@527 299 case "$bin" in
michael@527 300 mysql | mysql_config ) ;;
michael@527 301 * ) rm -f $bin ;;
michael@527 302 esac
michael@527 303 done
michael@527 304 ) || exit $?
michael@527 305 ( cd $RPM_BUILD_ROOT%{l_prefix}/man/man1
michael@527 306 for man in *; do
michael@527 307 case "$man" in
michael@527 308 mysql.1 | mysql_config.1 ) ;;
michael@527 309 * ) rm -f $man ;;
michael@527 310 esac
michael@527 311 done
michael@527 312 ) || exit $?
michael@527 313 %endif
michael@527 314
michael@527 315 # install JDBC driver
michael@527 316 %if "%{with_jdbc}" == "yes"
michael@527 317 ( cd mysql-connector-java-%{V_jdbc}
michael@527 318 %{l_shtool} install -c -m 644 \
michael@527 319 mysql-connector-java-%{V_jdbc}-bin.jar \
michael@527 320 $RPM_BUILD_ROOT%{l_prefix}/lib/mysql/mysql.jar
michael@527 321 ) || exit $?
michael@527 322 %endif
michael@527 323
michael@527 324 # determine the package files
michael@527 325 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
michael@527 326 %if "%{with_server}" == "yes"
michael@698 327 %{l_files_std} \
michael@527 328 '%config %attr(644,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.cnf' \
michael@527 329 '%config %attr(600,%{l_susr},%{l_mgrp}) %{l_prefix}/etc/mysql/my.pwd' \
michael@527 330 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql' \
michael@698 331 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/mysql/tmp'
michael@698 332 %else
michael@698 333 %{l_files_std}
michael@528 334 %endif
michael@527 335
michael@528 336 %files -f objbld/files
michael@527 337
michael@527 338 %clean
michael@527 339
michael@527 340 %pre
michael@527 341 %if "%{with_server}" == "yes"
michael@527 342 # before upgrade, save status and stop service
michael@527 343 [ $1 -eq 2 ] || exit 0
michael@527 344 eval `%{l_rc} mysql status 2>/dev/null | tee %{l_tmpfile}`
michael@527 345 %{l_rc} mysql stop 2>/dev/null
michael@527 346 %endif
michael@527 347 exit 0
michael@527 348
michael@527 349 %post
michael@527 350 %if "%{with_server}" == "yes"
michael@527 351 if [ $1 -eq 1 ]; then
michael@527 352 # after install, create initial database
michael@698 353 cd $RPM_INSTALL_PREFIX && $RPM_INSTALL_PREFIX/bin/mysql_install_db \
michael@698 354 --defaults-file=$RPM_INSTALL_PREFIX/etc/mysql/my.cnf \
michael@698 355 --ldata=$RPM_INSTALL_PREFIX/var/mysql \
michael@698 356 --user=%{l_rusr} >/dev/null 2>&1
michael@698 357 chgrp %{l_rgrp} $RPM_INSTALL_PREFIX/var/mysql/mysql
michael@527 358 ( echo "An initial MySQL DB was created. The owner of the database"
michael@527 359 echo "is the DB user 'root'. Its initial password is empty."
michael@527 360 echo "After starting MySQL with..."
michael@527 361 echo ""
michael@527 362 echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start"
michael@527 363 echo ""
michael@527 364 echo "...you should change the password as soon as possible with:"
michael@527 365 echo ""
michael@527 366 echo " \$ $RPM_INSTALL_PREFIX/bin/mysqladmin \\ "
michael@527 367 echo " -u root password '<new-password>'"
michael@527 368 echo ""
michael@698 369 echo "...or alternatively, even better secure the database with:"
michael@698 370 echo ""
michael@698 371 echo " \$ $RPM_INSTALL_PREFIX/bin/mysql_secure_installation"
michael@698 372 echo ""
michael@527 373 echo "Additionally, because the MySQL package includes automated"
michael@527 374 echo "maintenance procedures that require administrator access to"
michael@527 375 echo "the database, you must maintain a (plain text) copy of the"
michael@527 376 echo "administrator account name and password:"
michael@527 377 echo ""
michael@527 378 echo " \$ vi $RPM_INSTALL_PREFIX/etc/mysql/my.pwd"
michael@527 379 ) | %{l_rpmtool} msg -b -t notice
michael@527 380 fi
michael@527 381 if [ $1 -eq 2 ]; then
michael@527 382 # after upgrade, restore status
michael@527 383 { eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}; true; } >/dev/null 2>&1
michael@527 384 [ ".$mysql_active" = .yes ] && %{l_rc} mysql start
michael@527 385 fi
michael@527 386 %endif
michael@527 387 exit 0
michael@527 388
michael@527 389 %preun
michael@527 390 %if "%{with_server}" == "yes"
michael@527 391 # before erase, stop service and remove log files
michael@527 392 [ $1 -eq 0 ] || exit 0
michael@527 393 %{l_rc} mysql stop 2>/dev/null
michael@527 394 rm -f $RPM_INSTALL_PREFIX/var/mysql/*.log* >/dev/null 2>&1 || true
michael@527 395 rm -f $RPM_INSTALL_PREFIX/var/mysql/*.err* >/dev/null 2>&1 || true
michael@527 396 %endif
michael@527 397 exit 0
michael@527 398

mercurial