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