Tue, 29 Mar 2011 20:04:34 +0200
Rework package yet again, correcting and introducing new buildconf logic:
Conditionally disable bootstrap stage comparison correctly, correct
english grammar, better find system as(1) and ld(1), indotruce detailed
optimization option messages, more completely guess cpu types, allow
profiled bootstrapping without a preinstalled GCC because many other
compilers have long since implemented 64-bit arithmetic, instruct make
to build sequentially (not in sparallel) when building a profiled
bootstrap as GCC online documents recommend, and generally improve
comment blocks.
The single most important correction in this changeset relates to the
GCC changed optimization policy since at least GCC 4.5, in which -march
is always passed and not always correctly guessed. In the case of this
package, allowing GCC to guess the architecture leads to wild build
errors at various subcomponents (zlib, libgcc, libiberty...) and
bootstrap stages. It seems quite platform specific, and the safest
approach to correcting this seems to be explicitly always specifying the
-march argument when bootstrapping GCC. Because the best choice 'native'
is not available when bootstrapping using a foreign (non GCC) compiler,
a guess is made according to rpmmacros l_platform in that case.
It is questionable as to whether these recent optimization changes
on the part of GCC or this package are compatible with each other,
or if either are complete or correct at all. At least applying these
corrections allows this package to build again in most cases test.
1 ##
2 ## clamav.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2009 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package information
25 Name: clamav
26 Summary: Clam Antivirus
27 URL: http://www.clamav.net/
28 Vendor: Tomasz Kojm
29 Packager: OpenPKG Foundation e.V.
30 Distribution: OpenPKG Community
31 Class: EVAL
32 Group: AntiVirus
33 License: GPL
34 Version: 0.95.3
35 Release: 20091102
37 # package options
38 %option with_milter no
40 # list of sources
41 Source0: http://switch.dl.sourceforge.net/clamav/clamav-%{version}.tar.gz
42 Source1: rc.clamav
43 Patch0: clamav.patch
45 # build information
46 Prefix: %{l_prefix}
47 BuildRoot: %{l_buildroot}
48 BuildPreReq: OpenPKG, openpkg >= 20060823, gcc, bzip2, pkgconfig, bc
49 PreReq: OpenPKG, openpkg >= 20060823
50 BuildPreReq: zlib, bzip2, curl, gmp, libiconv, openssl
51 PreReq: zlib, bzip2, curl, gmp, libiconv, openssl
52 %if "%{with_milter}" == "yes"
53 BuildPreReq: milter
54 PreReq: milter
55 %endif
56 AutoReq: no
57 AutoReqProv: no
59 %description
60 Clam AntiVirus is an anti-virus toolkit for UNIX. The main
61 purpose of this software is the integration with mail servers
62 (attachment scanning). The package provides a flexible and scalable
63 multi-threaded daemon, a command line scanner, and a tool for
64 automatic updating via Internet. The programs are based on a shared
65 library distributed with the Clam AntiVirus package, which you can
66 use with your own software. The virus database is based on the virus
67 database from OpenAntiVirus, but contains additional signatures.
69 %track
70 prog clamav = {
71 version = %{version}
72 url = http://sourceforge.net/projects/clamav/files/
73 regex = clamav-(\d+\.\d+(\.\d+)*)\.tar\.gz
74 }
76 %prep
77 %setup -q
78 %patch -p0
80 %build
81 # configure package
82 CC="%{l_cc}" \
83 CFLAGS="%{l_cflags -O}" \
84 CPPFLAGS="%{l_cppflags}" \
85 LDFLAGS="%{l_ldflags}" \
86 GREP="grep" \
87 ./configure \
88 --prefix=%{l_prefix} \
89 --mandir=%{l_prefix}/man \
90 --sysconfdir=%{l_prefix}/etc/clamav \
91 --with-zlib=%{l_prefix} \
92 --with-libcurl \
93 --with-user=%{l_rusr} \
94 --with-group=%{l_rgrp} \
95 --without-tcpwrappers \
96 --disable-clamav \
97 --disable-clamuko \
98 --disable-urandom \
99 --disable-cr \
100 %if "%{with_milter}" == "yes"
101 --enable-milter \
102 --with-sendmail=/dev/null \
103 %else
104 --disable-milter \
105 %endif
106 --disable-unrar \
107 --disable-shared
109 # build package
110 %{l_make} %{l_mflags -O}
112 %install
113 rm -rf $RPM_BUILD_ROOT
115 # perform standard package installation
116 %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
118 # install default configuration
119 %{l_shtool} mkdir -f -p -m 755 \
120 $RPM_BUILD_ROOT%{l_prefix}/etc/clamav
121 %{l_shtool} install -c -m 644 \
122 -e 's;^\(Example\);#\1;' \
123 -e 's;^#\(LogFile\) /.*;\1 %{l_prefix}/var/clamav/clamd.log;' \
124 -e 's;^#\(LogTime.*\);\1;' \
125 -e 's;^#\(PidFile\).*;\1 %{l_prefix}/var/clamav/clamd.pid;' \
126 -e 's;^\(LocalSocket\).*;\1 %{l_prefix}/var/clamav/clamd.sock;' \
127 -e 's;^#\(FixStaleSocket.*\);\1;' \
128 -e 's;^#\(DatabaseDirectory\).*;\1 %{l_prefix}/share/clamav;' \
129 -e 's;^#\(User\).*;\1 %{l_rusr};' \
130 etc/clamd.conf \
131 $RPM_BUILD_ROOT%{l_prefix}/etc/clamav/
132 %{l_shtool} install -c -m 644 \
133 -e 's;^\(Example\);#\1;' \
134 -e 's;^#\(DatabaseDirectory\).*;\1 %{l_prefix}/share/clamav;' \
135 -e 's;^#\(UpdateLogFile\).*;\1 %{l_prefix}/var/clamav/freshclam.log;' \
136 -e 's;^#\(NotifyClamd\).*;\1 %{l_prefix}/etc/clamav/clamd.conf;' \
137 etc/freshclam.conf \
138 $RPM_BUILD_ROOT%{l_prefix}/etc/clamav/
140 # install run-command script
141 %{l_shtool} mkdir -f -p -m 755 \
142 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
143 %{l_shtool} install -c -m 755 %{l_value -s -a} \
144 %{SOURCE rc.clamav} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
146 # strip-down installation hierarchy
147 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
148 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
149 %if "%{with_milter}" == "no"
150 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/clamav-milter.8
151 %endif
153 # create additional installation directory
154 %{l_shtool} mkdir -f -p -m 755 \
155 $RPM_BUILD_ROOT%{l_prefix}/var/clamav
157 # determine installation files
158 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
159 %{l_files_std} \
160 '%config %{l_prefix}/etc/clamav/*.conf' \
161 '%attr(755,%{l_rusr},%{l_mgrp}) %{l_prefix}/var/clamav' \
162 '%attr(755,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/clamav'
164 %files -f files
166 %clean
167 rm -rf $RPM_BUILD_ROOT
169 %pre
170 # before upgrade, save status and stop service
171 [ $1 -eq 2 ] || exit 0
172 eval `%{l_rc} clamav status 2>/dev/null | tee %{l_tmpfile}`
173 %{l_rc} clamav stop 2>/dev/null
174 exit 0
176 %post
177 if [ $1 -eq 2 ]; then
178 # after upgrade, restore status
179 eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
180 [ ".$clamav_active" = .yes ] && %{l_rc} clamav start
181 fi
182 exit 0
184 %preun
185 # before erase, stop service and remove log files
186 [ $1 -eq 0 ] || exit 0
187 %{l_rc} clamav stop 2>/dev/null
188 rm -f $RPM_INSTALL_PREFIX/var/clamav/*.log* >/dev/null 2>&1 || true
189 exit 0