packaging(RHEL): fix installation of pam modules.
[gd/samba-autobuild/.git] / packaging / RHEL / samba.spec.tmpl
1 %define initdir %{_sysconfdir}/rc.d/init.d
2 %define auth %(test -f /etc/pam.d/system-auth && echo /etc/pam.d/system-auth || echo)
3
4 Summary: Samba SMB client and server
5 Vendor: Samba Team
6 Packager: Samba Team <samba@samba.org>
7 Name:         samba
8 Version:      PVERSION
9 Release:      PRELEASEPRPMREV
10 Epoch:        0
11 License: GNU GPL version 3
12 Group: System Environment/Daemons
13 URL: http://www.samba.org/
14
15 Source: samba-%{version}.tar.bz2
16
17 # Don't depend on Net::LDAP
18 Source998: filter-requires-samba.sh
19 Source999: setup.tar.bz2
20
21 Prereq: /sbin/chkconfig /bin/mktemp /usr/bin/killall
22 Prereq: fileutils sed /etc/init.d
23
24 Requires: pam >= 0.64 %{auth} 
25 Requires: samba-common = %{version}-%{release}
26 Requires: logrotate >= 3.4 initscripts >= 5.54-1
27 Provides: samba = %{version}
28
29 Prefix: /usr
30 BuildRoot: %{_tmppath}/%{name}-%{version}-root
31 BuildRequires: pam-devel, readline-devel, fileutils, libacl-devel, openldap-devel, krb5-devel, cups-devel
32
33 # Working around perl dependency problem from docs
34 %define __perl_requires %{SOURCE998}
35
36 # rpm screws up the arch lib dir when using --target on RHEL5
37 %ifarch i386 i486 i586 i686 ppc s390
38 %define _libarch lib
39 %else
40 %define _libarch %_lib
41 %endif
42
43 %define _libarchdir /usr/%{_libarch}
44
45
46 %description
47 Samba is the protocol by which a lot of PC-related machines share
48 files, printers, and other information (such as lists of available
49 files and printers). The Windows NT, OS/2, and Linux operating systems
50 support this natively, and add-on packages can enable the same thing
51 for DOS, Windows, VMS, UNIX of all kinds, MVS, and more. This package
52 provides an SMB server that can be used to provide network services to
53 SMB (sometimes called "Lan Manager") clients. Samba uses NetBIOS over
54 TCP/IP (NetBT) protocols and does NOT need the NetBEUI (Microsoft Raw
55 NetBIOS frame) protocol.
56
57
58 #######################################################################
59 %package client
60 Summary: Samba (SMB) client programs.
61 Group: Applications/System
62 Requires: samba-common = %{version}-%{release}
63 Obsoletes: smbfs
64 Provides: samba-client = %{version}-%{release}
65
66 %description client
67 The samba-client package provides some SMB clients to compliment the
68 built-in SMB filesystem in Linux. These clients allow access of SMB
69 shares and printing to SMB printers.
70
71
72 #######################################################################
73 %package common
74 Summary: Files used by both Samba servers and clients.
75 Group: Applications/System
76 Provides: samba-common = %{version}-%{release}
77
78 %description common
79 Samba-common provides files necessary for both the server and client
80 packages of Samba.
81
82
83 #######################################################################
84 %package swat
85 Summary: The Samba SMB server configuration program.
86 Group: Applications/System
87 Requires: samba = %{version} xinetd
88 Provides: samba-swat = %{version}-%{release}
89
90 %description swat
91 The samba-swat package includes the new SWAT (Samba Web Administration
92 Tool), for remotely managing Samba's smb.conf file using your favorite
93 Web browser.
94
95
96 #######################################################################
97 %package doc
98 Summary:      Samba Documentation
99 Group:        Documentation/Other
100 Provides:     samba-doc = %{version}-%{release}
101 Prereq:       /usr/bin/find /bin/rm /usr/bin/xargs
102
103 %description doc
104 The samba-doc package includes the HTML versions of the Samba manpages
105 utilized by SWAT as well as the HTML and PDF version of "Using Samba",
106 "Samba By Example", and "The Official Samba HOWTO and Reference Guide".
107
108
109 #######################################################################
110
111 %prep
112 %setup -q
113
114 # setup the vendor files (init scripts, etc...)
115 %setup -T -D -a 999 -n samba-%{version} -q
116
117 %build
118
119 /bin/cp setup/filter-requires-samba.sh %{SOURCE998}
120
121 cd source
122 # RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
123
124 ## check for ccache
125 # ccache -h 2>&1 > /dev/null
126 #if [ $? -eq 0 ]; then
127 #       CC="ccache gcc"
128 #else
129         CC="gcc"
130 #fi 
131
132 ## always run autogen.sh
133 ./autogen.sh
134
135 CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
136         --prefix=%{_prefix} \
137         --localstatedir=/var \
138         --with-configdir=%{_sysconfdir}/samba \
139         --libdir=%{_libarchdir} \
140         --with-modulesdir=%{_libarchdir}/samba \
141         --with-pammodulesdir=%{_libarch}/security \
142         --with-lockdir=/var/lib/samba \
143         --with-logfilebase=/var/log/samba \
144         --with-mandir=%{_mandir} \
145         --with-piddir=/var/run \
146         --with-privatedir=%{_sysconfdir}/samba \
147         --with-sambabook=%{_datadir}/swat/using_samba \
148         --with-swatdir=%{_datadir}/swat \
149         --enable-cups \
150         --with-acl-support \
151         --with-ads \
152         --with-automount \
153         --with-fhs \
154         --with-pam_smbpass \
155         --with-libsmbclient \
156         --with-libsmbsharemodes \
157         --without-smbwrapper \
158         --with-pam \
159         --with-quotas \
160         --with-shared-modules=idmap_rid,idmap_ad \
161         --with-syslog \
162         --with-utmp \
163         --with-dnsupdate
164
165 make showlayout
166
167 ## check for gcc 3.4 or later
168 CC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
169 CC_MAJOR=`echo ${CC_VERSION} | cut -d. -f 1`
170 CC_MINOR=`echo ${CC_VERSION} | cut -d. -f 2`
171 if [ ${CC_MAJOR} -ge 3 ]; then
172         if [ ${CC_MAJOR} -gt 3 -o ${CC_MINOR} -ge 4 ]; then
173                 make pch
174         fi
175 fi
176
177
178 make CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE" %{?_smp_mflags} \
179         all modules pam_smbpass
180
181 ## build the cifs fs mount helper
182 cd client
183 gcc  -o mount.cifs $RPM_OPT_FLAGS  -D_GNU_SOURCE -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE mount.cifs.c
184 gcc  -o umount.cifs $RPM_OPT_FLAGS  -D_GNU_SOURCE -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE umount.cifs.c
185 cd ..
186
187 # Remove some permission bits to avoid to many dependencies
188 cd ..
189 find examples docs -type f | xargs -r chmod -x
190
191 %install
192 # Clean up in case there is trash left from a previous build
193 rm -rf $RPM_BUILD_ROOT
194
195 # Create the target build directory hierarchy
196 mkdir -p $RPM_BUILD_ROOT%{_datadir}/swat/{help,include,using_samba/{figs,gifsa}}
197 mkdir -p $RPM_BUILD_ROOT%{_includedir}
198 mkdir -p $RPM_BUILD_ROOT%{_initrddir}
199 mkdir -p $RPM_BUILD_ROOT{%{_libarchdir},%{_includedir}}
200 mkdir -p $RPM_BUILD_ROOT%{_libarchdir}/samba/{auth,charset,idmap,vfs,pdb}
201 mkdir -p $RPM_BUILD_ROOT/%{_libarch}/security
202 mkdir -p $RPM_BUILD_ROOT%{_mandir}
203 mkdir -p $RPM_BUILD_ROOT%{_prefix}/{bin,sbin}
204 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
205 mkdir -p $RPM_BUILD_ROOT/sbin
206 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{logrotate.d,pam.d,samba}
207 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{pam.d,logrotate.d}
208 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
209 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{samba,sysconfig}
210 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d
211 mkdir -p $RPM_BUILD_ROOT/var/lib/samba/winbindd_privileged
212 mkdir -p $RPM_BUILD_ROOT/var/{log,run/winbindd,spool}/samba
213
214 cd source
215 make DESTDIR=$RPM_BUILD_ROOT \
216         install
217 cd ..
218
219 # NSS winbind support
220 install -m 755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/%{_libarch}/libnss_winbind.so
221 install -m 755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/%{_libarch}/libnss_wins.so
222 ( cd $RPM_BUILD_ROOT/%{_libarch};
223   ln -sf libnss_winbind.so  libnss_winbind.so.2;
224   ln -sf libnss_wins.so  libnss_wins.so.2 )
225
226 ## cleanup
227 /bin/rm -rf $RPM_BUILD_ROOT/usr/lib*/samba/security
228
229 # Install the miscellany
230 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT%{_sysconfdir}/samba/lmhosts
231
232 install -m644 setup/samba.log $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/samba
233 install -m644 setup/swat $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/swat
234 install -m644 setup/samba.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/samba
235 install -m755 setup/smb.init $RPM_BUILD_ROOT%{initdir}/smb
236 install -m755 setup/winbind.init $RPM_BUILD_ROOT%{initdir}/winbind
237 install -m644 setup/samba.pamd $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/samba
238 install -m755 setup/smbprint $RPM_BUILD_ROOT%{_bindir}
239 install -m644 setup/smbusers $RPM_BUILD_ROOT%{_sysconfdir}/samba/smbusers
240 install -m644 setup/smb.conf $RPM_BUILD_ROOT%{_sysconfdir}/samba/smb.conf
241 install -m755 source/client/mount.cifs $RPM_BUILD_ROOT/sbin/mount.cifs
242 install -m755 source/client/umount.cifs $RPM_BUILD_ROOT/sbin/umount.cifs
243 install -m755 source/script/mksmbpasswd.sh $RPM_BUILD_ROOT%{_bindir}
244
245 /bin/rm $RPM_BUILD_ROOT%{_sbindir}/*mount.cifs
246
247 ln -s ../..%{initdir}/smb  $RPM_BUILD_ROOT%{_sbindir}/samba
248 ln -s ../..%{initdir}/winbind  $RPM_BUILD_ROOT%{_sbindir}/winbind
249
250 # Remove "*.old" files
251 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
252
253 ## don't duplicate the docs.  These are installed by/with SWAT
254 rm -rf docs/htmldocs
255 rm -rf docs/manpages
256 ( cd docs; ln -s %{_prefix}/share/swat/help htmldocs )
257
258 ##
259 ## Clean out man pages for tools not installed here
260 ##
261 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
262 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
263 rm -f $RPM_BUILD_ROOT%{_mandir}/man5/vfstest.1*
264
265
266 %clean
267 rm -rf $RPM_BUILD_ROOT
268
269 %post
270 ## deal with an upgrade from a broken 3.0.21b RPM
271 if [ "$1" -eq "2" ]; then
272         if [ -d /var/cache/samba ]; then
273                 for file in `ls /var/cache/samba/*tdb`; do
274                         /bin/cp -up $file /var/lib/samba/`basename $file`
275                 done
276                 mkdir -p /var/lib/samba/eventlog
277                 for file in `ls /var/cache/samba/eventlog/*tdb`; do
278                         /bin/cp -up $file /var/lib/samba/eventlog/`basename $file`
279                 done
280                 /bin/mv /var/cache/samba /var/cache/samba.moved
281         fi
282 fi
283
284 %preun
285 if [ $1 = 0 ] ; then
286     /sbin/chkconfig --del smb
287     /sbin/chkconfig --del winbind
288     # rm -rf /var/log/samba/* /var/lib/samba/*
289     /sbin/service smb stop >/dev/null 2>&1
290 fi
291 exit 0
292
293 %postun
294 if [ "$1" -ge "1" ]; then
295         %{initdir}/smb restart >/dev/null 2>&1
296 fi      
297
298
299 %post swat
300 # Add swat entry to /etc/services if not already there.
301 if [ ! "`grep ^\s**swat /etc/services`" ]; then
302         echo 'swat        901/tcp     # Add swat service used via inetd' >> /etc/services
303 fi
304
305 %post common
306 /sbin/ldconfig
307
308 %postun common 
309 /sbin/ldconfig
310
311 #######################################################################
312 ## Files section                                                     ##
313 #######################################################################
314
315 %files
316 %defattr(-,root,root)
317
318 %config(noreplace) %{_sysconfdir}/sysconfig/samba
319 %config(noreplace) %{_sysconfdir}/samba/smbusers
320 %attr(755,root,root) %config %{initdir}/smb
321 %attr(755,root,root) %config %{initdir}/winbind
322 %config(noreplace) %{_sysconfdir}/logrotate.d/samba
323 %config(noreplace) %{_sysconfdir}/pam.d/samba
324
325 %attr(0755,root,root) %dir /var/log/samba
326 %attr(0755,root,root) %dir /var/lib/samba
327 %attr(1777,root,root) %dir /var/spool/samba
328
329 %{_sbindir}/samba
330 %{_sbindir}/winbind
331
332 %{_sbindir}/smbd
333 %{_sbindir}/nmbd
334 %{_sbindir}/winbindd
335
336 %{_bindir}/mksmbpasswd.sh
337 %{_bindir}/smbcontrol
338 %{_bindir}/smbstatus
339 %{_bindir}/tdbbackup
340 %{_bindir}/tdbtool
341 %{_bindir}/tdbdump
342 %{_bindir}/wbinfo
343 %{_bindir}/ntlm_auth
344 %{_bindir}/pdbedit
345 %{_bindir}/eventlogadm
346
347 %{_libarchdir}/samba/idmap/*.so
348 %{_libarchdir}/samba/nss_info/*.so
349 %{_libarchdir}/samba/vfs/*.so
350 %{_libarchdir}/samba/auth/*.so
351
352 %{_mandir}/man1/smbcontrol.1*
353 %{_mandir}/man1/smbstatus.1*
354 %{_mandir}/man1/vfstest.1*
355 %{_mandir}/man5/smbpasswd.5*
356 %{_mandir}/man7/samba.7*
357 %{_mandir}/man8/nmbd.8*
358 %{_mandir}/man8/pdbedit.8*
359 %{_mandir}/man8/smbd.8*
360 %{_mandir}/man8/tdbbackup.8*
361 %{_mandir}/man8/tdbdump.8*
362 %{_mandir}/man8/tdbtool.8*
363 %{_mandir}/man8/eventlogadm.8*
364 %{_mandir}/man8/winbindd.8*
365 %{_mandir}/man1/ntlm_auth.1*
366 %{_mandir}/man1/wbinfo.1*
367 %{_mandir}/man8/vfs_*.8*
368 %{_mandir}/man8/idmap_*.8*
369
370
371 ##########
372
373 %files doc
374 %defattr(-,root,root)
375 %doc README COPYING Manifest 
376 %doc WHATSNEW.txt Roadmap
377 %doc docs
378 %doc examples/autofs examples/LDAP examples/libsmbclient examples/misc examples/printer-accounting
379 %doc examples/printing
380 %doc %{_datadir}/swat/help
381 %doc %{_datadir}/swat/using_samba
382
383 ##########
384
385 %files swat
386 %defattr(-,root,root)
387 %config(noreplace) %{_sysconfdir}/xinetd.d/swat
388 %dir %{_datadir}/swat
389 %{_datadir}/swat/include
390 %{_datadir}/swat/images
391 %{_datadir}/swat/lang
392 %{_sbindir}/swat
393 %{_mandir}/man8/swat.8*
394
395 ##########
396
397 %files client
398 %defattr(-,root,root)
399 /sbin/mount.cifs
400 /sbin/umount.cifs
401
402 %{_bindir}/rpcclient
403 %{_bindir}/smbcacls
404 %{_bindir}/findsmb
405 %{_bindir}/smbcquotas
406 %{_bindir}/nmblookup
407 %{_bindir}/smbget
408 %{_bindir}/smbclient
409 %{_bindir}/smbprint
410 %{_bindir}/smbspool
411 %{_bindir}/smbtar
412 %{_bindir}/net
413 %{_bindir}/smbtree
414
415 %{_mandir}/man8/mount.cifs.8.*
416 %{_mandir}/man8/umount.cifs.8.*
417 %{_mandir}/man8/smbspool.8*
418 %{_mandir}/man1/smbget.1*
419 %{_mandir}/man5/smbgetrc.5*
420 %{_mandir}/man1/findsmb.1*
421 %{_mandir}/man1/nmblookup.1*
422 %{_mandir}/man1/rpcclient.1*
423 %{_mandir}/man1/smbcacls.1*
424 %{_mandir}/man1/smbclient.1*
425 %{_mandir}/man1/smbtar.1*
426 %{_mandir}/man1/smbtree.1*
427 %{_mandir}/man8/net.8*
428 %{_mandir}/man1/smbcquotas.1*
429
430 ##########
431
432 %files common
433 %defattr(-,root,root)
434 %dir %{_sysconfdir}/samba
435 %dir %{_libarchdir}/samba
436 %dir %{_libarchdir}/samba/charset
437 %config(noreplace) %{_sysconfdir}/samba/smb.conf
438 %config(noreplace) %{_sysconfdir}/samba/lmhosts
439
440 %attr(755,root,root) /%{_libarch}/libnss_wins.so*
441 %attr(755,root,root) /%{_libarch}/libnss_winbind.so*
442 %attr(755,root,root) /%{_libarch}/security/pam_winbind.so
443 %attr(755,root,root) /%{_libarch}/security/pam_smbpass.so
444
445 %{_includedir}/libsmbclient.h
446 %{_libarchdir}/libsmbclient.*
447 %{_includedir}/smb_share_modes.h
448 %{_libarchdir}/libsmbsharemodes.*
449
450 %{_libarchdir}/samba/*.dat
451 %{_libarchdir}/samba/*.msg
452 %{_libarchdir}/samba/charset/*.so
453
454 %{_includedir}/netapi.h
455 %{_includedir}/wbclient.h
456 %{_includedir}/talloc.h
457 %{_includedir}/tdb.h
458 %{_libarchdir}/libnetapi.so*
459 %{_libarchdir}/libtalloc.so*
460 %{_libarchdir}/libtdb.so*
461 %{_libarchdir}/libwbclient.so*
462
463 %{_bindir}/testparm
464 %{_bindir}/smbpasswd
465 %{_bindir}/profiles
466
467 %{_mandir}/man1/profiles.1*
468 %{_mandir}/man1/testparm.1*
469 %{_mandir}/man5/smb.conf.5*
470 %{_mandir}/man5/lmhosts.5*
471 %{_mandir}/man8/smbpasswd.8*
472 %{_mandir}/man7/libsmbclient.7*
473 %{_mandir}/man7/pam_winbind.7*
474
475 %changelog
476 * Fri Jan 16 2004 Gerald (Jerry) Carter <jerry@samba,org>
477 - Removed ChangeLog entries since they are kept in CVS
478
479
480