packaging/RHEL-CTDB: fix the build
[samba.git] / packaging / RHEL-CTDB / 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:      1GITHASH
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 Requires: /sbin/chkconfig /bin/mktemp /usr/bin/killall
22 Requires: fileutils sed /etc/init.d
23
24 Requires: pam >= 0.64 %{auth} 
25 Requires: samba-common = %{version}-%{release}
26 Provides: samba = %{version}
27
28 Prefix: /usr
29 BuildRoot: %{_tmppath}/%{name}-%{version}-root
30 BuildRequires: pam-devel, readline-devel, fileutils, libacl-devel, openldap-devel, krb5-devel, cups-devel, e2fsprogs-devel, gettext
31 # requirements for building the man pages:
32 BuildRequires: libxslt, docbook-utils, docbook-style-xsl, rsync
33 BuildRequires: ctdb-devel >= 1.2.25
34
35 # Working around perl dependency problem from docs
36 %define __perl_requires %{SOURCE998}
37
38 # rpm screws up the arch lib dir when using --target on RHEL5
39 %ifarch i386 i486 i586 i686 ppc s390
40 %define _libarch lib
41 %else
42 %define _libarch %_lib
43 %endif
44
45 %define _libarchdir /usr/%{_libarch}
46
47 %define numcpu  %(grep "^processor" /proc/cpuinfo |wc -l | sed -e 's/^0$/1/')
48
49 %description
50 Samba is the protocol by which a lot of PC-related machines share
51 files, printers, and other information (such as lists of available
52 files and printers). The Windows NT, OS/2, and Linux operating systems
53 support this natively, and add-on packages can enable the same thing
54 for DOS, Windows, VMS, UNIX of all kinds, MVS, and more. This package
55 provides an SMB server that can be used to provide network services to
56 SMB (sometimes called "Lan Manager") clients. Samba uses NetBIOS over
57 TCP/IP (NetBT) protocols and does NOT need the NetBEUI (Microsoft Raw
58 NetBIOS frame) protocol.
59
60
61 ######################################################################
62 %package client
63 Summary: Samba (SMB) client programs.
64 Group: Applications/System
65 Requires: samba-common = %{version}-%{release}
66 Obsoletes: smbfs
67 Provides: samba-client = %{version}-%{release}
68
69 %description client
70 The samba-client package provides some SMB clients to compliment the
71 built-in SMB filesystem in Linux. These clients allow access of SMB
72 shares and printing to SMB printers.
73
74
75 #######################################################################
76 %package common
77 Summary: Files used by both Samba servers and clients.
78 Group: Applications/System
79 Provides: samba-common = %{version}-%{release}
80
81 %description common
82 Samba-common provides files necessary for both the server and client
83 packages of Samba.
84
85
86
87 #######################################################################
88 %package swat
89 Summary: The Samba SMB server configuration program.
90 Group: Applications/System
91 Requires: samba = %{version} xinetd
92 Provides: samba-swat = %{version}-%{release}
93
94 %description swat
95 The samba-swat package includes the new SWAT (Samba Web Administration
96 Tool), for remotely managing Samba's smb.conf file using your favorite
97 Web browser.
98
99
100 #######################################################################
101 %package doc
102 Summary:      Samba Documentation
103 Group:        Documentation/Other
104 Provides:     samba-doc = %{version}-%{release}
105 Requires:       /usr/bin/find /bin/rm /usr/bin/xargs
106
107 %description doc
108 The samba-doc package includes the HTML versions of the Samba manpages
109 utilized by SWAT as well as the HTML and PDF version of "Using Samba",
110 "Samba By Example", and "The Official Samba HOWTO and Reference Guide".
111
112
113 #######################################################################
114
115 %prep
116 %setup -q
117
118 # setup the vendor files (init scripts, etc...)
119 %setup -T -D -a 999 -n samba-%{version} -q
120
121 %build
122
123 /bin/cp setup/filter-requires-samba.sh %{SOURCE998}
124
125 cd source3
126 # RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_FILE_OFFSET_BITS=64"
127
128 ## check for ccache
129 if ccache -h >/dev/null 2>&1 ; then
130         CC="ccache gcc"
131 else
132         CC="gcc"
133 fi
134
135 export CC
136
137 ## always run autogen.sh
138 ./autogen.sh
139
140
141 CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" ./configure \
142         --prefix=%{_prefix} \
143         --localstatedir=/var \
144         --with-configdir=%{_sysconfdir}/samba \
145         --libdir=%{_libarchdir} \
146         --with-modulesdir=%{_libarchdir}/samba \
147         --with-pammodulesdir=/%{_libarch}/security \
148         --with-lockdir=/var/lib/samba \
149         --with-logfilebase=/var/log/samba \
150         --mandir=%{_mandir} \
151         --with-piddir=/var/run \
152         --with-privatedir=%{_sysconfdir}/samba \
153         --disable-cups \
154         --with-acl-support \
155         --with-ads \
156         --with-automount \
157         --enable-fhs \
158         --with-pam_smbpass \
159         --with-libsmbclient \
160         --with-libsmbsharemodes \
161         --without-smbwrapper \
162         --with-pam \
163         --with-quotas \
164         --with-shared-modules=idmap_rid,idmap_ad,idmap_tdb2,vfs_gpfs,vfs_tsmsm \
165         --with-syslog \
166         --with-utmp \
167         --with-cluster-support \
168         --with-ctdb=/usr/include \
169         --without-ldb \
170         --without-dnsupdate \
171         --with-aio-support \
172         --disable-merged-build \
173         --disable-smbtorture4 \
174         --disable-external-libtalloc \
175         --disable-external-libtdb
176
177 make showlayout
178
179 ## check for gcc 3.4 or later
180 CC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
181 CC_MAJOR=`echo ${CC_VERSION} | cut -d. -f 1`
182 CC_MINOR=`echo ${CC_VERSION} | cut -d. -f 2`
183 if [ ${CC_MAJOR} -ge 3 ]; then
184         if [ ${CC_MAJOR} -gt 3 -o ${CC_MINOR} -ge 4 ]; then
185                 make pch
186         fi
187 fi
188
189
190 make -j %{numcpu} %{?_smp_mflags} \
191         everything modules pam_smbpass
192
193 # check that desired suppor has been compiled into smbd:
194 export LD_LIBRARY_PATH=./bin
195 for test in HAVE_POSIX_ACLS HAVE_LDAP HAVE_KRB5 HAVE_GPFS CLUSTER_SUPPORT
196 do
197         if ! $(./bin/smbd -b | grep -q $test ) ; then
198                 echo "ERROR: '$test' is not in smbd. Build stopped."
199                 exit 1;
200         fi
201 done
202
203 # try and build the manpages
204 cd ..
205 ./release-scripts/build-manpages-nogit
206
207 # Remove some permission bits to avoid to many dependencies
208 find examples docs -type f | xargs -r chmod -x
209
210 %install
211 # Clean up in case there is trash left from a previous build
212 rm -rf $RPM_BUILD_ROOT
213
214 # Create the target build directory hierarchy
215 mkdir -p $RPM_BUILD_ROOT%{_datadir}/samba/swat/{help,include,using_samba/{figs,gifsa}}
216 mkdir -p $RPM_BUILD_ROOT%{_includedir}
217 mkdir -p $RPM_BUILD_ROOT%{_initrddir}
218 mkdir -p $RPM_BUILD_ROOT{%{_libarchdir},%{_includedir}}
219 mkdir -p $RPM_BUILD_ROOT%{_libarchdir}/samba/{auth,charset,idmap,vfs,pdb}
220 mkdir -p $RPM_BUILD_ROOT/%{_libarch}/security
221 mkdir -p $RPM_BUILD_ROOT/lib/security
222 mkdir -p $RPM_BUILD_ROOT%{_mandir}
223 mkdir -p $RPM_BUILD_ROOT%{_prefix}/{bin,sbin}
224 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
225 mkdir -p $RPM_BUILD_ROOT/sbin
226 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{pam.d,samba}
227 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{pam.d}
228 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
229 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{samba,sysconfig}
230 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d
231 mkdir -p $RPM_BUILD_ROOT/var/lib/samba/winbindd_privileged
232 mkdir -p $RPM_BUILD_ROOT/var/{log,run/winbindd,spool}/samba
233 mkdir -p $RPM_BUILD_ROOT/%{_libarchdir}/krb5/plugins/libkrb5
234
235 cd source3
236 make DESTDIR=$RPM_BUILD_ROOT \
237         install
238
239 make DESTDIR=$RPM_BUILD_ROOT \
240         install-dbwrap_tool install-dbwrap_torture
241 cd ..
242
243 # NSS winbind support
244 install -m 755 nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/%{_libarch}/libnss_winbind.so.2
245 ( cd $RPM_BUILD_ROOT/%{_libarch};
246   ln -sf libnss_winbind.so.2  libnss_winbind.so )
247 #
248 # do not install libnss_wins.so in order to reduce dependencies
249 # (we do not need it for the samba-ctdb scenario)
250 #
251 #install -m 755 nsswitch/libnss_wins.so $RPM_BUILD_ROOT/%{_libarch}/libnss_wins.so
252 # ( cd $RPM_BUILD_ROOT/%{_libarch}; ln -sf libnss_wins.so  libnss_wins.so.2 )
253
254 cp -p source3/bin/winbind_krb5_locator.so ${RPM_BUILD_ROOT}/%{_libarchdir}/krb5/plugins/libkrb5
255
256
257 ## cleanup
258 /bin/rm -rf $RPM_BUILD_ROOT/usr/lib*/samba/security
259
260 # remove installed but unpackaged files:
261 /bin/rm -f $RPM_BUILD_ROOT/usr/lib*/libtalloc.so
262 /bin/rm -f $RPM_BUILD_ROOT/usr/lib*/libtdb.so
263 /bin/rm -f $RPM_BUILD_ROOT/usr/lib*/samba/perfcount/pc_test.so
264
265
266 # Install the miscellany
267 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT%{_sysconfdir}/samba/lmhosts
268
269 install -m644 setup/swat $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/swat
270 install -m644 setup/samba.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/samba
271 install -m755 setup/smb.init $RPM_BUILD_ROOT%{initdir}/smb
272 install -m755 setup/winbind.init $RPM_BUILD_ROOT%{initdir}/winbind
273 install -m644 setup/samba.pamd $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/samba
274 install -m755 setup/smbprint $RPM_BUILD_ROOT%{_bindir}
275 install -m644 setup/smbusers $RPM_BUILD_ROOT%{_sysconfdir}/samba/smbusers
276 install -m644 setup/smb.conf $RPM_BUILD_ROOT%{_sysconfdir}/samba/smb.conf
277 install -m755 source3/script/mksmbpasswd.sh $RPM_BUILD_ROOT%{_bindir}
278
279 ln -s ../..%{initdir}/smb  $RPM_BUILD_ROOT%{_sbindir}/samba
280 ln -s ../..%{initdir}/winbind  $RPM_BUILD_ROOT%{_sbindir}/winbind
281
282 # Remove "*.old" files
283 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
284
285
286 ##
287 ## Clean out man pages for tools not installed here
288 ##
289 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
290 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
291 rm -f $RPM_BUILD_ROOT%{_mandir}/man5/vfstest.1*
292
293
294 %clean
295 rm -rf $RPM_BUILD_ROOT
296
297 %post
298 ## deal with an upgrade from a broken 3.0.21b RPM
299 if [ "$1" -eq "2" ]; then
300         if [ -d /var/cache/samba ]; then
301                 for file in `ls /var/cache/samba/*tdb`; do
302                         /bin/cp -up $file /var/lib/samba/`basename $file`
303                 done
304                 mkdir -p /var/lib/samba/eventlog
305                 for file in `ls /var/cache/samba/eventlog/*tdb`; do
306                         /bin/cp -up $file /var/lib/samba/eventlog/`basename $file`
307                 done
308                 /bin/mv /var/cache/samba /var/cache/samba.moved
309         fi
310 fi
311
312 if [ "$1" -ge "1" ]; then
313         /sbin/service smb condrestart >/dev/null 2>&1 || :
314 fi
315
316 %preun
317 if [ $1 = 0 ] ; then
318     /sbin/service smb stop >/dev/null 2>&1 || :
319     /sbin/chkconfig --del smb
320     # rm -rf /var/log/samba/* /var/lib/samba/*
321 fi
322 exit 0
323
324 #%postun
325
326 %post swat
327 # Add swat entry to /etc/services if not already there.
328 if [ ! "`grep ^\s**swat /etc/services`" ]; then
329         echo 'swat        901/tcp     # Add swat service used via inetd' >> /etc/services
330 fi
331
332 %post common
333 /sbin/ldconfig
334
335 if [ "$1" -ge "1" ]; then
336         /sbin/service winbind condrestart >/dev/null 2>&1 || :
337 fi
338
339 %preun common
340 if [ $1 = 0 ] ; then
341     /sbin/service winbind stop >/dev/null 2>&1 || :
342     /sbin/chkconfig --del winbind
343 fi
344 exit 0
345
346 %postun common 
347 /sbin/ldconfig
348
349 #######################################################################
350 ## Files section                                                     ##
351 #######################################################################
352
353 %files
354 %defattr(-,root,root)
355
356 %config(noreplace) %{_sysconfdir}/sysconfig/samba
357 %config(noreplace) %{_sysconfdir}/samba/smbusers
358 %attr(755,root,root) %config %{initdir}/smb
359 %config(noreplace) %{_sysconfdir}/pam.d/samba
360
361 %attr(0755,root,root) %dir /var/log/samba
362 %attr(0755,root,root) %dir /var/lib/samba
363 %attr(1777,root,root) %dir /var/spool/samba
364
365 %{_sbindir}/samba
366
367 %{_sbindir}/smbd
368 %{_sbindir}/nmbd
369
370 %{_bindir}/mksmbpasswd.sh
371 %{_bindir}/smbcontrol
372 %{_bindir}/smbstatus
373 %{_bindir}/tdbbackup
374 %{_bindir}/tdbtool
375 %{_bindir}/tdbdump
376 %{_bindir}/tdbrestore
377 %{_bindir}/eventlogadm
378
379 %{_libarchdir}/samba/auth/script.so
380 %{_libarchdir}/samba/vfs/acl_tdb.so
381 %{_libarchdir}/samba/vfs/acl_xattr.so
382 %{_libarchdir}/samba/vfs/aio_fork.so
383 %{_libarchdir}/samba/vfs/audit.so
384 %{_libarchdir}/samba/vfs/cap.so
385 %{_libarchdir}/samba/vfs/catia.so
386 %{_libarchdir}/samba/vfs/crossrename.so
387 %{_libarchdir}/samba/vfs/default_quota.so
388 %{_libarchdir}/samba/vfs/dirsort.so
389 %{_libarchdir}/samba/vfs/expand_msdfs.so
390 %{_libarchdir}/samba/vfs/extd_audit.so
391 %{_libarchdir}/samba/vfs/fake_perms.so
392 %{_libarchdir}/samba/vfs/fileid.so
393 %{_libarchdir}/samba/vfs/full_audit.so
394 %{_libarchdir}/samba/vfs/gpfs.so
395 %{_libarchdir}/samba/vfs/linux_xfs_sgid.so
396 %{_libarchdir}/samba/vfs/netatalk.so
397 %{_libarchdir}/samba/vfs/preopen.so
398 %{_libarchdir}/samba/vfs/readahead.so
399 %{_libarchdir}/samba/vfs/readonly.so
400 %{_libarchdir}/samba/vfs/recycle.so
401 %{_libarchdir}/samba/vfs/scannedonly.so
402 %{_libarchdir}/samba/vfs/shadow_copy.so
403 %{_libarchdir}/samba/vfs/shadow_copy2.so
404 %{_libarchdir}/samba/vfs/smb_traffic_analyzer.so
405 %{_libarchdir}/samba/vfs/streams_depot.so
406 %{_libarchdir}/samba/vfs/streams_xattr.so
407 %{_libarchdir}/samba/vfs/syncops.so
408 %{_libarchdir}/samba/vfs/time_audit.so
409 %{_libarchdir}/samba/vfs/tsmsm.so
410 %{_libarchdir}/samba/vfs/xattr_tdb.so
411 %{_libarchdir}/samba/vfs/aio_posix.so
412 %{_libarchdir}/samba/vfs/aio_pthread.so
413 %{_libarchdir}/samba/vfs/media_harmony.so
414
415 %{_mandir}/man1/smbcontrol.1*
416 %{_mandir}/man1/smbstatus.1*
417 %{_mandir}/man1/vfstest.1*
418 %{_mandir}/man5/smbpasswd.5*
419 %{_mandir}/man5/pam_winbind.conf.5*
420 %{_mandir}/man7/samba.7*
421 %{_mandir}/man8/nmbd.8*
422 %{_mandir}/man8/pdbedit.8*
423 %{_mandir}/man8/smbd.8*
424 %{_mandir}/man8/eventlogadm.8*
425 %{_mandir}/man8/vfs_*.8*
426 %{_mandir}/man8/smbta-util.8*
427
428
429 ##########
430
431 %files doc
432 %defattr(-,root,root)
433 %doc README
434 %doc COPYING
435 %doc WHATSNEW.txt
436 %doc Roadmap
437 %doc docs-xml/archives/THANKS
438 %doc docs-xml/archives/history
439 %doc docs-xml/registry
440 %doc examples/autofs
441 %doc examples/LDAP
442 %doc examples/libsmbclient
443 %doc examples/misc
444 %doc examples/printer-accounting
445 %doc examples/printing
446
447 ##########
448
449 %files swat
450 %defattr(-,root,root)
451 %config(noreplace) %{_sysconfdir}/xinetd.d/swat
452 %dir %{_datadir}/samba/swat
453 %{_datadir}/samba/swat/*
454 %{_sbindir}/swat
455 %{_mandir}/man8/swat.8*
456 %attr(755,root,root) %{_datadir}/samba/codepages/*.msg
457
458 ##########
459
460 %files client
461 %defattr(-,root,root)
462
463 %{_bindir}/rpcclient
464 %{_bindir}/smbcacls
465 %{_bindir}/findsmb
466 %{_bindir}/nmblookup
467 %{_bindir}/smbget
468 %{_bindir}/smbclient
469 %{_bindir}/smbprint
470 %{_bindir}/smbspool
471 %{_bindir}/smbtar
472 %{_bindir}/smbtree
473 %{_bindir}/sharesec
474 %{_bindir}/smbta-util
475
476 %{_mandir}/man8/smbspool.8*
477 %{_mandir}/man1/smbget.1*
478 %{_mandir}/man5/smbgetrc.5*
479 %{_mandir}/man1/findsmb.1*
480 %{_mandir}/man1/nmblookup.1*
481 %{_mandir}/man1/rpcclient.1*
482 %{_mandir}/man1/smbcacls.1*
483 %{_mandir}/man1/smbclient.1*
484 %{_mandir}/man1/smbtar.1*
485 %{_mandir}/man1/smbtree.1*
486 %{_mandir}/man1/sharesec.1*
487
488 ##########
489
490
491 %files common
492 %defattr(-,root,root)
493 %dir %{_sysconfdir}/samba
494 %dir %{_libarchdir}/samba
495 %dir %{_libarchdir}/samba/charset
496 %config(noreplace) %{_sysconfdir}/samba/smb.conf
497 %config(noreplace) %{_sysconfdir}/samba/lmhosts
498 %attr(755,root,root) %config %{initdir}/winbind
499
500 %attr(755,root,root) /%{_libarch}/libnss_winbind.so
501 %attr(755,root,root) /%{_libarch}/libnss_winbind.so.2
502 %attr(755,root,root) /%{_libarch}/security/pam_winbind.so
503 %attr(755,root,root) /%{_libarch}/security/pam_smbpass.so
504 /usr/share/locale/*/LC_MESSAGES/pam_winbind.mo
505 /usr/share/locale/*/LC_MESSAGES/net.mo
506
507 %{_libarchdir}/samba/idmap/ad.so
508 %{_libarchdir}/samba/idmap/rid.so
509 %{_libarchdir}/samba/idmap/tdb2.so
510 %{_libarchdir}/samba/idmap/autorid.so
511 %{_libarchdir}/samba/idmap/hash.so
512 %{_libarchdir}/samba/nss_info/hash.so
513 %{_libarchdir}/samba/nss_info/rfc2307.so
514 %{_libarchdir}/samba/nss_info/sfu.so
515 %{_libarchdir}/samba/nss_info/sfu20.so
516 %{_datadir}/samba/codepages/lowcase.dat
517 %{_datadir}/samba/codepages/upcase.dat
518 %{_datadir}/samba/codepages/valid.dat
519
520 %{_includedir}/libsmbclient.h
521 %{_libarchdir}/libsmbclient.*
522 %{_includedir}/smb_share_modes.h
523 %{_libarchdir}/libsmbsharemodes.so
524 %{_libarchdir}/libsmbsharemodes.so.0
525
526 %{_includedir}/netapi.h
527 %{_includedir}/wbclient.h
528 %{_libarchdir}/libnetapi.so
529 %{_libarchdir}/libnetapi.so.0
530 %{_libarchdir}/libwbclient.so
531 %{_libarchdir}/libwbclient.so.0
532
533 %{_libarchdir}/krb5/plugins/libkrb5/winbind_krb5_locator.so
534
535 %{_sbindir}/winbind
536
537 %{_sbindir}/winbindd
538 %{_bindir}/testparm
539 %{_bindir}/smbpasswd
540 %{_bindir}/profiles
541 %{_bindir}/net
542 %{_bindir}/wbinfo
543 %{_bindir}/ntlm_auth
544 %{_bindir}/pdbedit
545 %{_bindir}/smbcquotas
546 %{_bindir}/dbwrap_tool
547 %{_bindir}/dbwrap_torture
548
549 %{_mandir}/man1/ntlm_auth.1*
550 %{_mandir}/man1/profiles.1*
551 %{_mandir}/man1/smbcquotas.1*
552 %{_mandir}/man1/testparm.1*
553 %{_mandir}/man5/smb.conf.5*
554 %{_mandir}/man5/lmhosts.5*
555 %{_mandir}/man8/smbpasswd.8*
556 %{_mandir}/man1/wbinfo.1*
557 %{_mandir}/man8/winbindd.8*
558 %{_mandir}/man8/net.8*
559 %{_mandir}/man8/pam_winbind.8*
560 %{_mandir}/man7/libsmbclient.7*
561 %{_mandir}/man7/winbind_krb5_locator.7*
562 %{_mandir}/man8/idmap_*.8*
563
564
565
566 %changelog
567 * Fri Jan 16 2004 Gerald (Jerry) Carter <jerry@samba,org>
568 - Removed ChangeLog entries since they are kept in CVS
569
570
571