clamav 0.84: Handle the /var directories correctly by making use of the
authorJamie Lenehan <lenehan@twibble.org>
Thu, 5 Oct 2006 06:33:31 +0000 (06:33 +0000)
committerJamie Lenehan <lenehan@twibble.org>
Thu, 5 Oct 2006 06:33:31 +0000 (06:33 +0000)
volatiles system. Previously these packages were broken after a reboot if
/var was on tmpfs due to missing directories and files. Note that the
updated virus definitions are stored in /var so they will be lost after a
reboot (but immediately re-downloaded) if using var on tmpfs.

packages/clamav/clamav_0.88.4.bb
packages/clamav/files/volatiles.02_clamav-data [new file with mode: 0644]
packages/clamav/files/volatiles.03_clamav-daemon [new file with mode: 0644]
packages/clamav/files/volatiles.03_clamav-freshclam [new file with mode: 0644]

index 46322bd..fa426b6 100644 (file)
@@ -16,7 +16,7 @@ RDEPENDS_${PN} = "${PN}-data"
 RDEPENDS_${PN}-daemon = "${PN}-data"
 RRECOMMENDS_${PN} = "${PN}-freshclam"
 RRECOMMENDS_${PN}-daemon = "${PN}-freshclam"
-PR = "r2"
+PR = "r3"
 
 SRC_URI = "${SOURCEFORGE_MIRROR}/clamav/clamav-${PV}.tar.gz \
           file://cross-compile-fix.patch;patch=1 \
@@ -25,7 +25,10 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/clamav/clamav-${PV}.tar.gz \
           file://clamav-freshclam.init \
           file://clamav-daemon.default \
           file://clamd.conf \
-          file://freshclam.conf"
+          file://freshclam.conf \
+          file://volatiles.02_clamav-data \
+          file://volatiles.03_clamav-daemon \
+          file://volatiles.03_clamav-freshclam"
 
 inherit autotools update-rc.d binconfig
 
@@ -35,22 +38,36 @@ EXTRA_OECONF = "--disable-clamav \
                 --with-dbdir=${localstatedir}/lib/clamav"
 
 do_install_append() {
-        install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d \
-                           ${D}${docdir}/clamav
+        install -m 0755 -d ${D}${sysconfdir}/default/volatiles \
+                           ${D}${sysconfdir}/init.d ${D}${docdir}/clamav
+
         # Save the installed clamd.conf in the doc dir and then install our new one
         install -m 0755 ${D}${sysconfdir}/clamd.conf ${D}${docdir}/clamav/clamd.conf.example
         install -m 0755 ${WORKDIR}/clamd.conf ${D}${sysconfdir}/clamd.conf
+
         # Save the installed freshclam.conf in the doc dir and then install our new one
         install -m 0755 ${D}${sysconfdir}/freshclam.conf ${D}${docdir}/clamav/freshclam.conf.example
+
         # Install our config files and init scripts
         install -m 0755 ${WORKDIR}/freshclam.conf ${D}${sysconfdir}/freshclam.conf
         install -m 0755 ${WORKDIR}/clamav-daemon.default ${D}${sysconfdir}/default/clamav-daemon
         install -m 0755 ${WORKDIR}/clamav-daemon.init ${D}${sysconfdir}/init.d/clamav-daemon
         install -m 0755 ${WORKDIR}/clamav-freshclam.init ${D}${sysconfdir}/init.d/clamav-freshclam
+
+        # We need some /var directories
+        for i in 02_clamav-data 03_clamav-daemon 03_clamav-freshclam; do
+          install -m 0644 ${WORKDIR}/volatiles.$i ${D}${sysconfdir}/default/volatiles/$i
+        done
+
+        # Move the clamav data to a non-volatile location, we'll symlink back
+        # If freshclam is running it'll break the link to this static data
+        # once it has succesfully downloaded an update
+        install -m 0755 -d ${D}${libdir}
+        mv ${D}${localstatedir}/lib/clamav ${D}${libdir}
 }
 do_stage () {
-       oe_libinstall -a -so libclamav ${STAGING_LIBDIR}
-       install -m 0644 libclamav/clamav.h ${STAGING_INCDIR}
+        oe_libinstall -a -so libclamav ${STAGING_LIBDIR}
+        install -m 0644 libclamav/clamav.h ${STAGING_INCDIR}
 }
 
 PACKAGES += "${PN}-freshclam ${PN}-daemon ${PN}-data ${PN}-lib"
