summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-support')
-rw-r--r--meta-oe/recipes-support/mysql/mariadb.inc51
-rwxr-xr-xmeta-oe/recipes-support/mysql/mariadb/install_db13
-rw-r--r--meta-oe/recipes-support/mysql/mariadb/install_db.service17
-rw-r--r--meta-oe/recipes-support/mysql/mariadb/my.cnf1
-rw-r--r--meta-oe/recipes-support/mysql/mariadb/mysql-systemd-start66
-rw-r--r--meta-oe/recipes-support/mysql/mariadb/mysqld.service9
6 files changed, 132 insertions, 25 deletions
diff --git a/meta-oe/recipes-support/mysql/mariadb.inc b/meta-oe/recipes-support/mysql/mariadb.inc
index 42a4eda65..a6826c31e 100644
--- a/meta-oe/recipes-support/mysql/mariadb.inc
+++ b/meta-oe/recipes-support/mysql/mariadb.inc
@@ -10,6 +10,9 @@ SRC_URI = "http://archive.mariadb.org/mariadb-${PV}/source/mariadb-${PV}.tar.gz
10 file://fix-mysqlclient-r-version.patch \ 10 file://fix-mysqlclient-r-version.patch \
11 file://my.cnf \ 11 file://my.cnf \
12 file://mysqld.service \ 12 file://mysqld.service \
13 file://install_db.service \
14 file://install_db \
15 file://mysql-systemd-start \
13 file://configure.cmake-fix-valgrind.patch \ 16 file://configure.cmake-fix-valgrind.patch \
14 file://fix-a-building-failure.patch \ 17 file://fix-a-building-failure.patch \
15 " 18 "
@@ -23,26 +26,35 @@ BINCONFIG_GLOB = "mysql_config"
23 26
24inherit cmake gettext binconfig update-rc.d useradd systemd 27inherit cmake gettext binconfig update-rc.d useradd systemd
25 28
26INITSCRIPT_PACKAGES = "${PN}-server" 29INITSCRIPT_PACKAGES = "${PN}-server ${PN}-setupdb"
27INITSCRIPT_NAME = "mysqld" 30INITSCRIPT_NAME_${PN}-server = "mysqld"
28INITSCRIPT_PARAMS = "start 45 5 . stop 45 0 6 1 ." 31INITSCRIPT_PARAMS_${PN}-server ?= "start 45 5 . stop 45 0 6 1 ."
29 32
30USERADD_PACKAGES = "${PN}-server" 33USERADD_PACKAGES = "${PN}-server"
31USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql" 34USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql"
32GROUPADD_PARAM_${PN}-server = "--system mysql" 35GROUPADD_PARAM_${PN}-server = "--system mysql"
33 36
34SYSTEMD_PACKAGES = "${PN}-server" 37INITSCRIPT_NAME_${PN}-setupdb = "install_db"
38INITSCRIPT_PARAMS_${PN}-setupdb ?= "defaults 44 44"
39
40SYSTEMD_PACKAGES = "${PN}-server ${PN}-setupdb"
35SYSTEMD_SERVICE_${PN}-server = "mysqld.service" 41SYSTEMD_SERVICE_${PN}-server = "mysqld.service"
36SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" 42SYSTEMD_AUTO_ENABLE_${PN}-server ?= "disable"
43
44SYSTEMD_SERVICE_${PN}-setupdb = "install_db.service"
45SYSTEMD_AUTO_ENABLE_${PN}-setupdb ?= "enable"
46ALLOW_EMPTY_${PN}-setupdb ?= "1"
47FILES_${PN}-setupdb = "${sysconfdir}/init.d/install_db"
37 48
38EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'" 49EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'"
39 50
40PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" 51PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)} setupdb"
41PACKAGECONFIG_class-native = "" 52PACKAGECONFIG_class-native = ""
42PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam" 53PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam"
43PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind" 54PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind"
44PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit" 55PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit"
45PACKAGECONFIG[krb5] = ", ,krb5" 56PACKAGECONFIG[krb5] = ", ,krb5"
57PACKAGECONFIG[setupdb] = ", ,,${PN}-setupdb"
46 58
47# MariaDB doesn't link properly with gold 59# MariaDB doesn't link properly with gold
48# https://mariadb.atlassian.net/browse/MDEV-5982 60# https://mariadb.atlassian.net/browse/MDEV-5982
@@ -114,39 +126,29 @@ do_install() {
114 126
115 install -d ${D}/${sysconfdir}/init.d 127 install -d ${D}/${sysconfdir}/init.d
116 install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/ 128 install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/
129 install -m 0755 ${WORKDIR}/install_db ${D}/${sysconfdir}/init.d/
117 mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld 130 mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld
118 131
119 install -d ${D}${systemd_unitdir}/system 132 install -d ${D}${systemd_unitdir}/system
120 install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system 133 install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system
121 sed -i -e 's,@BINDIR@,${bindir},g' -e 's,@PREFIX@,${prefix},g' ${D}${systemd_unitdir}/system/mysqld.service 134 install -m 0644 ${WORKDIR}/install_db.service ${D}${systemd_unitdir}/system
135 sed -i -e 's,@BINDIR@,${bindir},g' -e 's,@PREFIX@,${prefix},g' ${D}${systemd_unitdir}/system/mysqld.service \
136 ${D}${systemd_unitdir}/system/install_db.service
122 137
123 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then 138 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
124 install -d ${D}${sysconfdir}/tmpfiles.d 139 install -d ${D}${sysconfdir}/tmpfiles.d
125 echo "f /var/log/mysqld.err 0640 mysql mysql -" \ 140 echo "f /var/log/mysqld.err 0640 mysql mysql -" \
126 > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf 141 > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf
127 fi 142 fi
128} 143 install -d ${D}${bindir}
129 144 install -m 755 ${WORKDIR}/mysql-systemd-start ${D}${bindir}
130pkg_postinst_${PN}-server () {
131 if [ "x$D" != "x" ]; then
132 exit 1
133 fi
134
135 #Install the database
136 test -d /usr/bin || mkdir -p /usr/bin
137 test -e /usr/bin/hostname || ln -s /bin/hostname /usr/bin/hostname
138 mkdir /var/lib/mysql
139 chown mysql.mysql /var/lib/mysql
140
141 mysql_install_db --basedir=${prefix} --user=mysql
142 145
143 [ -x /sbin/restorecon ] && /sbin/restorecon -RF /var/lib/mysql
144} 146}
145 147
146PACKAGES = "${PN}-dbg ${PN} \ 148PACKAGES = "${PN}-dbg ${PN} \
147 libmysqlclient-r libmysqlclient-r-dev libmysqlclient-r-staticdev libmysqlclient-r-dbg \ 149 libmysqlclient-r libmysqlclient-r-dev libmysqlclient-r-staticdev libmysqlclient-r-dbg \
148 libmysqlclient libmysqlclient-dev libmysqlclient-staticdev libmysqlclient-dbg \ 150 libmysqlclient libmysqlclient-dev libmysqlclient-staticdev libmysqlclient-dbg \
149 libmysqld libmysqld-dev ${PN}-client ${PN}-server ${PN}-leftovers" 151 libmysqld libmysqld-dev ${PN}-client ${PN}-server ${PN}-setupdb ${PN}-leftovers"
150CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf" 152CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf"
151CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf" 153CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf"
152CONFFILES_libmysqlclient += "${sysconfdir}/my.cnf.d/client.cnf" 154CONFFILES_libmysqlclient += "${sysconfdir}/my.cnf.d/client.cnf"
@@ -236,6 +238,7 @@ FILES_${PN}-server = "\
236 ${bindir}/mysql_install_db \ 238 ${bindir}/mysql_install_db \
237 ${bindir}/mysql_secure_installation \ 239 ${bindir}/mysql_secure_installation \
238 ${bindir}/mysql_setpermission \ 240 ${bindir}/mysql_setpermission \
241 ${bindir}/mysql-systemd-start \
239 ${bindir}/mysql_tzinfo_to_sql \ 242 ${bindir}/mysql_tzinfo_to_sql \
240 ${bindir}/mysql_upgrade \ 243 ${bindir}/mysql_upgrade \
241 ${bindir}/mysql_plugin \ 244 ${bindir}/mysql_plugin \
@@ -268,7 +271,7 @@ FILES_${PN}-server = "\
268 ${libdir}/plugin/*.so \ 271 ${libdir}/plugin/*.so \
269 ${datadir}/mysql/ \ 272 ${datadir}/mysql/ \
270 ${localstatedir}/mysql/ \ 273 ${localstatedir}/mysql/ \
271 ${sysconfdir}/init.d \ 274 ${sysconfdir}/init.d/mysqld \
272 ${sysconfdir}/my.cnf \ 275 ${sysconfdir}/my.cnf \
273 ${sysconfdir}/my.cnf.d/server.cnf \ 276 ${sysconfdir}/my.cnf.d/server.cnf \
274 ${sysconfdir}/tmpfiles.d" 277 ${sysconfdir}/tmpfiles.d"
diff --git a/meta-oe/recipes-support/mysql/mariadb/install_db b/meta-oe/recipes-support/mysql/mariadb/install_db
new file mode 100755
index 000000000..512a7da7e
--- /dev/null
+++ b/meta-oe/recipes-support/mysql/mariadb/install_db
@@ -0,0 +1,13 @@
1#! /bin/sh
2case "$1" in
3 start)
4 echo "Starting to install database for mariadb"
5 /usr/bin/mysql-systemd-start pre
6 echo "done."
7 ;;
8 *)
9 echo "Usage: /etc/init.d/install_db start"
10 exit 1
11esac
12
13exit 0
diff --git a/meta-oe/recipes-support/mysql/mariadb/install_db.service b/meta-oe/recipes-support/mysql/mariadb/install_db.service
new file mode 100644
index 000000000..c8369f569
--- /dev/null
+++ b/meta-oe/recipes-support/mysql/mariadb/install_db.service
@@ -0,0 +1,17 @@
1#
2# Simple install MySQL database service file
3# It shoulb be done before mysqld.service
4
5[Unit]
6Description=Install MySQL Community Server Database
7After=network.target
8After=syslog.target
9Before=mysqld.service
10
11[Install]
12WantedBy=multi-user.target
13
14[Service]
15Type=oneshot
16ExecStart=@BINDIR@/mysql-systemd-start pre
17
diff --git a/meta-oe/recipes-support/mysql/mariadb/my.cnf b/meta-oe/recipes-support/mysql/mariadb/my.cnf
index 28d389922..dc4c172e5 100644
--- a/meta-oe/recipes-support/mysql/mariadb/my.cnf
+++ b/meta-oe/recipes-support/mysql/mariadb/my.cnf
@@ -4,7 +4,6 @@ port = 3306
4socket = /var/lib/mysql/mysql.sock 4socket = /var/lib/mysql/mysql.sock
5 5
6[mysqld_safe] 6[mysqld_safe]
7err-log = /var/log/mysql.err
8 7
9[mysqld] 8[mysqld]
10user = mysql 9user = mysql
diff --git a/meta-oe/recipes-support/mysql/mariadb/mysql-systemd-start b/meta-oe/recipes-support/mysql/mariadb/mysql-systemd-start
new file mode 100644
index 000000000..189c02021
--- /dev/null
+++ b/meta-oe/recipes-support/mysql/mariadb/mysql-systemd-start
@@ -0,0 +1,66 @@
1#! /bin/sh
2#
3# Needed argument: pre | post
4#
5# pre mode : try to run mysql_install_db and fix perms and SELinux contexts
6# post mode : ping server until answer is received
7#
8
9get_option () {
10 local section=$1
11 local option=$2
12 local default=$3
13 ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
14 [ -z $ret ] && ret=$default
15 echo $ret
16}
17
18install_db () {
19 # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)
20 datadir=$(get_option mysqld datadir "/var/lib/mysql")
21
22 # Restore log, dir, perms and SELinux contexts
23 [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1
24 log=/var/log/mysqld.log
25 [ -e $log ] || touch $log
26 chmod 0640 $log
27 chown mysql:mysql $log || exit 1
28 if [ -x /usr/sbin/restorecon ]; then
29 /usr/sbin/restorecon "$datadir"
30 /usr/sbin/restorecon $log
31 fi
32
33 # If special mysql dir is in place, skip db install
34 [ -d "$datadir/mysql" ] && exit 0
35
36 # Create initial db
37 /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql
38 exit 0
39}
40
41pinger () {
42 # Wait for ping to answer to signal startup completed,
43 # might take a while in case of e.g. crash recovery
44 # MySQL systemd service will timeout script if no answer
45 datadir=$(get_option mysqld datadir "/var/lib/mysql")
46 socket=$(get_option mysqld socket "$datadir/mysql.sock")
47 case $socket in
48 /*) adminsocket="$socket" ;;
49 *) adminsocket="$datadir/$socket" ;;
50 esac
51
52 while /bin/true ; do
53 sleep 1
54 mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping >/dev/null 2>&1 && break
55 done
56 exit 0
57}
58
59# main
60case $1 in
61 "pre") install_db ;;
62 "post") pinger ;;
63esac
64
65exit 0
66
diff --git a/meta-oe/recipes-support/mysql/mariadb/mysqld.service b/meta-oe/recipes-support/mysql/mariadb/mysqld.service
index 757d0386c..d88361703 100644
--- a/meta-oe/recipes-support/mysql/mariadb/mysqld.service
+++ b/meta-oe/recipes-support/mysql/mariadb/mysqld.service
@@ -8,7 +8,16 @@ PIDFile=/var/lib/mysql/mysqld.pid
8Type=simple 8Type=simple
9User=mysql 9User=mysql
10Group=mysql 10Group=mysql
11
12# Execute post scripts as root
13PermissionsStartOnly=true
14
15# Start main service
11ExecStart=@BINDIR@/mysqld_safe --basedir=@PREFIX@ 16ExecStart=@BINDIR@/mysqld_safe --basedir=@PREFIX@
17
18# Don't signal startup success before a ping works
19ExecStartPost=@BINDIR@/mysql-systemd-start post
20
12TimeoutSec=300 21TimeoutSec=300
13PrivateTmp=true 22PrivateTmp=true
14 23