diff options
Diffstat (limited to 'meta-oe/recipes-support')
-rw-r--r-- | meta-oe/recipes-support/mysql/mariadb.inc | 51 | ||||
-rwxr-xr-x | meta-oe/recipes-support/mysql/mariadb/install_db | 13 | ||||
-rw-r--r-- | meta-oe/recipes-support/mysql/mariadb/install_db.service | 17 | ||||
-rw-r--r-- | meta-oe/recipes-support/mysql/mariadb/my.cnf | 1 | ||||
-rw-r--r-- | meta-oe/recipes-support/mysql/mariadb/mysql-systemd-start | 66 | ||||
-rw-r--r-- | meta-oe/recipes-support/mysql/mariadb/mysqld.service | 9 |
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 | ||
24 | inherit cmake gettext binconfig update-rc.d useradd systemd | 27 | inherit cmake gettext binconfig update-rc.d useradd systemd |
25 | 28 | ||
26 | INITSCRIPT_PACKAGES = "${PN}-server" | 29 | INITSCRIPT_PACKAGES = "${PN}-server ${PN}-setupdb" |
27 | INITSCRIPT_NAME = "mysqld" | 30 | INITSCRIPT_NAME_${PN}-server = "mysqld" |
28 | INITSCRIPT_PARAMS = "start 45 5 . stop 45 0 6 1 ." | 31 | INITSCRIPT_PARAMS_${PN}-server ?= "start 45 5 . stop 45 0 6 1 ." |
29 | 32 | ||
30 | USERADD_PACKAGES = "${PN}-server" | 33 | USERADD_PACKAGES = "${PN}-server" |
31 | USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql" | 34 | USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql" |
32 | GROUPADD_PARAM_${PN}-server = "--system mysql" | 35 | GROUPADD_PARAM_${PN}-server = "--system mysql" |
33 | 36 | ||
34 | SYSTEMD_PACKAGES = "${PN}-server" | 37 | INITSCRIPT_NAME_${PN}-setupdb = "install_db" |
38 | INITSCRIPT_PARAMS_${PN}-setupdb ?= "defaults 44 44" | ||
39 | |||
40 | SYSTEMD_PACKAGES = "${PN}-server ${PN}-setupdb" | ||
35 | SYSTEMD_SERVICE_${PN}-server = "mysqld.service" | 41 | SYSTEMD_SERVICE_${PN}-server = "mysqld.service" |
36 | SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" | 42 | SYSTEMD_AUTO_ENABLE_${PN}-server ?= "disable" |
43 | |||
44 | SYSTEMD_SERVICE_${PN}-setupdb = "install_db.service" | ||
45 | SYSTEMD_AUTO_ENABLE_${PN}-setupdb ?= "enable" | ||
46 | ALLOW_EMPTY_${PN}-setupdb ?= "1" | ||
47 | FILES_${PN}-setupdb = "${sysconfdir}/init.d/install_db" | ||
37 | 48 | ||
38 | EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'" | 49 | EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'" |
39 | 50 | ||
40 | PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" | 51 | PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)} setupdb" |
41 | PACKAGECONFIG_class-native = "" | 52 | PACKAGECONFIG_class-native = "" |
42 | PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam" | 53 | PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam" |
43 | PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind" | 54 | PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind" |
44 | PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit" | 55 | PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit" |
45 | PACKAGECONFIG[krb5] = ", ,krb5" | 56 | PACKAGECONFIG[krb5] = ", ,krb5" |
57 | PACKAGECONFIG[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} | |
130 | pkg_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 | ||
146 | PACKAGES = "${PN}-dbg ${PN} \ | 148 | PACKAGES = "${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" |
150 | CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf" | 152 | CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf" |
151 | CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf" | 153 | CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf" |
152 | CONFFILES_libmysqlclient += "${sysconfdir}/my.cnf.d/client.cnf" | 154 | CONFFILES_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 | ||
2 | case "$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 | ||
11 | esac | ||
12 | |||
13 | exit 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] | ||
6 | Description=Install MySQL Community Server Database | ||
7 | After=network.target | ||
8 | After=syslog.target | ||
9 | Before=mysqld.service | ||
10 | |||
11 | [Install] | ||
12 | WantedBy=multi-user.target | ||
13 | |||
14 | [Service] | ||
15 | Type=oneshot | ||
16 | ExecStart=@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 | |||
4 | socket = /var/lib/mysql/mysql.sock | 4 | socket = /var/lib/mysql/mysql.sock |
5 | 5 | ||
6 | [mysqld_safe] | 6 | [mysqld_safe] |
7 | err-log = /var/log/mysql.err | ||
8 | 7 | ||
9 | [mysqld] | 8 | [mysqld] |
10 | user = mysql | 9 | user = 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 | |||
9 | get_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 | |||
18 | install_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 | |||
41 | pinger () { | ||
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 | ||
60 | case $1 in | ||
61 | "pre") install_db ;; | ||
62 | "post") pinger ;; | ||
63 | esac | ||
64 | |||
65 | exit 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 | |||
8 | Type=simple | 8 | Type=simple |
9 | User=mysql | 9 | User=mysql |
10 | Group=mysql | 10 | Group=mysql |
11 | |||
12 | # Execute post scripts as root | ||
13 | PermissionsStartOnly=true | ||
14 | |||
15 | # Start main service | ||
11 | ExecStart=@BINDIR@/mysqld_safe --basedir=@PREFIX@ | 16 | ExecStart=@BINDIR@/mysqld_safe --basedir=@PREFIX@ |
17 | |||
18 | # Don't signal startup success before a ping works | ||
19 | ExecStartPost=@BINDIR@/mysql-systemd-start post | ||
20 | |||
12 | TimeoutSec=300 | 21 | TimeoutSec=300 |
13 | PrivateTmp=true | 22 | PrivateTmp=true |
14 | 23 | ||