packaging(RHEL): fix libdir installation by using _libarch/_libarchdir
[jra/samba/.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-lockdir=/var/lib/samba \
142         --with-logfilebase=/var/log/samba \
143         --with-mandir=%{_mandir} \
144         --with-piddir=/var/run \
145         --with-privatedir=%{_sysconfdir}/samba \
146         --with-sambabook=%{_datadir}/swat/using_samba \
147         --with-swatdir=%{_datadir}/swat \
148         --enable-cups \
149         --with-acl-support \
150         --with-ads \
151         --with-automount \
152         --with-fhs \
153         --with-pam_smbpass \
154         --with-libsmbclient \
155         --with-libsmbsharemodes \
156         --without-smbwrapper \
157         --with-pam \
158         --with-quotas \
159         --with-shared-modules=idmap_rid,idmap_ad \
160         --with-syslog \
161         --with-utmp \
162         --with-dnsupdate
163
164 make showlayout
165
166 ## check for gcc 3.4 or later
167 CC_VERSION=`${CC} --version | head -1 | awk '{print $3}'`
168 CC_MAJOR=`echo ${CC_VERSION} | cut -d. -f 1`
169 CC_MINOR=`echo ${CC_VERSION} | cut -d. -f 2`
170 if [ ${CC_MAJOR} -ge 3 ]; then
171         if [ ${CC_MAJOR} -gt 3 -o ${CC_MINOR} -ge 4 ]; then
172                 make pch
173         fi
174 fi
175
176
177 make CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE" %{?_smp_mflags} \
178         all modules pam_smbpass
179
180 ## build the cifs fs mount helper
181 cd client
182 gcc  -o mount.cifs $RPM_OPT_FLAGS  -D_GNU_SOURCE -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE mount.cifs.c
183 gcc  -o umount.cifs $RPM_OPT_FLAGS  -D_GNU_SOURCE -Wall -D_GNU_SOURCE -D_LARGEFILE64_SOURCE umount.cifs.c
184 cd ..
185
186 # Remove some permission bits to avoid to many dependencies
187 cd ..
188 find examples docs -type f | xargs -r chmod -x
189
190 %install
191 # Clean up in case there is trash left from a previous build
192 rm -rf $RPM_BUILD_ROOT
193
194 # Create the target build directory hierarchy
195 mkdir -p $RPM_BUILD_ROOT%{_datadir}/swat/{help,include,using_samba/{figs,gifsa}}
196 mkdir -p $RPM_BUILD_ROOT%{_includedir}
197 mkdir -p $RPM_BUILD_ROOT%{_initrddir}
198 mkdir -p $RPM_BUILD_ROOT{%{_libarchdir},%{_includedir}}
199 mkdir -p $RPM_BUILD_ROOT%{_libarchdir}/samba/{auth,charset,idmap,vfs,pdb}
200 mkdir -p $RPM_BUILD_ROOT/%{_libarch}/security
201 mkdir -p $RPM_BUILD_ROOT%{_mandir}
202 mkdir -p $RPM_BUILD_ROOT%{_prefix}/{bin,sbin}
203 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
204 mkdir -p $RPM_BUILD_ROOT/sbin
205 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{logrotate.d,pam.d,samba}
206 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{pam.d,logrotate.d}
207 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d
208 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/{samba,sysconfig}
209 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d
210 mkdir -p $RPM_BUILD_ROOT/var/lib/samba/winbindd_privileged
211 mkdir -p $RPM_BUILD_ROOT/var/{log,run/winbindd,spool}/samba
212
213 cd source
214 make DESTDIR=$RPM_BUILD_ROOT \
215         install
216 cd ..
217
218 # NSS & PAM winbind support
219 install -m 755 source/bin/pam_winbind.so $RPM_BUILD_ROOT/%{_libarch}/security/pam_winbind.so
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 # make install puts libsmbclient.so in the wrong place on x86_64
227 rm -f $RPM_BUILD_ROOT/usr/lib*/samba/libsmbclient.so $RPM_BUILD_ROOT/usr/lib*/samba/libsmbclient.a || true
228 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{_libarchdir}/libsmbclient.so
229 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{_libarchdir}/libsmbclient.a
230 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{_includedir}
231 ln -s %{_libarchdir}/libsmbclient.so $RPM_BUILD_ROOT%{_libarchdir}/libsmbclient.so.0
232
233 # make install puts libsmbsharemodes.so in the wrong place on x86_64
234 rm -f $RPM_BUILD_ROOT/usr/lib*/samba/libsmbsharemodes.so $RPM_BUILD_ROOT/usr/lib*/samba/libsmbsharemodes.a || true
235 install -m 755 source/bin/libsmbsharemodes.so $RPM_BUILD_ROOT%{_libarchdir}/libsmbsharemodes.so
236 install -m 755 source/bin/libsmbsharemodes.a $RPM_BUILD_ROOT%{_libarchdir}/libsmbsharemodes.a
237 install -m 644 source/include/smb_share_modes.h $RPM_BUILD_ROOT%{_includedir}
238 rm -f $RPM_BUILD_ROOT%{_libarchdir}/samba/libsmbsharemodes.*
239 ln -s /%{_libdir}/libsmbsharemodes.so $RPM_BUILD_ROOT%{_libarchdir}/libsmbsharemodes.so.0
240
241 # Install pam_smbpass.so
242 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/%{_libarch}/security/pam_smbpass.so
243
244 ## cleanup
245 /bin/rm -rf $RPM_BUILD_ROOT/usr/lib*/samba/security
246
247 # Install the miscellany
248 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT%{_sysconfdir}/samba/lmhosts
249
250 install -m644 setup/samba.log $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/samba
251 install -m644 setup/swat $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/swat
252 install -m644 setup/samba.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/samba
253 install -m755 setup/smb.init $RPM_BUILD_ROOT%{initdir}/smb
254 install -m755 setup/winbind.init $RPM_BUILD_ROOT%{initdir}/winbind
255 install -m644 setup/samba.pamd $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/samba
256 install -m755 setup/smbprint $RPM_BUILD_ROOT%{_bindir}
257 install -m644 setup/smbusers $RPM_BUILD_ROOT%{_sysconfdir}/samba/smbusers
258 install -m644 setup/smb.conf $RPM_BUILD_ROOT%{_sysconfdir}/samba/smb.conf
259 install -m755 source/client/mount.cifs $RPM_BUILD_ROOT/sbin/mount.cifs
260 install -m755 source/client/umount.cifs $RPM_BUILD_ROOT/sbin/umount.cifs
261 install -m755 source/script/mksmbpasswd.sh $RPM_BUILD_ROOT%{_bindir}
262
263 /bin/rm $RPM_BUILD_ROOT%{_sbindir}/*mount.cifs
264
265 ln -s ../..%{initdir}/smb  $RPM_BUILD_ROOT%{_sbindir}/samba
266 ln -s ../..%{initdir}/winbind  $RPM_BUILD_ROOT%{_sbindir}/winbind
267
268 # Remove "*.old" files
269 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
270
271 ## don't duplicate the docs.  These are installed by/with SWAT
272 rm -rf docs/htmldocs
273 rm -rf docs/manpages
274 ( cd docs; ln -s %{_prefix}/share/swat/help htmldocs )
275
276 ##
277 ## Clean out man pages for tools not installed here
278 ##
279 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
280 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
281 rm -f $RPM_BUILD_ROOT%{_mandir}/man5/vfstest.1*
282
283
284 %clean
285 rm -rf $RPM_BUILD_ROOT
286
287 %post
288 ## deal with an upgrade from a broken 3.0.21b RPM
289 if [ "$1" -eq "2" ]; then
290         if [ -d /var/cache/samba ]; then
291                 for file in `ls /var/cache/samba/*tdb`; do
292                         /bin/cp -up $file /var/lib/samba/`basename $file`
293                 done
294                 mkdir -p /var/lib/samba/eventlog
295                 for file in `ls /var/cache/samba/eventlog/*tdb`; do
296                         /bin/cp -up $file /var/lib/samba/eventlog/`basename $file`
297                 done
298                 /bin/mv /var/cache/samba /var/cache/samba.moved
299         fi
300 fi
301
302 %preun
303 if [ $1 = 0 ] ; then
304     /sbin/chkconfig --del smb
305     /sbin/chkconfig --del winbind
306     # rm -rf /var/log/samba/* /var/lib/samba/*
307     /sbin/service smb stop >/dev/null 2>&1
308 fi
309 exit 0
310
311 %postun
312 if [ "$1" -ge "1" ]; then
313         %{initdir}/smb restart >/dev/null 2>&1
314 fi      
315
316
317 %post swat
318 # Add swat entry to /etc/services if not already there.
319 if [ ! "`grep ^\s**swat /etc/services`" ]; then
320         echo 'swat        901/tcp     # Add swat service used via inetd' >> /etc/services
321 fi
322
323 %post common
324 /sbin/ldconfig
325
326 %postun common 
327 /sbin/ldconfig
328
329 #######################################################################
330 ## Files section                                                     ##
331 #######################################################################
332
333 %files
334 %defattr(-,root,root)
335
336 %config(noreplace) %{_sysconfdir}/sysconfig/samba
337 %config(noreplace) %{_sysconfdir}/samba/smbusers
338 %attr(755,root,root) %config %{initdir}/smb
339 %attr(755,root,root) %config %{initdir}/winbind
340 %config(noreplace) %{_sysconfdir}/logrotate.d/samba
341 %config(noreplace) %{_sysconfdir}/pam.d/samba
342
343 %attr(0755,root,root) %dir /var/log/samba
344 %attr(0755,root,root) %dir /var/lib/samba
345 %attr(1777,root,root) %dir /var/spool/samba
346
347 %{_sbindir}/samba
348 %{_sbindir}/winbind
349
350 %{_sbindir}/smbd
351 %{_sbindir}/nmbd
352 %{_sbindir}/winbindd
353
354 %{_bindir}/mksmbpasswd.sh
355 %{_bindir}/smbcontrol
356 %{_bindir}/smbstatus
357 %{_bindir}/tdbbackup
358 %{_bindir}/tdbtool
359 %{_bindir}/tdbdump
360 %{_bindir}/wbinfo
361 %{_bindir}/ntlm_auth
362 %{_bindir}/pdbedit
363 %{_bindir}/eventlogadm
364
365 %{_libarchdir}/samba/idmap/*.so
366 %{_libarchdir}/samba/nss_info/*.so
367 %{_libarchdir}/samba/vfs/*.so
368 %{_libarchdir}/samba/auth/*.so
369
370 %{_mandir}/man1/smbcontrol.1*
371 %{_mandir}/man1/smbstatus.1*
372 %{_mandir}/man1/vfstest.1*
373 %{_mandir}/man5/smbpasswd.5*
374 %{_mandir}/man7/samba.7*
375 %{_mandir}/man8/nmbd.8*
376 %{_mandir}/man8/pdbedit.8*
377 %{_mandir}/man8/smbd.8*
378 %{_mandir}/man8/tdbbackup.8*
379 %{_mandir}/man8/tdbdump.8*
380 %{_mandir}/man8/tdbtool.8*
381 %{_mandir}/man8/eventlogadm.8*
382 %{_mandir}/man8/winbindd.8*
383 %{_mandir}/man1/ntlm_auth.1*
384 %{_mandir}/man1/wbinfo.1*
385 %{_mandir}/man8/vfs_*.8*
386 %{_mandir}/man8/idmap_*.8*
387
388
389 ##########
390
391 %files doc
392 %defattr(-,root,root)
393 %doc README COPYING Manifest 
394 %doc WHATSNEW.txt Roadmap
395 %doc docs
396 %doc examples/autofs examples/LDAP examples/libsmbclient examples/misc examples/printer-accounting
397 %doc examples/printing
398 %doc %{_datadir}/swat/help
399 %doc %{_datadir}/swat/using_samba
400
401 ##########
402
403 %files swat
404 %defattr(-,root,root)
405 %config(noreplace) %{_sysconfdir}/xinetd.d/swat
406 %dir %{_datadir}/swat
407 %{_datadir}/swat/include
408 %{_datadir}/swat/images
409 %{_datadir}/swat/lang
410 %{_sbindir}/swat
411 %{_mandir}/man8/swat.8*
412
413 ##########
414
415 %files client
416 %defattr(-,root,root)
417 /sbin/mount.smb
418 /sbin/mount.smbfs
419 /sbin/mount.cifs
420 /sbin/umount.cifs
421
422 %{_bindir}/rpcclient
423 %{_bindir}/smbcacls
424 %{_bindir}/smbmnt
425 %{_bindir}/smbumount
426 %{_bindir}/findsmb
427 %{_bindir}/smbcquotas
428 %{_bindir}/nmblookup
429 %{_bindir}/smbget
430 %{_bindir}/smbclient
431 %{_bindir}/smbprint
432 %{_bindir}/smbspool
433 %{_bindir}/smbtar
434 %{_bindir}/net
435 %{_bindir}/smbtree
436
437 %{_mandir}/man8/mount.cifs.8.*
438 %{_mandir}/man8/umount.cifs.8.*
439 %{_mandir}/man8/smbspool.8*
440 %{_mandir}/man1/smbget.1*
441 %{_mandir}/man5/smbgetrc.5*
442 %{_mandir}/man1/findsmb.1*
443 %{_mandir}/man1/nmblookup.1*
444 %{_mandir}/man1/rpcclient.1*
445 %{_mandir}/man1/smbcacls.1*
446 %{_mandir}/man1/smbclient.1*
447 %{_mandir}/man1/smbtar.1*
448 %{_mandir}/man1/smbtree.1*
449 %{_mandir}/man8/net.8*
450 %{_mandir}/man1/smbcquotas.1*
451
452 ##########
453
454 %files common
455 %defattr(-,root,root)
456 %dir %{_sysconfdir}/samba
457 %config(noreplace) %{_sysconfdir}/samba/smb.conf
458 %config(noreplace) %{_sysconfdir}/samba/lmhosts
459
460 %attr(755,root,root) /%{_libarch}/libnss_wins.so*
461 %attr(755,root,root) /%{_libarch}/libnss_winbind.so*
462 %attr(755,root,root) /%{_libarch}/security/pam_winbind.so
463 %attr(755,root,root) /%{_libarch}/security/pam_smbpass.so
464
465 %{_includedir}/libsmbclient.h
466 %{_libarchdir}/libsmbclient.*
467 %{_includedir}/smb_share_modes.h
468 %{_libarchdir}/libsmbsharemodes.*
469
470 %{_libarchdir}/samba/*.dat
471 %{_libarchdir}/samba/*.msg
472 %{_libarchdir}/samba/charset/*.so
473
474 %{_bindir}/testparm
475 %{_bindir}/smbpasswd
476 %{_bindir}/profiles
477
478 %{_mandir}/man1/profiles.1*
479 %{_mandir}/man1/testparm.1*
480 %{_mandir}/man5/smb.conf.5*
481 %{_mandir}/man5/lmhosts.5*
482 %{_mandir}/man8/smbpasswd.8*
483 %{_mandir}/man7/libsmbclient.7*
484 %{_mandir}/man7/pam_winbind.7*
485
486 %changelog
487 * Fri Jan 16 2004 Gerald (Jerry) Carter <jerry@samba,org>
488 - Removed ChangeLog entries since they are kept in CVS
489
490
491