Merge branch 'debian'
[hcoop/debian/courier-authlib.git] / courier-authlib.spec.in
1 #
2 # Copyright 1998 - 2017 Double Precision, Inc. See COPYING for
3 # distribution information.
4
5 # No dist tag from mock; detect mandrake, redhat, etc. the old fashioned way
6 %if 0%{!?dist:1}
7 %define courier_release %(test -e /etc/mandrake-release -o -e /etc/mandriva-release && release="mdk" ; if test $? != 0; then release="`rpm -q --queryformat='.rh%{VERSION}' redhat-release 2>/dev/null`" ; if test $? != 0 ; then release="`rpm -q --queryformat='.fc%{VERSION}' fedora-release 2>/dev/null`" ; if test $? != 0 ; then release="" ; fi ; fi ; fi ; echo "$release")
8 %else
9 %define courier_release %{nil}
10 %endif
11
12 %define using_systemd %(test -d /etc/systemd && echo 1 || echo 0)
13
14 ################################################################################
15
16 Name: courier-authlib
17 Version: @VERSION@
18 Release: 1%{?dist}%{?courier_release}
19 Summary: Courier authentication library
20
21 Group: System Environment/Daemons
22 License: GPLv3
23 URL: http://www.courier-mta.org
24
25 ################################################################################
26
27 Source: http://downloads.sourceforge.net/courier/%{name}-%{version}.tar.bz2
28
29 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
30
31 ################################################################################
32
33 BuildRequires: libtool
34 BuildRequires: openldap-devel
35 BuildRequires: mysql-devel zlib-devel sqlite-devel
36 BuildRequires: postgresql-devel
37 BuildRequires: gdbm-devel
38 BuildRequires: pam-devel
39 BuildRequires: expect
40 BuildRequires: gcc-c++
41 BuildRequires: redhat-rpm-config
42 BuildRequires: courier-unicode-devel
43
44 BuildRequires: %{_includedir}/ltdl.h
45
46 %if 0%(rpm -q redhat-release >/dev/null 2>&1 || rpm -q fedora-release >/dev/null 2>&1 || exit 0; echo "1")
47 BuildRequires: redhat-rpm-config
48 BuildRequires: /usr/bin/ps
49 %endif
50
51 %if %using_systemd
52 Requires(post): systemd
53 Requires(preun): systemd
54 Requires(postun): systemd
55 %else
56 Requires(post): /sbin/chkconfig
57 Requires(preun): /sbin/chkconfig
58 %endif
59
60 %define need_perl_generators %(if rpm -q fedora-release >/dev/null 2>/dev/null; then echo "1"; exit 0; fi; echo "1"; exit 1)
61
62 %if %need_perl_generators
63 BuildRequires: perl-generators
64 %endif
65
66 ################################################################################
67
68 %description
69 The Courier authentication library provides authentication services for
70 other Courier applications.
71
72 ################################################################################
73
74 %package devel
75 Summary: Development libraries for the Courier authentication library
76 Group: Development/Libraries
77 Requires: courier-authlib = 0:%{version}-%{release}
78
79 %description devel
80 This package contains the development libraries and files needed to compile
81 Courier packages that use this authentication library. Install this
82 package in order to build the rest of the Courier packages. After they are
83 built and installed this package can be removed. Files in this package
84 are not needed at runtime.
85
86 ################################################################################
87
88 %package userdb
89
90 Summary: Userdb support for the Courier authentication library
91 Group: System Environment/Daemons
92 Requires: courier-authlib = 0:%{version}-%{release}
93
94 %description userdb
95 This package installs the userdb support for the Courier authentication
96 library. Userdb is a simple way to manage virtual mail accounts using
97 a GDBM-based database file.
98 Install this package in order to be able to authenticate with userdb.
99
100 ################################################################################
101
102 %package ldap
103
104 Summary: LDAP support for the Courier authentication library
105 Group: System Environment/Daemons
106 Requires: courier-authlib = 0:%{version}-%{release}
107
108 %description ldap
109 This package installs LDAP support for the Courier authentication library.
110 Install this package in order to be able to authenticate using LDAP.
111
112 ################################################################################
113
114 %package mysql
115
116 Summary: MySQL support for the Courier authentication library
117 Group: System Environment/Daemons
118 Requires: courier-authlib = 0:%{version}-%{release}
119
120 %description mysql
121 This package installs MySQL support for the Courier authentication library.
122 Install this package in order to be able to authenticate using MySQL.
123
124 %package sqlite
125
126 Summary: SQLite support for the Courier authentication library
127 Group: System Environment/Daemons
128 Requires: courier-authlib = 0:%{version}-%{release}
129
130 %description sqlite
131 This package installs SQLite support for the Courier authentication library.
132 Install this package in order to be able to authenticate using an SQLite-based
133 database file.
134
135 ################################################################################
136
137 %package pgsql
138
139 Summary: PostgreSQL support for the Courier authentication library
140 Group: System Environment/Daemons
141 Requires: courier-authlib = 0:%{version}-%{release}
142
143 %description pgsql
144 This package installs PostgreSQL support for the Courier authentication
145 library.
146 Install this package in order to be able to authenticate using PostgreSQL.
147
148 ################################################################################
149
150 %package pipe
151
152 Summary: External authentication module that communicates via pipes
153 Group: System Environment/Daemons
154 Requires: courier-authlib = 0:%{version}-%{release}
155
156 %description pipe
157 This package installs the authpipe module, which is a generic plugin
158 that enables authentication requests to be serviced by an external
159 program, then communicates through messages on stdin and stdout.
160
161 ################################################################################
162
163 %prep
164 %setup -q
165 PATH=/usr/bin:$PATH %configure -C --with-redhat
166
167 %build
168 %{__make} -s %{_smp_mflags}
169
170 %install
171 rm -rf $RPM_BUILD_ROOT
172 MAKEFLAGS= %{__make} -j 1 install DESTDIR=$RPM_BUILD_ROOT
173 %{__rm} -f $RPM_BUILD_ROOT%{_libdir}/courier-authlib/*.a
174 %{__install} -m 555 sysconftool $RPM_BUILD_ROOT%{_libexecdir}/courier-authlib
175
176 ./courierauthconfig --configfiles >configtmp
177 . ./configtmp
178
179 d=`pwd`
180 cd $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon || exit 1
181 $d/authmksock ./socket || exit 1
182 cd $d || exit 1
183 touch $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon/pid.lock || exit 1
184 touch $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon/pid || exit 1
185 %{__chmod} 777 $RPM_BUILD_ROOT%{_localstatedir}/spool/authdaemon/socket || exit 1
186
187 cat >configfiles.base <<EOF
188 %defattr(-,$mailuser,$mailgroup,-)
189 %{_sysconfdir}/authlib
190 %{_libexecdir}/courier-authlib
191 %dir %{_libdir}/courier-authlib
192 %dir %attr(750,$mailuser,$mailgroup) %{_localstatedir}/spool/authdaemon
193 EOF
194
195 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.mysql
196 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.sqlite
197 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.ldap
198 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.pgsql
199 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.userdb
200 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.pipe
201 echo "%defattr(-,$mailuser,$mailgroup,-)" >configfiles.devel
202
203 for f in $RPM_BUILD_ROOT%{_sbindir}/*
204 do
205 fn=`basename $f`
206 case "$fn" in
207 *userdb*)
208 echo "%{_sbindir}/$fn" >>configfiles.userdb
209 ;;
210 *)
211 echo "%{_sbindir}/$fn" >>configfiles.base
212 ;;
213 esac
214 done
215
216 for f in $RPM_BUILD_ROOT%{_libdir}/courier-authlib/*
217 do
218 fn=`basename $f`
219
220 # Remove *.la for authentication modules, keep the ones
221 # for client libraries. Do this before we sort them into buckets,
222 # below.
223
224 case "$fn" in
225 *.la)
226 case "$fn" in
227 libcourierauth*)
228 ;;
229 *)
230 rm -f "$f"
231 ;;
232 esac
233 continue
234 ;;
235 esac
236
237 case "$fn" in
238 libauthpipe*)
239 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.pipe
240 ;;
241 libauthldap*)
242 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.ldap
243 ;;
244 libauthmysql*)
245 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.mysql
246 ;;
247 libauthsqlite*)
248 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.sqlite
249 ;;
250 libauthpgsql*)
251 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.pgsql
252 ;;
253 libauthldap*)
254 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.ldap
255 ;;
256 libauthuserdb*)
257 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.userdb
258 ;;
259 *)
260 echo "%{_libdir}/courier-authlib/$fn" >>configfiles.base
261 ;;
262 esac
263 done
264 %if %using_systemd
265 %{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}
266 %{__install} -m 555 courier-authlib.sysvinit $RPM_BUILD_ROOT%{_datadir}
267
268 %{__mkdir_p} $RPM_BUILD_ROOT/lib/systemd/system
269 %{__install} -m 644 courier-authlib.service $RPM_BUILD_ROOT/lib/systemd/system
270 %else
271 %{__mkdir_p} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
272 %{__install} -m 555 courier-authlib.sysvinit \
273 $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/courier-authlib
274 %endif
275
276 %post
277 %{_libexecdir}/courier-authlib/sysconftool %{_sysconfdir}/authlib/*.dist >/dev/null
278 %if %using_systemd
279 if test -f /etc/init.d/courier-authlib
280 then
281 # Upgrade to systemd
282
283 /sbin/chkconfig --del courier-authlib
284 /bin/systemctl stop courier-authlib.service || :
285 fi
286 %systemd_post courier-authlib.service
287 if [ $1 -eq 1 ]
288 then
289 /bin/systemctl daemon-reload >/dev/null 2>&1 || :
290 fi
291 %else
292 /sbin/chkconfig --del courier-authlib
293 /sbin/chkconfig --add courier-authlib
294 %endif
295 %preun
296 if test "$1" = "0"
297 then
298 %if %using_systemd
299 %systemd_preun courier-authlib.service
300 %else
301 /sbin/chkconfig --del courier-authlib
302 %endif
303 fi
304
305 %postun
306 %if %using_systemd
307 if [ $1 -eq 0 ]
308 then
309 /bin/systemctl daemon-reload
310 fi
311 %systemd_postun_with_restart courier-authlib.service
312 %endif
313
314 %clean
315 rm -rf $RPM_BUILD_ROOT
316
317
318 %files -f configfiles.base
319 %defattr(-,root,root,-)
320 %doc README README*html README.authmysql.myownquery README.ldap
321 %doc NEWS COPYING* AUTHORS ChangeLog
322 %if %using_systemd
323 /lib/systemd/system/*
324 %attr(755, bin, bin) %{_datadir}/courier-authlib.sysvinit
325 %else
326 /etc/rc.d/init.d/*
327 %endif
328 %ghost %attr(600, root, root) %{_localstatedir}/spool/authdaemon/pid.lock
329 %ghost %attr(644, root, root) %{_localstatedir}/spool/authdaemon/pid
330 %ghost %attr(-, root, root) %{_localstatedir}/spool/authdaemon/socket
331 %{_mandir}/man1/*
332
333 %files -f configfiles.userdb userdb
334 %{_mandir}/man8/*userdb*
335
336 %files -f configfiles.devel devel
337 %defattr(-,root,root,-)
338 %{_bindir}/courierauthconfig
339 %{_includedir}/*
340 %{_mandir}/man3/*
341 %{_libdir}/courier-authlib/*.la
342 %doc authlib.html auth_*.html
343
344 %files -f configfiles.ldap ldap
345 %defattr(-,root,root,-)
346 %doc authldap.schema authldap.ldif
347
348 %files -f configfiles.mysql mysql
349
350 %files -f configfiles.sqlite sqlite
351
352 %files -f configfiles.pgsql pgsql
353
354 %files -f configfiles.pipe pipe
355
356 %changelog
357
358 * Thu Sep 7 2006 Chris Petersen <rpm@forevermore.net> 0.58-2
359 - Make the spec a little prettier
360 - Replace BuildPreReq with BuildRequires
361 - Remove period from summaries (rpmlint)
362 - Fix release tag to use %{?dist} macro if it's present
363 - Change distro-detection to use "rh" and "fc" for version detection, and add support for mandriva
364
365 * Sun Oct 3 2004 Mr. Sam <sam@email-scan.com> 0.50-1
366 - Initial build.