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