Skip to content
Permalink
Browse files

mariadb-10.3: new port

  • Loading branch information
michaelld committed Jun 26, 2020
1 parent a6f9ee4 commit 53cecb189a44087a274b9881e7f348314631f244
@@ -0,0 +1,300 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup legacysupport 1.0
legacysupport.newest_darwin_requires_legacy 10

name mariadb-10.3
set name_mysql ${name}
version 10.3.23
set version_branch [join [lrange [split ${version} .] 0 1] .]
# Please set revision_client and revision_server to 0 if you bump
# version; these can be changed independently for the 2 subports, but
# can be changed at the same time if that's what's required.
set revision_client 0
set revision_server 0
categories databases
platforms darwin
license GPL-2
maintainers {michaelld @michaelld} openmaintainer

if {$subport eq $name} {

PortGroup cmake 1.0
PortGroup select 1.0
PortGroup github 1.0

compiler.cxx_standard 2011

github.setup MariaDB server ${version} mariadb-
revision ${revision_client}

license GPL-2
description Multithreaded SQL database server
long_description Mariadb is a fork of the MySQL server, a multi-threaded SQL database.

cmake.out_of_source yes
use_parallel_build yes

# mariadb-connector-c is a submodule, but because we're not
# cloning into a GIT module in the first place, we can't use the
# git submodule feature. Have to download separately and install
# into the correct location to get this port to work! Which means
# we need a mariadb-connector-c branch and so forth ... basically
# replicate what the github PG does but without using it since it
# is not designed to be used for multiple downloads.

set submodule_github_author MariaDB
set submodule_github_project mariadb-connector-c
set submodule_github_branch 3.1

set main_distname ${distname}
set main_distfile ${distfiles}
set submodule_distname ${submodule_github_project}-${submodule_github_branch}
set submodule_distfile ${submodule_distname}${extract.suffix}

distfiles ${main_distfile}:tagone \
${submodule_distfile}:tagtwo

master_sites ${github.homepage}/archive/${git.branch}:tagone \
https://github.com/${submodule_github_author}/${submodule_github_project}/archive/${submodule_github_branch}:tagtwo

checksums ${main_distfile} \
rmd160 142e747e8cf7bf14c1de8093bfabe4c6b599ce6e \
sha256 bb6cb839d2b91283fcae3611248188e784b2dcc80556f6284b3b979cef0934cf \
size 62922405 \
${submodule_distfile} \
rmd160 363c58e6b30a0f8fb72858d413b9ef97f9ec7905 \
sha256 8fe951d5640eea2f66f911ffd699541f5f55ad0429abc44afeaa3103ca57aefb \
size 751613

worksrcdir ${github.project}-${git.branch}

post-extract {
# put the submodule_github_project directory into position
# remove the original directory
ui_debug "delete ${worksrcpath}/libmariadb"
delete ${worksrcpath}/libmariadb
ui_debug "move ${workpath}/${submodule_distname} ${worksrcpath}/libmariadb"
move ${workpath}/${submodule_distname} ${worksrcpath}/libmariadb
}

depends_lib-append port:zlib port:tcp_wrappers port:ncurses port:judy \
path:lib/libssl.dylib:openssl port:libxml2
depends_run-append port:mysql_select

select.group mysql
select.file ${filespath}/${name_mysql}

post-extract {
file mkdir ${cmake.build_dir}/macports
copy ${filespath}/macports-default.cnf \
${filespath}/my.cnf \
${cmake.build_dir}/macports/
}

patch.pre_args -p1
patchfiles patch-cmake-install_layout.cmake.diff \
patch-CMakeLists.txt.diff \
patch-libmariadb_cmake_install.cmake.diff \
patch-libmariadb_libmariadb_CMakeLists.txt.diff \
patch-libmariadb_mariadb_config_CMakeLists.txt.diff \
patch-cmake_mysql_version.cmake.diff

post-patch {
reinplace "s|@NAME@|${name_mysql}|g" \
${worksrcpath}/cmake/install_layout.cmake
reinplace "s|@NAME@|${name_mysql}|g" \
${worksrcpath}/libmariadb/cmake/install.cmake
reinplace "s|@NAME@|${name_mysql}|g" \
${cmake.build_dir}/macports/macports-default.cnf \
${cmake.build_dir}/macports/my.cnf
reinplace "s|@PREFIX@|${prefix}|g" \
${cmake.build_dir}/macports/macports-default.cnf \
${cmake.build_dir}/macports/my.cnf
move ${worksrcpath}/VERSION ${worksrcpath}/VERSION.txt
}

configure.args-delete \
-DCMAKE_INSTALL_NAME_DIR=${prefix}/lib
configure.args-append \
-DCMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/${name_mysql}/mysql \
-DINSTALL_LAYOUT:STRING=MACPORTS \
-DSYSCONFDIR:PATH=${prefix}/etc/${name_mysql} \
-DMYSQL_UNIX_ADDR:PATH=${prefix}/var/run/${name_mysql}/mysqld.sock \
-DMYSQL_DATADIR:PATH=${prefix}/var/db/${name_mysql} \
-DDEFAULT_CHARSET:STRING=utf8 \
-DDEFAULT_COLLATION:STRING=utf8_general_ci \
-DWITH_EMBEDDED_SERVER:BOOL=ON \
-DWITH_ZLIB:STRING=system \
-DWITH_UNIT_TESTS:BOOL=ON \
-DWITHOUT_CASSANDRA_STORAGE_ENGINE:BOOL=ON \
-DWITHOUT_MROONGA_STORAGE_ENGINE:BOOL=ON \
-DWITHOUT_ROCKSDB_STORAGE_ENGINE:BOOL=ON \
-DWITHOUT_TOKUDB_STORAGE_ENGINE:BOOL=ON \
-DENABLE_GCOV:BOOL=OFF \
-DENABLE_DTRACE:BOOL=OFF \
-DWITH_READLINE:BOOL=ON \
-DWITH_LIBWRAP:BOOL=ON \
-DWITH_SSL:STRING=yes \
-DWITH_SSL_PATH=${prefix} \
-DMYSQL_MAINTAINER_MODE:STRING=AUTO \
-DICONV_LIBRARIES=${prefix}/lib/libiconv.dylib \
-DICONV_INCLUDE_DIR:PATH=${prefix}/include \
-DCONNECT_WITH_LIBXML2=ON

post-destroot {
# proc portdestroot::destroot_finish fails to find and compress our man pages
# so borrow the compress command and run on our files now.
set manpath "${destroot}${prefix}/share/man"
set gzip [findBinary gzip ${portutil::autoconf::gzip_path}]
foreach manpage [glob -type f ${destroot}${prefix}/share/man/${name_mysql}/man\[1-9\]/*] {
# Fix paths in manpages
reinplace -q "s|/etc/|${prefix}/etc/${name_mysql}/|g" ${manpage}
# Compress all manpages with gzip
system "$gzip -9vf ${manpage}"
}
#foreach samp_conffile [glob -type f ${destroot}${prefix}/share/${name_mysql}/support-files/my-*.cnf] {
# # Fix paths in sample configuration files
# reinplace -q "s|/etc/my.cnf|${prefix}/etc/${name_mysql}/my.cnf|g" ${samp_conffile}
#}
xinstall -m 755 -o root -d \
${destroot}${prefix}/etc/${name_mysql}
copy ${cmake.build_dir}/macports/macports-default.cnf \
${destroot}${prefix}/etc/${name_mysql}/
xinstall -m 755 -o root -d \
${destroot}${prefix}/share/${name_mysql}/support-files/macports
copy ${cmake.build_dir}/macports/my.cnf \
${destroot}${prefix}/share/${name_mysql}/support-files/macports/
}

post-install {
if {![file exists ${prefix}/etc/LaunchDaemons/org.macports.${name_mysql}/org.macports.${name_mysql}-server.plist]} {
ui_msg "The ${name_mysql} client has been installed."
ui_msg "To install the ${name_mysql} server, install the ${name_mysql}-server port."
}
}

pre-activate {
# The macports-default.cnf is installed by ${name_mysql}.
# Early versions of ${name_mysql}-server installed macports-default.cnf so for a
# reasonable period we need to deactivate older versions of the ${name_mysql}-server.
if { [file exists ${prefix}/etc/${name_mysql}/macports-default.cnf]
&& ![catch {set vers [lindex [registry_active ${name_mysql}-server] 0]}]
&& [vercmp [lindex $vers 1] 5.5.24] < 0 } {

registry_deactivate_composite ${name_mysql}-server "" [list ports_nodepcheck 1]
}
}

post-activate {
if {![file exists ${prefix}/etc/${name_mysql}/my.cnf]} {
copy ${prefix}/share/${name_mysql}/support-files/macports/my.cnf \
${prefix}/etc/${name_mysql}/
}
}

variant system_readline description {Use system readline instead of bundled readline} {
# Add readline support.
# "-DWITH_READLINE:BOOL=OFF" has the peculiar meaning "do not use the bundled copy
# of readline but use the system's (i.e. MacPorts') copy of readline"
depends_lib-append port:readline
configure.args-delete -DWITH_READLINE:BOOL=ON
configure.args-append -DWITH_READLINE:BOOL=OFF
}

notes "
On activation if no ${prefix}/etc/${name_mysql}/my.cnf file exists one
will be created which loads
${prefix}/etc/${name_mysql}/macports-default.cnf.
If a ${prefix}/etc/${name_mysql}/my.cnf file exists MacPorts does not
touch it and any changes you make to ${prefix}/etc/${name_mysql}/my.cnf
will be preserved (e.g., during port upgrades, deactivations or
activations). ${prefix}/etc/${name_mysql}/my.cnf is a good place to
customize your ${name_mysql} installation.
Any changes made to ${prefix}/etc/${name_mysql}/macports-default.cnf
will be lost during port upgrades, deactivations or activations so you
are advised to not make changes here. Currently
${prefix}/etc/${name_mysql}/macports-default.cnf contains only one
directive; to disable networking. With disabled networking it is
possible to install and have running all the MacPorts mysql ports
simultaneously.
"

github.livecheck.regex (${version_branch}.\[0-9\]+)

}

subport ${name_mysql}-server {

revision ${revision_server}
license BSD
description (Beta version) Run ${name_mysql} as server
long_description {*}${description}

supported_archs noarch
distfiles

depends_run port:${name_mysql}

if {"darwin" eq ${os.platform} && ${os.major} > 8} {
set mysqluser _mysql
} else {
set mysqluser mysql
}
add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server

pre-extract {
copy ${filespath}/org.macports.mysql-server.plist ${workpath}/org.macports.${subport}.plist
}

post-patch {
reinplace "s|@NAMEMYSQL@|${name_mysql}|g" \
${workpath}/org.macports.${subport}.plist
reinplace "s|@PREFIX@|${prefix}|g" \
${workpath}/org.macports.${subport}.plist
reinplace "s|@SUBPORT@|${subport}|g" \
${workpath}/org.macports.${subport}.plist
reinplace "s|@USER@|${mysqluser}|g" \
${workpath}/org.macports.${subport}.plist
reinplace "s|@GROUP@|${mysqluser}|g" \
${workpath}/org.macports.${subport}.plist
}

use_configure no

build {}

destroot {
xinstall -d -m 755 ${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
xinstall -m 0644 -o root -W ${workpath} \
org.macports.${subport}.plist \
${destroot}${prefix}/etc/LaunchDaemons/org.macports.${subport}
xinstall -d -m 755 ${destroot}/Library/LaunchDaemons
ln -s ${prefix}/etc/LaunchDaemons/org.macports.${subport}/org.macports.${subport}.plist \
${destroot}/Library/LaunchDaemons/org.macports.${subport}.plist
xinstall -m 755 -o root -d \
${destroot}${prefix}/var/run
xinstall -m 755 -o ${mysqluser} -g ${mysqluser} -d \
${destroot}${prefix}/etc/${name_mysql} \
${destroot}${prefix}/var/db/${name_mysql} \
${destroot}${prefix}/var/log/${name_mysql} \
${destroot}${prefix}/var/run/${name_mysql}
destroot.keepdirs-append \
${destroot}${prefix}/var/db/${name_mysql} \
${destroot}${prefix}/var/log/${name_mysql} \
${destroot}${prefix}/var/run/${name_mysql}
}

notes "
If this is a new install you might want to run:
\$ sudo -u ${mysqluser} ${prefix}/lib/${name_mysql}/bin/mysql_install_db
"

livecheck.type none
}

homepage https://mariadb.org/
@@ -0,0 +1,9 @@
# WARNING! ANY CHANGES TO THIS FILE WILL BE LOST ON UNINSTALL/UPGRADES!
# Make your changes to @PREFIX@/etc/@NAME@/my.cnf
# YOU HAVE BEEN WARNED!

# MacPorts default options
[mysqld]
# skip-networking so multple mysql server ports can be loaded
# without each competing for port 3306.
skip-networking

0 comments on commit 53cecb1

Please sign in to comment.
You can’t perform that action at this time.