From 6f4d0dbfbc7d5ab8c5781379884f41d30cb6db25 Mon Sep 17 00:00:00 2001 From: Yi Zhao Date: Fri, 22 May 2020 10:54:49 +0800 Subject: apache2: create log/run directory via pkg_postinst The commit e789c3837ca8d65abb4bac29dc2e5c595c8ce05b tries to create log/run directory in initscript/systemd unit file. This is not a correct method. We should create them in pkg_postinst. Signed-off-by: Yi Zhao Signed-off-by: Khem Raj --- meta-webserver/recipes-httpd/apache2/apache2_2.4.43.bb | 18 ++++++++++++++++++ .../recipes-httpd/apache2/files/apache2-volatile.conf | 2 ++ .../recipes-httpd/apache2/files/apache2.service | 4 ---- meta-webserver/recipes-httpd/apache2/files/init | 5 ----- .../recipes-httpd/apache2/files/volatiles.04_apache2 | 3 +++ 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 meta-webserver/recipes-httpd/apache2/files/apache2-volatile.conf create mode 100644 meta-webserver/recipes-httpd/apache2/files/volatiles.04_apache2 (limited to 'meta-webserver') diff --git a/meta-webserver/recipes-httpd/apache2/apache2_2.4.43.bb b/meta-webserver/recipes-httpd/apache2/apache2_2.4.43.bb index 9b80bbff67..a7083d80e9 100644 --- a/meta-webserver/recipes-httpd/apache2/apache2_2.4.43.bb +++ b/meta-webserver/recipes-httpd/apache2/apache2_2.4.43.bb @@ -20,7 +20,9 @@ SRC_URI = "${APACHE_MIRROR}/httpd/httpd-${PV}.tar.bz2 \ SRC_URI_append_class-target = " \ file://0008-apache2-do-not-use-relative-path-for-gen_test_char.patch \ file://init \ + file://apache2-volatile.conf \ file://apache2.service \ + file://volatiles.04_apache2 \ " LIC_FILES_CHKSUM = "file://LICENSE;md5=bddeddfac80b2c9a882241d008bb41c3" @@ -126,10 +128,16 @@ do_install_append_class-target() { -e 's,".*/configure","configure",g' ${D}${datadir}/apache2/build/config.nice if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${sysconfdir}/tmpfiles.d/ + install -m 0644 ${WORKDIR}/apache2-volatile.conf ${D}${sysconfdir}/tmpfiles.d/ + install -d ${D}${systemd_unitdir}/system install -m 0644 ${WORKDIR}/apache2.service ${D}${systemd_unitdir}/system sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/apache2.service sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' ${D}${systemd_unitdir}/system/apache2.service + elif ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then + install -d ${D}${sysconfdir}/default/volatiles + install -m 0644 ${WORKDIR}/volatiles.04_apache2 ${D}${sysconfdir}/default/volatiles/04_apache2 fi rm -rf ${D}${localstatedir} ${D}${sbindir}/envvars* @@ -206,3 +214,13 @@ RDEPENDS_${PN}-scripts += "perl ${PN}" RDEPENDS_${PN}-dev = "perl" BBCLASSEXTEND = "native" + +pkg_postinst_${PN}() { + if [ -z "$D" ]; then + if type systemd-tmpfiles >/dev/null; then + systemd-tmpfiles --create + elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then + ${sysconfdir}/init.d/populate-volatile.sh update + fi + fi +} diff --git a/meta-webserver/recipes-httpd/apache2/files/apache2-volatile.conf b/meta-webserver/recipes-httpd/apache2/files/apache2-volatile.conf new file mode 100644 index 0000000000..ff2c587046 --- /dev/null +++ b/meta-webserver/recipes-httpd/apache2/files/apache2-volatile.conf @@ -0,0 +1,2 @@ +d /var/run/apache2 0755 root root - +d /var/log/apache2 0755 root root - diff --git a/meta-webserver/recipes-httpd/apache2/files/apache2.service b/meta-webserver/recipes-httpd/apache2/files/apache2.service index 25d43acf8e..9b5548c761 100644 --- a/meta-webserver/recipes-httpd/apache2/files/apache2.service +++ b/meta-webserver/recipes-httpd/apache2/files/apache2.service @@ -5,10 +5,6 @@ After=network.target remote-fs.target nss-lookup.target [Service] Type=simple Environment=LANG=C -ExecStartPre=mkdir -p /var/log/apache2 -ExecStartPre=mkdir -p /var/run/apache2 -ExecStartPre=chmod -R 0755 /var/log/apache2 -ExecStartPre=chmod -R 0755 /var/run/apache2 ExecStart=@SBINDIR@/httpd -DFOREGROUND -D SSL -D PHP5 -k start ExecStop=@BASE_BINDIR@/kill -WINCH ${MAINPID} KillSignal=SIGCONT diff --git a/meta-webserver/recipes-httpd/apache2/files/init b/meta-webserver/recipes-httpd/apache2/files/init index 80a7ebfcb2..758d133b9e 100644 --- a/meta-webserver/recipes-httpd/apache2/files/init +++ b/meta-webserver/recipes-httpd/apache2/files/init @@ -97,11 +97,6 @@ do_start() return 1 fi - mkdir -p /var/log/apache2 - chmod -R 0755 /var/log/apache2 - mkdir -p /var/run/apache2 - chmod -R 0755 /var/run/apache2 - if apache_conftest ; then $APACHECTL start apache_wait_start $? diff --git a/meta-webserver/recipes-httpd/apache2/files/volatiles.04_apache2 b/meta-webserver/recipes-httpd/apache2/files/volatiles.04_apache2 new file mode 100644 index 0000000000..922075b1bd --- /dev/null +++ b/meta-webserver/recipes-httpd/apache2/files/volatiles.04_apache2 @@ -0,0 +1,3 @@ +# +d root root 0755 /var/run/apache2 none +d root root 0755 /var/log/apache2 none -- cgit 1.2.3-korg