PKGBUILDs/extra/mariadb/PKGBUILD
2019-11-26 13:37:46 +00:00

246 lines
8 KiB
Bash

# Maintainer: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Maintainer: Christian Hesse <mail@eworm.de>
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - disable mroonga storage engine (doesn't build on ARM)
# - patch to link (unused) static libs against libatomic on v5/v6 to fix FTBFS
pkgbase=mariadb
pkgname=('mariadb-libs' 'mariadb-clients' 'mariadb' 'mytop')
pkgdesc='Fast SQL database server, derived from MySQL'
pkgver=10.4.10
pkgrel=2
arch=('x86_64')
license=('GPL')
url='https://mariadb.org/'
makedepends=('boost' 'bzip2' 'cmake' 'jemalloc' 'libaio' 'libxml2' 'lz4' 'lzo'
'openssl' 'systemd' 'zlib' 'zstd')
validpgpkeys=('199369E5404BD5FC7D2FE43BCBCB082A1BB943DB') # MariaDB Package Signing Key <package-signing-key@mariadb.org>
# The default links with mirror redirection fail for signatures, specific
# mirrors may be out of date every now and then. Let's use the upstream
# rsync source and hope it does not hurt them too much.
# https://mariadb.com/kb/en/library/mirror-sites-for-mariadb/
source=("rsync://rsync.osuosl.org/mariadb/mariadb-${pkgver}/source/mariadb-${pkgver}.tar.gz"{,.asc}
'0001-arch-specific.patch'
'0002-systemd-sysusers-tmpfiles.patch'
'0005-fix-galera_recovery-with-fs.protected_regular-enabled.patch'
'0007-MDEV-20646.patch'
'0001-libatomic.patch')
sha256sums=('cd50fddf86c2a47405737e342f78ebd40d5716f0fb32b976245de713bed01421'
'SKIP'
'ce72ea1563ad773e00e8b1c299babea176abae1102827c2f743921e9de615041'
'3e83467af80fbd53400a201a34fc858b88509ea8e88b10709947eb66545f9457'
'c8c801f80924ccb97b499552fe1c532b3ebf8f86cdfc0d23715d4adb1a8810f0'
'825d4ab1601c9e97bf24857bcfd8bed2b6d8ad15a4c2411c7867bff2333b09d8'
'1c7360453b6e964c6546cbbb10fff697f6227554eba716b2a1df74f7c2613d95')
prepare() {
cd $pkgbase-$pkgver/
# Arch Linux specific patches:
# * enable PrivateTmp for a little bit more security
# * force preloading jemalloc for memory management
# * remove aliases in systemd unit files
patch -Np1 < ../0001-arch-specific.patch
# MDEV-17028 Fix glitches with systemd sysusers and tmpfiles:
# * Use descriptive file names for sysusers and tmpfiles configuration
# * Make systemd-tmpfiles create MYSQL_DATADIR
# https://github.com/MariaDB/server/pull/530
patch -Np1 < ../0002-systemd-sysusers-tmpfiles.patch
# fix galera_recovery with fs.protected_regular enabled
# https://github.com/MariaDB/server/pull/1137
patch -Np1 < ../0005-fix-galera_recovery-with-fs.protected_regular-enabled.patch
# MDEV-20646: 10.3.18 is slower than 10.3.17
patch -Np1 < ../0007-MDEV-20646.patch
if [[ $CARCH == arm || $CARCH == armv6h ]]; then
patch -p1 -i ../0001-libatomic.patch
fi
}
build() {
local _cmake_options=(
# build options
-DCOMPILATION_COMMENT="Arch Linux"
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-Wno-dev
# file paths
# /etc
-DINSTALL_SYSCONFDIR=/etc
-DINSTALL_SYSCONF2DIR=/etc/my.cnf.d
# /run
-DINSTALL_UNIX_ADDRDIR=/run/mysqld/mysqld.sock
# /usr
-DCMAKE_INSTALL_PREFIX=/usr
# /usr/bin /usr/include
-DINSTALL_SCRIPTDIR=bin
-DINSTALL_INCLUDEDIR=include/mysql
# /usr/lib
-DINSTALL_PLUGINDIR=lib/mysql/plugin
-DINSTALL_SYSTEMD_UNITDIR=/usr/lib/systemd/system/
-DINSTALL_SYSTEMD_SYSUSERSDIR=/usr/lib/sysusers.d/
-DINSTALL_SYSTEMD_TMPFILESDIR=/usr/lib/tmpfiles.d/
# /usr/share
-DINSTALL_SHAREDIR=share
-DINSTALL_SUPPORTFILESDIR=share/mysql
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_DOCREADMEDIR=share/doc/mariadb
-DINSTALL_DOCDIR=share/doc/mariadb
-DINSTALL_MANDIR=share/man
# /var
-DMYSQL_DATADIR=/var/lib/mysql
# default settings
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_unicode_ci
# features
-DENABLED_LOCAL_INFILE=ON
-DPLUGIN_EXAMPLE=NO
-DPLUGIN_FEDERATED=NO
-DPLUGIN_FEEDBACK=NO
-DWITHOUT_MROONGA_STORAGE_ENGINE=1
-DWITH_EMBEDDED_SERVER=ON
-DWITH_EXTRA_CHARSETS=complex
-DWITH_JEMALLOC=ON
-DWITH_LIBWRAP=OFF
-DWITH_PCRE=bundled
-DWITH_READLINE=ON
-DWITH_SSL=system
-DWITH_SYSTEMD=yes
-DWITH_UNIT_TESTS=OFF
-DWITH_ZLIB=system
)
mkdir build
cd build
cmake ../"$pkgbase-$pkgver" "${_cmake_options[@]}"
make
}
check() {
cd build/mysql-test
# Takes *really* long, so disabled by default.
#./mtr --parallel=5 --mem --force --max-test-fail=0
}
package_mariadb-libs() {
pkgdesc='MariaDB libraries'
depends=('bzip2' 'libaio' 'lz4' 'lzo' 'openssl' 'xz' 'zlib')
conflicts=('libmysqlclient' 'libmariadbclient' 'mariadb-connector-c')
provides=('libmariadbclient' 'mariadb-connector-c')
replaces=('libmariadbclient')
cd build
for dir in libmariadb libmysqld libservices include; do
make -C "$dir" DESTDIR="$pkgdir" install
done
ln -s mariadb_config "$pkgdir"/usr/bin/mysql_config
install -D -m0644 "$srcdir"/"$pkgbase-$pkgver"/man/mysql_config.1 "$pkgdir"/usr/share/man/man1/mysql_config.1
install -D -m0644 support-files/mariadb.pc "$pkgdir"/usr/share/pkgconfig/mariadb.pc
install -D -m0644 "$srcdir"/"$pkgbase-$pkgver"/support-files/mysql.m4 "$pkgdir"/usr/share/aclocal/mysql.m4
cd "$pkgdir"
# remove static libraries
rm usr/lib/*.a
}
package_mariadb-clients() {
pkgdesc='MariaDB client tools'
depends=("mariadb-libs=${pkgver}" 'jemalloc')
conflicts=('mysql-clients')
provides=("mysql-clients=$pkgver")
cd build
make -C client DESTDIR="$pkgdir" install
# install man pages
for man in mysql mysql_plugin mysql_upgrade mysqladmin mysqlbinlog mysqlcheck mysqldump mysqlimport mysqlshow mysqlslap mysqltest; do
install -D -m0644 "$srcdir"/"$pkgbase-$pkgver"/man/"$man.1" "$pkgdir"/usr/share/man/man1/"$man.1"
done
}
package_mariadb() {
pkgdesc='Fast SQL database server, derived from MySQL'
backup=('etc/my.cnf'
'etc/my.cnf.d/client.cnf'
'etc/my.cnf.d/enable_encryption.preset'
'etc/my.cnf.d/mysql-clients.cnf'
'etc/my.cnf.d/server.cnf')
install=mariadb.install
depends=("mariadb-clients=${pkgver}" 'inetutils' 'systemd-libs' 'libxml2' 'zstd')
optdepends=('galera: for MariaDB cluster with Galera WSREP'
'perl-dbd-mysql: for mysqlhotcopy, mysql_convert_table_format and mysql_setpermission')
conflicts=('mysql')
provides=("mysql=$pkgver")
options=('emptydirs')
cd build
make DESTDIR="$pkgdir" install
cd "$pkgdir"
# no SysV init, please!
rm -r etc/logrotate.d
rm usr/bin/rcmysql
rm usr/share/mysql/{binary-configure,mysql{,d_multi}.server}
# link service files with old name for compatibility
ln -s mariadb.service usr/lib/systemd/system/mysqld.service
ln -s mariadb@.service usr/lib/systemd/system/mysqld@.service
# move to proper licenses directories
install -d usr/share/licenses/mariadb
mv usr/share/doc/mariadb/COPYING* usr/share/licenses/mariadb/
# move it where one might look for it
#mv usr/share/{groonga{,-normalizer-mysql},doc/mariadb/}
# already installed to real systemd unit directory or useless
rm -r usr/share/mysql/systemd/
rm -r usr/lib/systemd/system/mariadb@bootstrap.service.d
# provided by mariadb-libs
rm usr/bin/mariadb_config
rm usr/bin/mysql_config
rm -r usr/include/
rm usr/share/man/man1/mysql_config.1
rm -r usr/share/{aclocal,pkgconfig}
rm usr/lib/lib*
rm usr/lib/mysql/plugin/{auth_gssapi_client,caching_sha2_password,client_ed25519,dialog,mysql_clear_password,sha256_password}.so
rm -r usr/lib/pkgconfig/
# provided by mariadb-clients
rm usr/bin/mysql{,_plugin,_upgrade,admin,binlog,check,dump,import,show,slap,test}
rm usr/bin/mariadb{,-{admin,binlog,check,dump,import,plugin,show,slap,test,upgrade}}
rm usr/share/man/man1/mysql{,_plugin,_upgrade,admin,binlog,check,dump,import,show,slap,test}.1
# provided by mytop
rm usr/bin/mytop
# not needed
rm -r usr/{data,mysql-test,sql-bench}
rm usr/share/man/man1/mysql-test-run.pl.1
}
package_mytop() {
pkgdesc='Top clone for MariaDB'
depends=('perl' 'perl-dbd-mysql' 'perl-term-readkey')
cd build
install -D -m0755 scripts/mytop "$pkgdir"/usr/bin/mytop
}