clamav/clamd-gen

269 lines
6.6 KiB
Plaintext
Raw Normal View History

- build the package with '--disable-zlib-vcheck' because RH is unable to apply a fix for a 5 month old and solved security issue. Please fill your comments at https://bugzilla.redhat.com/beta/show_bug.cgi?id=131385 - added 'BuildRequires: bc' (should work without also, but ./configure gives out ugly warnings else) 0.81-0.fdr.1 - updated to 0.81 - do not ship the 'clamd.milter' daemon anymore; clamav-milter supports an internal mode now which is enabled by default - updated -milter %%description 0.80-0.fdr.2 - s!cron.d/clamav!cron.d/clamav-update! in the %%description of the -update subpackage (https://bugzilla.fedora.us/show_bug.cgi?id=1715#c39) 0.80-0.fdr.1 - updated to 0.80 - removed DMS, FreeBSD-HOWTO and localized docs as it is not shipped anymore - buildrequire 'curl-devel' - renamed clamav.conf to clamd.conf (upstream change) - updated -initoff patch 0.75.1-0.fdr.1 - updated to 0.75.1 - use %%configure, the problems with the architecture specification seem to have passed (probably because of an autoconf update) - set mode 0600 for the cron-script (required by vixie-cron) - made the cronjob a spambot and send mail about deactivated freshclam service to nearly everybody... (root, postmaster, webmaster) - other fixes in the notification cronjob 0.75-0.fdr.1 - updated to 0.75 0.74-0.fdr.2 - moved /usr/bin/clamav-config from main into -devel 0.74-0.fdr.1 - updated to 0.74 0.73-0.fdr.1 - updated to 0.73 - added pkgconfig file 0.72-0.fdr.3 - notify the user about a deactivated clamav-update service - added clamd-gen script which generates template spec-files for services using clamd - copied template configuration files to %pkgdatadir/template (needed for clamd-gen) - moved the clamd-wrapper from %_initrddir to %{pkgdatadir}; a symlink will be provided for compatibility reasons - conditionalized building of the -milter subpackage ('--without milter' switch) to enable builds on RH73 (bug #1715, comment #5/#7) 0.72-0.fdr.2 - removed 'BuildRequires: dietlibc'; it was a leftover from the pre-use-signal era (before 0.70) (bug #1716) 0.72-0.fdr.1 - updated to 0.72
2005-02-03 08:40:44 +00:00
#! /bin/bash
# Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
function showHelp()
{
echo \
$"Usage: clamd-gen --service=<SERVICE> --version=<VERSION> --release=<RELEASE>
--license=<LICENSE> --username=>USERNAME>
"
exit 0
}
function rpm.generatePreamble()
{
cat <<EOF
%{!?release_func:%define release_func() 0.fdr.%1}
# The name of the minit service
%define minitsvcdir %minitdir/services/%name
# The configuration file for the SysV initservice
%define conffile %_sysconfdir/clamd.d/%service.conf
# The directory, where the milter socket will be placed into; this
# socket will be named clamd.sock
%define rundir /var/run/clamd.%service
# The name of the logfile
%define logfile /var/log/clamd.%service
# The user under whose id, the clamd shall be running. This user must
# be able to read the files from the base-service and is usually
# created there.
%define username $USERNAME
# The packagename of the service
%define service $SERVICE
# The service name as used by the system's initscripts; usually this
# is %service
%define baseservice %service
%define __chkconfig /sbin/chkconfig
%define minitdir %_sysconfdir/minit
EOF
}
function rpm.generateHeader()
{
cat <<EOF
Summary: Clamav server for '%service'
Name: clamd.%service
Version: $VERSION
Release: %release_func $RELEASE
Epoch: 0
License: $LICENSE
Group: System Environment/Daemons
BuildRoot: %_tmppath/%name-%version-%release-root
BuildArch: noarch
Requires: init(%name)
Requires(pre): %service
Requires: clamav-server
BuildRequires: clamav-devel
%package sysv
Summary: SysV initscripts for a %service clamav-server
Group: System Environment/Daemons
Provides: init(%name) = sysv
Conflicts: init(%name) < sysv
Conflicts: init(%name) > sysv
Requires(post): %name = %epoch:%version-%release
Requires(post): diffutils mktemp %__chkconfig
Requires(preun): %__chkconfig
Requires(pre): %_initrddir
Requires(postun): %_initrddir
%package minit
Summary: minit initscripts for a %service clamav-server
Group: System Environment/Daemons
Provides: init(%name) = minit
Conflicts: init(%name) < minit
Conflicts: init(%name) > minit
Requires(post): %name = %epoch:%version-%release
Requires(post): diffutils mktemp
Requires(pre): minit-setup
Requires(postun): minit-setup
Requires(triggers): minit-tools
%description
Basic setup for a clamav server for '%service'.
%description sysv
Basic setup for a clamav server for '%service'.
This package contains initscripts for SysV based systems.
%description minit
Basic setup for a clamav server for '%service'.
This package contains initscripts for minit based systems.
EOF
}
function rpm.genBody()
{
cat <<"XEOFX"
%prep
%build
%install
rm -rf $RPM_BUILD_ROOT
%__install -d -m755 $RPM_BUILD_ROOT{%minitsvcdir,%_sbindir,%rundir,/var/log}
d=/usr/share/clamav/template
function subst
{
src=$d/$1
dst=$RPM_BUILD_ROOT$2
%__install -d -m755 $(dirname "$dst")
sed -e 's!^\(#?LogFile \).*!\1%logfile!g;
s!^#?\(LocalSocket \).*!\1%rundir/clamd.sock!g;
s!^#?\(PidFile \).*!\1%rundir/clamd.pid!g;
s!<SERVICE>!%service!g;
s!<USER>!%username!g;' "$src" >"$dst"
chmod --reference "$src" "$dst"
}
subst clamd.conf %conffile
subst clamd.logrotate %_sysconfdir/logrotate.d/clamd.%service
%if 0%{!?_without_sysv:1}
subst clamd.sysconfig %_sysconfdir/sysconfig/clamd.%service
subst clamd.init %_initrddir/clamd.%service
%endif
ln -s clamd $RPM_BUILD_ROOT%_sbindir/clamd.%service
touch $RPM_BUILD_ROOT%logfile
touch $RPM_BUILD_ROOT%rundir/clamd.sock
%if 0%{!?_without_minit:1}
ln -s %_sbindir/clamd.%service $RPM_BUILD_ROOT%minitsvcdir/run
touch $RPM_BUILD_ROOT%minitsvcdir/respawn
cat <<EOF >$RPM_BUILD_ROOT%minitsvcdir/params
-c
%conffile
EOF
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%triggerin minit -- %baseservice
minit-svc add services/clamd.%service services/%baseservice/
%triggerun minit -- %baseservice
test "$1" != 0 -a "$2" != 0 || \
minit-svc del services/clamd.%service services/%baseservice/
%post minit
d=$(mktemp /tmp/clamd.%service.XXXXXX)
sed -e 's!^#Foreground!Foreground!' "%conffile" >"$d"
grep -q '^Foreground' $d || echo 'Foreground' >>$d
cmp -s "$d" %conffile || cat "$d" >"%conffile"
rm -f "$d"
%post sysv
d=$(mktemp /tmp/clamd.%service.XXXXXX)
sed -e 's!^Foreground!#Foreground!' "%conffile" >"$d"
cmp -s "$d" %conffile || cat "$d" >"%conffile"
rm -f "$d"
%__chkconfig --add %name
%preun sysv
test "$1" != 0 || %__chkconfig --del %name
XEOFX
}
function rpm.genFiles
{
cat <<"EOF"
%files
%defattr(-,root,root,-)
%doc
%config(noreplace) %verify(not size md5 mtime) %attr(0620,root,%username) %logfile
%config(noreplace) %verify(not mtime) %conffile
%config(noreplace) %verify(not mtime) %_sysconfdir/logrotate.d/clamd.%service
%_sbindir/clamd.%service
%dir %attr(0700,%username,root) %rundir
%ghost %rundir/clamd.sock
%if 0%{!?_without_sysv:1}
%files sysv
%defattr(-,root,root,-)
%config %verify(not mtime) %_initrddir/clamd.%service
%config(noreplace) %verify(not mtime) %_sysconfdir/sysconfig/clamd.%service
%endif
%if 0%{!?_without_minit:1}
%files minit
%defattr(-,root,root,-)
%dir %minitsvcdir
%config(noreplace) %verify(not mtime) %minitsvcdir/params
%config %minitsvcdir/run
%minitsvcdir/respawn
%endif
EOF
}
SERVICE=
VERSION=
RELEASE=
LICENSE=
USERNAME=
tmp=$(getopt -o '' --long service:,version:,release:,license:,username:,help -n "$0" -- "$@") || exit 1
eval set -- "$tmp"
while true; do
case "$1" in
(--help) showHelp $0;;
(--service) SERVICE=$2; shift;;
(--version) VERSION=$2; shift;;
(--release) RELEASE=$2; shift;;
(--license) LICENSE=$2; shift;;
(--username) USERNAME=$2; shift;;
(--) shift; break;;
esac
shift
done
for i in SERVICE VERSION RELEASE LICENSE USERNAME; do
eval tmp=\$${i}
test "$tmp" || {
echo $"No value for $i specified; assuming @${i}@" >&2;
eval $i=@${i}@;
}
done
rpm.generatePreamble
rpm.generateHeader
rpm.genBody
rpm.genFiles