@@ -59,13 +76,16 @@ FILES_${PN} = "${bindir}/clamscan ${bindir}/sigtool ${bindir}/clamdscan"
 FILES_${PN}-lib = "${libdir}/libclamav.so.*"
 FILES_${PN}-freshclam = "${bindir}/freshclam \
                          ${sysconfdir}/freshclam.conf \
-                         ${sysconfdir}/init.d/clamav-freshclam"
+                         ${sysconfdir}/init.d/clamav-freshclam \
+                         ${sysconfdir}/default/volatiles/03_clamav-freshclam"
 FILES_${PN}-daemon = "${sysconfdir}/clamd.conf \
                       ${sbindir}/clamd \
                       ${sysconfdir}/init.d/clamav-daemon \
-                      ${sysconfdir}/default/clamav-daemon"
-FILES_${PN}-data = "${localstatedir}/lib/clamav/main.cvd \
-                    ${localstatedir}/lib/clamav/daily.cvd"
+                      ${sysconfdir}/default/clamav-daemon \
+                      ${sysconfdir}/default/volatiles/03_clamav-daemon"
+FILES_${PN}-data = "${libdir}/clamav/main.cvd \
+                    ${libdir}/clamav/daily.cvd \
+                    ${sysconfdir}/default/volatiles/02_clamav-data"
 FILES_${PN}-dev += "${bindir}/clamav-config"
 
 # Add clamav's user and groups
@@ -73,30 +93,25 @@ pkg_postinst_${PN}-freshclam () {
         grep -q clamav: /etc/group || addgroup clamav
         grep -q clamav: /etc/passwd || adduser --disabled-password --home=/var/lib/clamav/ \
                                                --ingroup clamav -g "ClamAV" clamav
+        /etc/init.d/populate-volatile.sh
 }
 pkg_postinst_${PN}-daemon () {
         grep -q clamav: /etc/group || addgroup clamav
         grep -q clamav: /etc/passwd || adduser --disabled-password --home=/var/lib/clamav/ \
                                                --ingroup clamav -g "ClamAV" clamav
+        /etc/init.d/populate-volatile.sh
 }
 pkg_postinst_${PN}-data () {
         grep -q clamav: /etc/group || addgroup clamav
         grep -q clamav: /etc/passwd || adduser --disabled-password --home=/var/lib/clamav/ \
                                                --ingroup clamav --no-create-home -g "ClamAV" clamav
-        chown clamav:clamav \
-            ${localstatedir}/lib/clamav \
-            ${localstatedir}/lib/clamav/main.cvd \
-            ${localstatedir}/lib/clamav/daily.cvd
+        /etc/init.d/populate-volatile.sh
 }
 
 # Indicate that the default files are configuration files
 CONFFILES_${PN}-daemon = "${sysconfdir}/clamd.conf \
                           ${sysconfdir}/default/clamav-daemon"
 CONFFILES_${PN}-freshclam = "${sysconfdir}/freshclam.conf"
-# Mark the database as conffiles so that newer data file won't replace
-# updates generated by freshclam
-CONFFILES_${PN}-data = "${localstatedir}/lib/clamav/main.cvd \
-                        ${localstatedir}/lib/clamav/daily.cvd"
 
 INITSCRIPT_PACKAGES = "${PN}-daemon ${PN}-freshclam"
 INITSCRIPT_NAME_${PN}-daemon = "clamav-daemon"
diff --git a/packages/clamav/files/volatiles.02_clamav-data b/packages/clamav/files/volatiles.02_clamav-data
new file mode 100644 (file)
index 0000000..e26c08a
--- /dev/null
@@ -0,0 +1,4 @@
+# <type> <owner> <group> <mode> <path> [<linksource>]
+d clamav clamav 0755 /var/lib/clamav
+l clamav clamav 0644 /var/lib/clamav/main.cvd /usr/lib/clamav/main.cvd
+l clamav clamav 0644 /var/lib/clamav/daily.cvd /usr/lib/clamav/daily.cvd
diff --git a/packages/clamav/files/volatiles.03_clamav-daemon b/packages/clamav/files/volatiles.03_clamav-daemon
new file mode 100644 (file)
index 0000000..aeac57a
--- /dev/null
@@ -0,0 +1,4 @@
+# <type> <owner> <group> <mode> <path> [<linksource>]
+d clamav clamav 0775 /var/log/clamav
+d clamav clamav 0755 /var/lib/clamav
+d clamav clamav 0755 /var/run/clamav
\ No newline at end of file
diff --git a/packages/clamav/files/volatiles.03_clamav-freshclam b/packages/clamav/files/volatiles.03_clamav-freshclam
new file mode 100644 (file)
index 0000000..3019ea3
--- /dev/null
@@ -0,0 +1,4 @@
+# <type> <owner> <group> <mode> <path> [<linksource>]
+d clamav clamav 0775 /var/log/clamav
+d clamav clamav 0755 /var/lib/clamav
+d clamav clamav 0755 /var/run/clamav