Skip to contentSkip to conversation

iptraf-ng: Create /var/log and /var/lib subdirs at runtime

PATCH New Khem Raj 1 participant 2 messages Nov 4, 2021

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 iptraf-ng: Create /var/log and /var/lib subdirs at runtime

This ensures that /var can be empty during build and populated only at runtime

---
 .../recipes-devtools/iptraf/iptraf-ng/iptraf-ng-tmpfiles.conf   | 2 ++
 meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb              | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)
meta-oe/recipes-devtools/iptraf/iptraf-ng/iptraf-ng-tmpfiles.conf +2 -0
index 1c79f0d8c3..ebb9d67800 100644
@@ -1 +1,3 @@
 d /run/iptraf-ng 0755 root root -
+d /var/log/iptraf-ng 0755 root root -
+d /var/lib/iptraf-ng 0755 root root -
meta-oe/recipes-devtools/iptraf/iptraf-ng_1.2.1.bb +0 -1
index 115bbf082b..27a0f4441d 100644
@@ -41,7 +41,6 @@ do_compile() {
 
 do_install() {
     oe_runmake DESTDIR=${D} install
-    install -d -m 0755 ${D}${localstatedir}/{log,lib}/iptraf-ng
     install -D -m 0644 -p ${S}/iptraf-ng-logrotate.conf ${D}${sysconfdir}/logrotate.d/iptraf-ng
     install -Dm 0644 ${WORKDIR}/iptraf-ng-tmpfiles.conf ${D}${libdir}/tmpfiles.d/iptraf-ng-tmpfiles.conf
 }
Signature · 1 line
2.33.1
author
#1 lore raw

PATCH 2/2 monkey: Move content away from /var

/var is r/w sometimes populated at runtime as it can be mounted from a different partition, therefore its better to keep it empty and only populate it during runtime.

---
 .../recipes-httpd/monkey/monkey_1.6.9.bb      | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
meta-webserver/recipes-httpd/monkey/monkey_1.6.9.bb +14 -6
index 1386770c8a..bd09bcfa64 100644
@@ -17,7 +17,8 @@ UPSTREAM_CHECK_URI = "https://github.com/monkey/monkey/releases"
 UPSTREAM_CHECK_REGEX = "v(?P<pver>\d+(\.\d+)+).tar.gz"
 
 EXTRA_OECMAKE = "-DINSTALL_LOGDIR=${localstatedir}/log/monkey/ \
-                 -DPID_FILE=${localstatedir}/run/monkey.pid \
+                 -DINSTALL_WEBROOTDIR=${datadir}/www/monkey \
+                 -DPID_FILE=/run/monkey.pid \
                  -DINSTALL_SYSCONFDIR=${sysconfdir}/monkey/ \
                  -DWITH_PLUGINS=* \
                  -DWITHOUT_PLUGINS=mbedtls \
@@ -38,10 +39,18 @@ inherit cmake pkgconfig update-rc.d systemd
 OECMAKE_GENERATOR = "Unix Makefiles"
 
 do_install:append() {
-    rm -rf ${D}/run
-    rm -rf ${D}${localstatedir}/run
+    rmdir ${D}${localstatedir}/log/${BPN} ${D}${localstatedir}/run ${D}${localstatedir}/log
+    rmdir --ignore-fail-on-non-empty ${D}${localstatedir}
     install -Dm 0755 ${WORKDIR}/monkey.init ${D}${sysconfdir}/init.d/monkey
-
+    # Create /var/log/monkey in runtime.
+    if [ "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}" ]; then
+        install -d ${D}${nonarch_libdir}/tmpfiles.d
+        echo "d ${localstatedir}/log/${BPN} 0755 ${BPN} ${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 ${BPN} ${BPN} 0755 ${localstatedir}/log/${BPN} none" > ${D}${sysconfdir}/default/volatiles/99_${BPN}
+    fi
     if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
         install -Dm 644 ${WORKDIR}/monkey.service ${D}/${systemd_unitdir}/system/monkey.service
     fi
@@ -56,8 +65,7 @@ PACKAGES += "${PN}-plugins"
 
 FILES:${PN}-plugins = "${libdir}/monkey-*.so"
 
-FILES:${PN} += "${localstatedir}/www/monkey/ /run"
-
+FILES:${PN} += "${nonarch_libdir}/tmpfiles.d ${datadir}/www"
 
 CONFFILES:${PN} = "${sysconfdir}/monkey/monkey.conf \
                    ${sysconfdir}/monkey/sites/default \
Signature · 1 line
2.33.1