Skip to contentSkip to conversation

hiawatha: Create /var/log /var/run at runtime

PATCH In review Khem Raj 2 participants 2 messages Nov 4, 2021

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 hiawatha: Create /var/log /var/run at runtime

Move WEBROOT to /use/share/www from /var/www
this paves the way to empty these dirs which
then can be mounted freely

---
 .../recipes-httpd/hiawatha/hiawatha_10.12.bb  | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
meta-webserver/recipes-httpd/hiawatha/hiawatha_10.12.bb +22 -1
index f66ec7d736..ff3c3bf659 100644
@@ -33,6 +33,7 @@ EXTRA_OECMAKE = " -DENABLE_IPV6=OFF \
                   -DCMAKE_INSTALL_SBINDIR=${sbindir} \
                   -DCMAKE_INSTALL_SYSCONFDIR=${sysconfdir} \
                   -DCMAKE_INSTALL_LIBDIR=${libdir} \
+                  -DWEBROOT_DIR=${datadir}/www/${BPN} \
                   -DCMAKE_INSTALL_FULL_LOCALSTATEDIR=${localstatedir}"
 
 do_install:append() {
@@ -50,7 +51,26 @@ do_install:append() {
         install -m 644 ${WORKDIR}/hiawatha.service ${D}/${systemd_unitdir}/system
     fi
 
-    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}" "${D}${localstatedir}/run"
+    # /var/log/hiawatha and /var/lib/hiawatha needs to be created in runtime.
+    # Use rmdir to catch if upstream stops creating these dirs, or adds
+    # something else in /var/log.
+    rmdir ${D}${localstatedir}/log/${BPN} ${D}${localstatedir}/log
+    rmdir ${D}${localstatedir}/lib/${BPN} ${D}${localstatedir}/lib
+    rmdir ${D}${localstatedir}/run
+    rmdir --ignore-fail-on-non-empty ${D}${localstatedir}
+
+    # Create /var/log/hiawatha at runtime.
+    if [ "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}" ]; then
+        install -d ${D}${nonarch_libdir}/tmpfiles.d
+        echo "d ${localstatedir}/log/${BPN} - - - -" > ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
+        echo "d ${localstatedir}/lib/${BPN} - - - -" >> ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
+    fi
+    if [ "${@bb.utils.filter('DISTRO_FEATURES', 'sysvinit', d)}" ]; then
+        install -d ${D}${sysconfdir}/default/volatiles
+        echo "d root root 0755 ${localstatedir}/log/${BPN} none" > ${D}${sysconfdir}/default/volatiles/99_${BPN}
+        echo "d root root 0755 ${localstatedir}/lib/${BPN} none" >> ${D}${sysconfdir}/default/volatiles/99_${BPN}
+    fi
+
 }
 
 CONFFILES:${PN} = " \
@@ -61,4 +81,5 @@ CONFFILES:${PN} = " \
     ${sysconfdir}/hiawatha/php-fcgi.conf \
 "
 
+FILES:${PN} += "${datadir}/www/${BPN} ${nonarch_libdir}/tmpfiles.d"
 FILES:${PN}-dev = "${libdir}/hiawatha/*${SOLIBSDEV}"
Signature · 1 line
2.33.1
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Khem Raj
Sent: den 4 november 2021 07:30
To: [email protected]
Cc: Khem Raj <[email protected]>
Subject: [oe] [meta-webserver][PATCH] hiawatha: Create /var/log /var/run at runtime

Move WEBROOT to /use/share/www from /var/www
this paves the way to empty these dirs which
then can be mounted freely

It is typically only /var/run and /var/log that are volatile so there should not be any reason to move /var/www and /var/lib.

//Peter

Quoted 54 lines
---
 .../recipes-httpd/hiawatha/hiawatha_10.12.bb  | 23 ++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
meta-webserver/recipes-httpd/hiawatha/hiawatha_10.12.bb +22 -2
index f66ec7d736..ff3c3bf659 100644
@@ -33,6 +33,7 @@ EXTRA_OECMAKE = " -DENABLE_IPV6=OFF \
                   -DCMAKE_INSTALL_SBINDIR=${sbindir} \
                   -DCMAKE_INSTALL_SYSCONFDIR=${sysconfdir} \
                   -DCMAKE_INSTALL_LIBDIR=${libdir} \
+                  -DWEBROOT_DIR=${datadir}/www/${BPN} \
                   -DCMAKE_INSTALL_FULL_LOCALSTATEDIR=${localstatedir}"
 
 do_install:append() {
@@ -50,7 +51,26 @@ do_install:append() {
         install -m 644 ${WORKDIR}/hiawatha.service ${D}/${systemd_unitdir}/system
     fi
 
-    rmdir --ignore-fail-on-non-empty "${D}${localstatedir}" "${D}${localstatedir}/run"
+    # /var/log/hiawatha and /var/lib/hiawatha needs to be created in runtime.
+    # Use rmdir to catch if upstream stops creating these dirs, or adds
+    # something else in /var/log.
+    rmdir ${D}${localstatedir}/log/${BPN} ${D}${localstatedir}/log
+    rmdir ${D}${localstatedir}/lib/${BPN} ${D}${localstatedir}/lib
+    rmdir ${D}${localstatedir}/run
+    rmdir --ignore-fail-on-non-empty ${D}${localstatedir}
+
+    # Create /var/log/hiawatha at runtime.
+    if [ "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}" ]; then
+        install -d ${D}${nonarch_libdir}/tmpfiles.d
+        echo "d ${localstatedir}/log/${BPN} - - - -" > ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
+        echo "d ${localstatedir}/lib/${BPN} - - - -" >> ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
+    fi
+    if [ "${@bb.utils.filter('DISTRO_FEATURES', 'sysvinit', d)}" ]; then
+        install -d ${D}${sysconfdir}/default/volatiles
+        echo "d root root 0755 ${localstatedir}/log/${BPN} none" > ${D}${sysconfdir}/default/volatiles/99_${BPN}
+        echo "d root root 0755 ${localstatedir}/lib/${BPN} none" >> ${D}${sysconfdir}/default/volatiles/99_${BPN}
+    fi
+
 }
 
 CONFFILES:${PN} = " \
@@ -61,4 +81,5 @@ CONFFILES:${PN} = " \
     ${sysconfdir}/hiawatha/php-fcgi.conf \
 "
 
+FILES:${PN} += "${datadir}/www/${BPN} ${nonarch_libdir}/tmpfiles.d"
 FILES:${PN}-dev = "${libdir}/hiawatha/*${SOLIBSDEV}"
--

2.33.1