Browse Source

finish packaging this

Ralf S. Engelschall 23 years ago
parent
commit
fc01138d67
2 changed files with 71 additions and 5 deletions
  1. 45 5
      clamav/clamav.spec
  2. 26 0
      clamav/rc.clamav

+ 45 - 5
clamav/clamav.spec

@@ -60,6 +60,7 @@ AutoReqProv:  no
     %setup -q
 
 %build
+    #   configure package
     CC="%{l_cc}" \
     CFLAGS="%{l_cflags -O}" \
     CPPFLAGS="%{l_cppflags}" \
@@ -67,21 +68,60 @@ AutoReqProv:  no
     ./configure \
         --prefix=%{l_prefix} \
         --sysconfdir=%{l_prefix}/etc/clamav \
-        --with-user=%{l_musr} \
-        --with-group=%{l_mgrp} \
+        --with-user=%{l_rusr} \
+        --with-group=%{l_rgrp} \
         --disable-clamav \
         --disable-clamuko \
         --disable-urandom \
-        --disable-pthreads \
         --disable-cr \
         --disable-shared
+
+    #   build package
     %{l_make} %{l_mflags -O}
 
 %install
     rm -rf $RPM_BUILD_ROOT
+
+    #   perform standard package installation
     %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
-    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
-    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
+
+    #   install default configuration
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/clamav
+    %{l_shtool} install -c -m 644 \
+        -e 's;^\(Example\);#\1;' \
+        -e 's;^#\(LogFile\).*;\1 %{l_prefix}/var/clamav/clamd.log;' \
+        -e 's;^#\(PidFile\).*;\1 %{l_prefix}/var/clamav/clamd.pid;' \
+        -e 's;^\(LocalSocket\).*;\1 %{l_prefix}/var/clamav/clamd.sock;' \
+        -e 's;^#\(DataDirectory\).*;\1 %{l_prefix}/share/clamav;' \
+        -e 's;^#\(User\).*;\1 %{l_rusr};' \
+        etc/clamav.conf \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/clamav/
+
+    #   install run-command script
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
+    %{l_shtool} install -c -m 755 \
+        -e 's;@l_prefix@;%{l_prefix};g' \
+        -e 's;@l_rusr@;%{l_rusr};g' \
+        -e 's;@l_rgrp@;%{l_rgrp};g' \
+        %{SOURCE rc.clamav} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
+
+    #   strip-down installation hierarchy
+    strip $RPM_BUILD_ROOT%{l_prefix}/bin/*  >/dev/null 2>&1 || true
+    strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/clamav-milter.1
+
+    #   create additional installation directory
+    %{l_shtool} mkdir -f -p -m 755 \
+        $RPM_BUILD_ROOT%{l_prefix}/var/clamav
+
+    #   determine installation files
+    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
+        %{l_files_std} \
+        '%config %{l_prefix}/etc/clamav/clamav.conf' \
+        '%attr(755,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/clamav' \
+        '%attr(755,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/clamav'
 
 %files -f files
 

+ 26 - 0
clamav/rc.clamav

@@ -0,0 +1,26 @@
+#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
+##
+##  rc.clamav -- Run-Commands
+##
+
+%config
+    clamav_enable="yes"
+
+%common
+    clamav_cfgfile="@l_prefix@/etc/clamav/clamav.conf"
+    clamav_pidfile="@l_prefix@/var/clamav/clamd.pid"
+
+%start -p 200 -u @l_rusr@
+    opServiceEnabled clamav || exit 0
+    @l_prefix@/sbin/clamd --config-file=$clamav_cfgfile
+    
+%stop -p 200 -u @l_rusr@
+    opServiceEnabled clamav || exit 0
+    if [ -f $clamav_pidfile ]; then
+        kill -TERM `cat $clamav_pidfile`
+    fi
+
+%daily -p 200 -u @l_rusr@
+    opServiceEnabled clamav || exit 0
+    @l_prefix@/bin/freshclam
+