Patchwork [meta-oe,1/2] mariadb: add systemd unit file

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date Aug. 22, 2014, 2:37 a.m.
Message ID <1408675054-4549-1-git-send-email-Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/78789/
State Accepted, archived
Headers show

Comments

Qi.Chen@windriver.com - Aug. 22, 2014, 2:37 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

The service file mainly comes from Fedora20.

This patch also adds a configuration file under /etc/tmpfiles.d so
that mysqld could start correctly.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../recipes-support/mysql/mariadb/mysqld.service   |   15 +++++++++++++++
 meta-oe/recipes-support/mysql/mariadb_5.5.38.inc   |   19 +++++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/recipes-support/mysql/mariadb/mysqld.service
Khem Raj - Aug. 25, 2014, 5:25 a.m.
On 14-08-22 10:37:33, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> The service file mainly comes from Fedora20.
> 
> This patch also adds a configuration file under /etc/tmpfiles.d so
> that mysqld could start correctly.

the next patch for apache does the execdir replacement on install. Why
not here too ?
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  .../recipes-support/mysql/mariadb/mysqld.service   |   15 +++++++++++++++
>  meta-oe/recipes-support/mysql/mariadb_5.5.38.inc   |   19 +++++++++++++++++--
>  2 files changed, 32 insertions(+), 2 deletions(-)
>  create mode 100644 meta-oe/recipes-support/mysql/mariadb/mysqld.service
> 
> diff --git a/meta-oe/recipes-support/mysql/mariadb/mysqld.service b/meta-oe/recipes-support/mysql/mariadb/mysqld.service
> new file mode 100644
> index 0000000..698e52d
> --- /dev/null
> +++ b/meta-oe/recipes-support/mysql/mariadb/mysqld.service
> @@ -0,0 +1,15 @@
> +[Unit]
> +Description=MariaDB database server
> +After=syslog.target
> +After=network.target
> +
> +[Service]
> +Type=simple
> +User=mysql
> +Group=mysql
> +ExecStart=/usr/bin/mysqld_safe --basedir=/usr
> +TimeoutSec=300
> +PrivateTmp=true
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git a/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc b/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc
> index 8a73833..83f2a92 100644
> --- a/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc
> +++ b/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc
> @@ -9,6 +9,7 @@ SRC_URI = "http://mirror.stshosting.co.uk/mariadb/mariadb-${PV}/source/mariadb-$
>             file://remove-bad-path.patch \
>             file://fix-mysqlclient-r-version.patch \
>             file://my.cnf \
> +           file://mysqld.service \
>            "
>  
>  SRC_URI[md5sum] = "fa9ba00b084b95a45fab70860c412f10"
> @@ -18,7 +19,7 @@ S = "${WORKDIR}/mariadb-${PV}"
>  
>  BINCONFIG_GLOB = "mysql_config"
>  
> -inherit cmake gettext binconfig update-rc.d useradd
> +inherit cmake gettext binconfig update-rc.d useradd systemd
>  
>  INITSCRIPT_PACKAGES = "${PN}-server"
>  INITSCRIPT_NAME = "mysqld"
> @@ -28,6 +29,10 @@ USERADD_PACKAGES = "${PN}-server"
>  USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql"
>  GROUPADD_PARAM_${PN}-server = "--system mysql"
>  
> +SYSTEMD_PACKAGES = "mariadb-server"
> +SYSTEMD_SERVICE_mariadb-server = "mysqld.service"
> +SYSTEMD_AUTO_ENABLE_mariadb-server = "disable"
> +
>  EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'"
>  
>  python __anonymous() {
> @@ -112,6 +117,15 @@ do_install() {
>      install -d ${D}/${sysconfdir}/init.d
>      install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/
>      mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld
> +
> +    install -d ${D}${systemd_unitdir}/system
> +    install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system
> +
> +    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
> +	install -d ${D}${sysconfdir}/tmpfiles.d
> +	echo "f /var/log/mysqld.err 0640 mysql mysql -" \
> +            > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf
> +    fi
>  }
>  
>  pkg_postinst_${PN}-server () {
> @@ -247,7 +261,8 @@ FILES_${PN}-server = "\
>      ${datadir}/mysql/ \
>      ${localstatedir}/mysql/ \
>      ${sysconfdir}/init.d \
> -    ${sysconfdir}/my.cnf"
> +    ${sysconfdir}/my.cnf \
> +    ${sysconfdir}/tmpfiles.d"
>  
>  DESCRIPTION_${PN}-leftovers = "unpackaged and probably unneeded files for ${PN}"
>  FILES_${PN}-leftovers = "/"
> -- 
> 1.7.9.5
> 
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

Patch

diff --git a/meta-oe/recipes-support/mysql/mariadb/mysqld.service b/meta-oe/recipes-support/mysql/mariadb/mysqld.service
new file mode 100644
index 0000000..698e52d
--- /dev/null
+++ b/meta-oe/recipes-support/mysql/mariadb/mysqld.service
@@ -0,0 +1,15 @@ 
+[Unit]
+Description=MariaDB database server
+After=syslog.target
+After=network.target
+
+[Service]
+Type=simple
+User=mysql
+Group=mysql
+ExecStart=/usr/bin/mysqld_safe --basedir=/usr
+TimeoutSec=300
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc b/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc
index 8a73833..83f2a92 100644
--- a/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc
+++ b/meta-oe/recipes-support/mysql/mariadb_5.5.38.inc
@@ -9,6 +9,7 @@  SRC_URI = "http://mirror.stshosting.co.uk/mariadb/mariadb-${PV}/source/mariadb-$
            file://remove-bad-path.patch \
            file://fix-mysqlclient-r-version.patch \
            file://my.cnf \
+           file://mysqld.service \
           "
 
 SRC_URI[md5sum] = "fa9ba00b084b95a45fab70860c412f10"
@@ -18,7 +19,7 @@  S = "${WORKDIR}/mariadb-${PV}"
 
 BINCONFIG_GLOB = "mysql_config"
 
-inherit cmake gettext binconfig update-rc.d useradd
+inherit cmake gettext binconfig update-rc.d useradd systemd
 
 INITSCRIPT_PACKAGES = "${PN}-server"
 INITSCRIPT_NAME = "mysqld"
@@ -28,6 +29,10 @@  USERADD_PACKAGES = "${PN}-server"
 USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql"
 GROUPADD_PARAM_${PN}-server = "--system mysql"
 
+SYSTEMD_PACKAGES = "mariadb-server"
+SYSTEMD_SERVICE_mariadb-server = "mysqld.service"
+SYSTEMD_AUTO_ENABLE_mariadb-server = "disable"
+
 EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'"
 
 python __anonymous() {
@@ -112,6 +117,15 @@  do_install() {
     install -d ${D}/${sysconfdir}/init.d
     install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/
     mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld
+
+    install -d ${D}${systemd_unitdir}/system
+    install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system
+
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+	install -d ${D}${sysconfdir}/tmpfiles.d
+	echo "f /var/log/mysqld.err 0640 mysql mysql -" \
+            > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf
+    fi
 }
 
 pkg_postinst_${PN}-server () {
@@ -247,7 +261,8 @@  FILES_${PN}-server = "\
     ${datadir}/mysql/ \
     ${localstatedir}/mysql/ \
     ${sysconfdir}/init.d \
-    ${sysconfdir}/my.cnf"
+    ${sysconfdir}/my.cnf \
+    ${sysconfdir}/tmpfiles.d"
 
 DESCRIPTION_${PN}-leftovers = "unpackaged and probably unneeded files for ${PN}"
 FILES_${PN}-leftovers = "/"