r11166: missed a specfile fix for redhat
[nivanova/samba-autobuild/.git] / packaging / RedHat / samba.spec.tmpl
1 ## grab the major and minor version of rpm 
2 %define rpm_version `rpm --version | awk '{print $3}' | awk -F. '{print $1$2}'`
3
4 Summary: Samba SMB client and server
5 Vendor: Samba Team
6 Name: samba
7 Version: PVERSION
8 Release: PRELEASE
9 License: GNU GPL version 2
10 Group: Networking
11 Source: http://download.samba.org/samba/ftp/samba-%{version}.tar.bz2
12
13 # Don't depend on Net::LDAP
14 # one filter for RH 8 and one for 9
15 Source998: filter-requires-samba_rh8.sh
16 Source999: filter-requires-samba_rh9.sh
17
18 Packager: Gerald Carter [Samba-Team] <jerry@samba.org>
19 Requires: pam openldap krb5-libs cups
20 BuildRequires: openldap-devel krb5-devel pam-devel cups-devel
21 Prereq: chkconfig fileutils /sbin/ldconfig
22 Provides: samba = %{version}
23 Obsoletes: samba-common, samba-client, samba-swat
24 BuildRoot: %{_tmppath}/%{name}-%{version}-root
25 Prefix: /usr
26
27 %description
28 Samba provides an SMB/CIFS server which can be used to provide
29 network file and print services to SMB/CIFS clients, including 
30 various versions of MS Windows, OS/2, and other Linux machines. 
31 Samba also provides some SMB clients, which complement the 
32 built-in SMB filesystem in Linux. Samba uses NetBIOS over TCP/IP 
33 (NetBT) protocols and does NOT need NetBEUI (Microsoft Raw NetBIOS 
34 frame) protocol.
35
36 Samba 3.0 also introduces UNICODE support and kerberos/ldap
37 integration as a member server in a Windows 2000 domain.
38
39 Please refer to the WHATSNEW.txt document for fixup information.
40 docs directory for implementation details.
41
42 %changelog
43 * Mon Nov 18 2002 Gerald Carter <jerry@samba.org>
44   - removed change log entries since history
45     is being maintained in CVS
46
47 %prep
48 %setup
49
50 %build
51
52 # Working around perl dependency problem from docs
53 # Only > RH 8.0 seems to care here
54
55 echo "rpm_version == %{rpm_version}"
56 if [ "%{rpm_version}" == "42" ]; then
57    %define __perl_requires %{SOURCE999}
58    echo "%{__perl_requires}"
59 elif [ "%{rpm_version}" == "41" ]; then
60    %define __find_requires %{SOURCE998}
61    echo "%{__find_requires}"
62 fi
63
64 ## Build main Samba source
65 cd source
66
67 %ifarch ia64
68 libtoolize --copy --force     # get it to recognize IA-64
69 autoheader
70 autoconf
71 EXTRA="-D_LARGEFILE64_SOURCE"
72 %endif
73
74 ## Get number of cpu's, default for 1 cpu on error 
75 NUMCPU=`grep processor /proc/cpuinfo | wc -l`
76 if [ $NUMCPU -eq 0 ]; then
77         NUMCPU=1;
78 fi 
79
80 ## run autogen if missing the configure script
81 if [ ! -f "configure" ]; then
82         ./autogen.sh
83 fi
84
85 CFLAGS="$RPM_OPT_FLAGS $EXTRA" ./configure \
86         --prefix=%{prefix} \
87         --localstatedir=/var \
88         --with-configdir=/etc/samba \
89         --with-privatedir=/etc/samba \
90         --with-fhs \
91         --with-quotas \
92         --with-smbmount \
93         --enable-cups \
94         --with-pam \
95         --with-pam_smbpass \
96         --with-syslog \
97         --with-utmp \
98         --with-sambabook=%{prefix}/share/swat/using_samba \
99         --with-swatdir=%{prefix}/share/swat \
100         --with-shared-modules=idmap_rid \
101         --with-libsmbclient 
102 make -j${NUMCPU} proto
103 make -j${NUMCPU} all modules nsswitch/libnss_wins.so 
104 make -j${NUMCPU} debug2html
105
106 # Remove some permission bits to avoid to many dependencies
107 cd ..
108 find examples docs -type f | xargs -r chmod -x
109
110 %install
111 rm -rf $RPM_BUILD_ROOT
112 mkdir -p $RPM_BUILD_ROOT
113 mkdir -p $RPM_BUILD_ROOT/sbin
114 mkdir -p $RPM_BUILD_ROOT/etc/samba
115 mkdir -p $RPM_BUILD_ROOT/etc/{logrotate.d,pam.d,samba}
116 mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
117 mkdir -p $RPM_BUILD_ROOT%{prefix}/{bin,sbin}
118 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/{help,include,using_samba}
119 mkdir -p $RPM_BUILD_ROOT%{prefix}/share/swat/using_samba/{figs,gifs}
120 mkdir -p $RPM_BUILD_ROOTMANDIR_MACRO
121 mkdir -p $RPM_BUILD_ROOT/var/lib/samba
122 mkdir -p $RPM_BUILD_ROOT/var/{log,run}/samba
123 mkdir -p $RPM_BUILD_ROOT/var/spool/samba
124 mkdir -p $RPM_BUILD_ROOT/lib/security
125 mkdir -p $RPM_BUILD_ROOT%{prefix}/lib/samba/vfs
126 mkdir -p $RPM_BUILD_ROOT%{prefix}/{lib,include}
127
128 # Install standard binary files
129 for i in nmblookup smbclient smbpasswd smbstatus testparm \
130         rpcclient smbspool smbcacls smbcontrol wbinfo smbmnt net \
131         smbcacls pdbedit eventlogadm tdbbackup smbtree ntlm_auth smbcquotas
132 do
133         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/bin
134 done
135
136 for i in mksmbpasswd.sh smbtar findsmb
137 do
138         install -m755 source/script/$i $RPM_BUILD_ROOT%{prefix}/bin
139 done
140
141 # Install secure binary files
142 for i in smbd nmbd swat smbmount smbumount debug2html winbindd 
143 do
144         install -m755 source/bin/$i $RPM_BUILD_ROOT%{prefix}/sbin
145 done
146
147 # we need a symlink for mount to recognise the smb and smbfs filesystem types
148 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smbfs
149 ln -sf %{prefix}/sbin/smbmount $RPM_BUILD_ROOT/sbin/mount.smb
150
151 # This allows us to get away without duplicating code that 
152 #  sombody else can maintain for us.  
153 cd source
154 make DESTDIR=$RPM_BUILD_ROOT \
155         BASEDIR=/usr \
156         CONFIGDIR=/etc/samba \
157         LIBDIR=%{prefix}/lib/samba \
158         VARDIR=/var \
159         SBINDIR=%{prefix}/sbin \
160         BINDIR=%{prefix}/bin \
161         MANDIR=MANDIR_MACRO \
162         SWATDIR=%{prefix}/share/swat \
163         SAMBABOOK=%{prefix}/share/swat/using_samba \
164         installman installswat installdat installmodules
165 cd ..
166
167 ## don't duplicate the docs.  These are installed with SWAT
168 rm -rf docs/htmldocs
169 rm -rf docs/manpages
170 ( cd docs; ln -s %{prefix}/share/swat/help htmldocs )
171
172
173
174 # Install the nsswitch wins library
175 install -m755 source/nsswitch/libnss_wins.so $RPM_BUILD_ROOT/lib
176 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_wins.so libnss_wins.so.2 )
177
178 # Install winbind shared libraries
179 install -m755 source/nsswitch/libnss_winbind.so $RPM_BUILD_ROOT/lib
180 ( cd $RPM_BUILD_ROOT/lib; ln -sf libnss_winbind.so libnss_winbind.so.2 )
181 install -m755 source/nsswitch/pam_winbind.so $RPM_BUILD_ROOT/lib/security
182
183 # Install pam_smbpass.so
184 install -m755 source/bin/pam_smbpass.so $RPM_BUILD_ROOT/lib/security
185
186 # libsmbclient
187 install -m 755 source/bin/libsmbclient.so $RPM_BUILD_ROOT%{prefix}/lib/
188 install -m 755 source/bin/libsmbclient.a $RPM_BUILD_ROOT%{prefix}/lib/
189 install -m 644 source/include/libsmbclient.h $RPM_BUILD_ROOT%{prefix}/include/
190
191 # libmsrpc
192 install -m 755 source/bin/libmsrpc.so $RPM_BUILD_ROOT%{prefix}/lib/
193 install -m 755 source/bin/libmsrpc.a $RPM_BUILD_ROOT%{prefix}/lib/
194 install -m 644 source/include/libmsrpc.h $RPM_BUILD_ROOT%{prefix}/include/
195
196 # Install the miscellany
197 install -m755 packaging/RedHat/smbprint $RPM_BUILD_ROOT%{prefix}/bin
198 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT/etc/rc.d/init.d/smb
199 install -m755 packaging/RedHat/winbind.init $RPM_BUILD_ROOT/etc/rc.d/init.d/winbind
200 install -m755 packaging/RedHat/smb.init $RPM_BUILD_ROOT%{prefix}/sbin/samba
201 install -m644 packaging/RedHat/samba.log $RPM_BUILD_ROOT/etc/logrotate.d/samba
202 install -m644 packaging/RedHat/smb.conf $RPM_BUILD_ROOT/etc/samba/smb.conf
203 install -m644 packaging/RedHat/smbusers $RPM_BUILD_ROOT/etc/samba/smbusers
204 install -m644 packaging/RedHat/samba.pamd $RPM_BUILD_ROOT/etc/pam.d/samba
205 install -m644 packaging/RedHat/samba.pamd.stack $RPM_BUILD_ROOT/etc/samba/samba.stack
206 install -m644 packaging/RedHat/samba.xinetd $RPM_BUILD_ROOT/etc/samba/samba.xinetd
207 echo 127.0.0.1 localhost > $RPM_BUILD_ROOT/etc/samba/lmhosts
208
209 # Remove "*.old" files
210 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
211
212 ##
213 ## Clean out man pages for tools not installed here
214 ##
215 rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/editreg.1*
216 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/log2pcap.1*
217 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbsh.1*
218 rm -f $RPM_BUILD_ROOT%{_mandir}/man1/smbget.1*
219 rm -f $RPM_BUILD_ROOT/%{_mandir}/man8/mount.cifs.8*
220
221
222 %clean
223 rm -rf $RPM_BUILD_ROOT
224
225 %post
226 ## 
227 ## only needed if this is a new install (not an upgrade)
228 ##
229 if [ "$1" -eq "1" ]; then
230         /sbin/chkconfig --add smb
231         /sbin/chkconfig --add winbind
232         /sbin/chkconfig smb off
233         /sbin/chkconfig winbind off
234 fi
235
236 ##
237 ## we only have to wory about this if we are upgrading
238 ##
239 if [ "$1" -eq "2" ]; then
240         if [ -f /etc/smb.conf -a ! -f /etc/samba/smb.conf ]; then
241                 echo "Moving old /etc/smb.conf to /etc/samba/smb.conf"
242                 mv /etc/smb.conf /etc/samba/smb.conf
243         fi
244
245         if [ -f /etc/smbusers -a ! -f /etc/samba/smbusers ]; then
246                 echo "Moving old /etc/smbusers to /etc/samba/smbusers"
247                 mv /etc/smbusers /etc/samba/smbusers
248         fi
249
250         if [ -f /etc/lmhosts -a ! -f /etc/samba/lmhosts ]; then
251                 echo "Moving old /etc/lmhosts to /etc/samba/lmhosts"
252                 mv /etc/lmhosts /etc/samba/lmhosts
253         fi
254
255         if [ -f /etc/MACHINE.SID -a ! -f /etc/samba/MACHINE.SID ]; then
256                 echo "Moving old /etc/MACHINE.SID to /etc/samba/MACHINE.SID"
257                 mv /etc/MACHINE.SID /etc/samba/MACHINE.SID
258         fi
259
260         if [ -f /etc/smbpasswd -a ! -f /etc/samba/smbpasswd ]; then
261                 echo "Moving old /etc/smbpasswd to /etc/samba/smbpasswd"
262                 mv /etc/smbpasswd /etc/samba/smbpasswd
263         fi
264
265         #
266         # For 2.2.1 we move the tdb files from /var/lock/samba to /var/cache/samba
267         # to preserve across reboots.
268         #
269         for i in /var/lock/samba/*.tdb; do
270                 if [ -f $i ]; then
271                         newname="/var/lib/samba/`basename $i`"
272                         echo "Moving $i to $newname"
273                         mv $i $newname
274                 fi
275         done
276
277         #
278         # For 3.0.1 we move the tdb files from /var/cache/samba to /var/lib/samba
279         #
280         echo "Moving tdb files in /var/cache/samba/*.tdb to /var/lib/samba/*.tdb"
281         for i in /var/cache/samba/*.tdb; do
282                 if [ -f $i ]; then
283                         newname="/var/lib/samba/`basename $i`"
284                         echo "Moving $i to $newname"
285                         mv $i $newname
286                 fi
287         done
288 fi
289
290 ##
291 ## New things
292 ##
293
294 # Add swat entry to /etc/services if not already there.
295 if [ ! "`grep ^\s**swat /etc/services`" ]; then
296         echo 'swat              901/tcp                         # Add swat service used via inetd' >> /etc/services
297 fi
298
299 # Add swat entry to /etc/inetd.conf if needed.
300 if [ -f /etc/inetd.conf ]; then
301         if [ ! "`grep ^\s*swat /etc/inetd.conf`" ]; then
302                 echo 'swat      stream  tcp     nowait.400      root    %{prefix}/sbin/swat swat' >> /etc/inetd.conf
303         killall -HUP inetd || :
304         fi
305 fi
306
307 # Add swat entry to xinetd.d if needed.
308 if [ -d /etc/xinetd.d -a ! -f /etc/xinetd.d/swat ]; then
309         mv /etc/samba/samba.xinetd /etc/xinetd.d/swat
310 else
311         rm -f /etc/samba/samba.xinetd
312 fi
313
314 # Install the correct version of the samba pam file
315 if [ -f /lib/security/pam_stack.so ]; then
316         echo "Installing stack version of /etc/pam.d/samba..."
317         mv /etc/samba/samba.stack /etc/pam.d/samba
318 else
319         echo "Installing non-stack version of /etc/pam.d/samba..."
320         rm -f /etc/samba/samba.stack
321 fi
322
323 ## call ldconfig to create the version symlink for libsmbclient.so
324 /sbin/ldconfig
325
326 %preun
327 if [ "$1" -eq "0" ] ; then
328         /sbin/chkconfig --del smb
329         /sbin/chkconfig --del winbind
330
331         # We want to remove the browse.dat and wins.dat files 
332         # so they can not interfer with a new version of samba!
333         if [ -e /var/lib/samba/browse.dat ]; then
334                 rm -f /var/lib/samba/browse.dat
335         fi
336         if [ -e /var/lib/samba/wins.dat ]; then
337                 rm -f /var/lib/samba/wins.dat
338         fi
339
340         # Remove the transient tdb files.
341         if [ -e /var/lib/samba/brlock.tdb ]; then
342                 rm -f /var/lib/samba/brlock.tdb
343         fi
344
345         if [ -e /var/lib/samba/unexpected.tdb ]; then
346                 rm -f /var/lib/samba/unexpected.tdb
347         fi
348
349         if [ -e /var/lib/samba/connections.tdb ]; then
350                 rm -f /var/lib/samba/connections.tdb
351         fi
352
353         if [ -e /var/lib/samba/locking.tdb ]; then
354                 rm -f /var/lib/samba/locking.tdb
355         fi
356
357         if [ -e /var/lib/samba/messages.tdb ]; then
358                 rm -f /var/lib/samba/messages.tdb
359         fi
360 fi
361
362 %postun
363 # Only delete remnants of samba if this is the final deletion.
364 if [ "$1" -eq  "0" ] ; then
365     if [ -x /etc/pam.d/samba ]; then
366       rm -f /etc/pam.d/samba
367     fi
368
369     if [ -e /var/log/samba ]; then
370       rm -rf /var/log/samba
371     fi
372
373     if [ -e /var/lib/samba ]; then
374       rm -rf /var/lib/samba
375     fi
376
377     # Remove swat entries from /etc/inetd.conf and /etc/services
378     cd /etc
379     tmpfile=/etc/tmp.$$
380     if [ -f /etc/inetd.conf ]; then
381       # preserve inetd.conf permissions.
382       cp -p /etc/inetd.conf $tmpfile
383       sed -e '/^[:space:]*swat.*$/d' /etc/inetd.conf > $tmpfile
384       mv $tmpfile inetd.conf
385     fi
386
387     # preserve services permissions.
388     cp -p /etc/services $tmpfile
389     sed -e '/^[:space:]*swat.*$/d' /etc/services > $tmpfile
390     mv $tmpfile /etc/services
391
392     # Remove swat entry from /etc/xinetd.d
393     if [ -f /etc/xinetd.d/swat ]; then
394       rm -r /etc/xinetd.d/swat
395     fi
396 fi
397
398 /sbin/ldconfig
399
400 %files
401 %defattr(-,root,root)
402 %doc README COPYING Manifest Read-Manifest-Now
403 %doc WHATSNEW.txt Roadmap
404 %doc docs
405 %doc examples
406 %{prefix}/sbin/smbd
407 %{prefix}/sbin/nmbd
408 %{prefix}/sbin/swat
409 %{prefix}/bin/smbmnt
410 %{prefix}/sbin/smbmount
411 %{prefix}/sbin/smbumount
412 %{prefix}/sbin/winbindd
413 %{prefix}/sbin/samba
414 %{prefix}/sbin/debug2html
415 /sbin/mount.smbfs
416 /sbin/mount.smb
417 %{prefix}/bin/mksmbpasswd.sh
418 %{prefix}/bin/smbclient
419 %{prefix}/bin/smbspool
420 %{prefix}/bin/rpcclient
421 %{prefix}/bin/testparm
422 %{prefix}/bin/findsmb
423 %{prefix}/bin/smbstatus
424 %{prefix}/bin/nmblookup
425 %{prefix}/bin/smbpasswd
426 %{prefix}/bin/smbtar
427 %{prefix}/bin/smbprint
428 %{prefix}/bin/smbcontrol
429 %{prefix}/bin/wbinfo
430 %{prefix}/bin/net
431 %{prefix}/bin/ntlm_auth
432 %{prefix}/bin/smbcquotas
433 %{prefix}/bin/smbcacls
434 %{prefix}/bin/pdbedit
435 %{prefix}/bin/eventlogadm
436 %{prefix}/bin/tdbbackup
437 %{prefix}/bin/smbtree
438 %attr(755,root,root) /lib/libnss_wins.s*
439 %attr(755,root,root) %{prefix}/lib/samba/vfs/*.so
440 %attr(755,root,root) %{prefix}/lib/samba/charset/*.so
441 %attr(755,root,root) %{prefix}/lib/samba/idmap/*.so
442 #%attr(755,root,root) %{prefix}/lib/samba/pdb/*.so
443 %attr(755,root,root) %{prefix}/lib/samba/*.dat
444 %attr(755,root,root) %{prefix}/lib/samba/*.msg
445 %{prefix}/include/libsmbclient.h
446 %{prefix}/lib/libsmbclient.a
447 %{prefix}/lib/libsmbclient.so
448 %{prefix}/include/libmsrpc.h
449 %{prefix}/lib/libmsrpc.a
450 %{prefix}/lib/libmsrpc.so
451 %{prefix}/share/swat/help/*
452 %{prefix}/share/swat/include/*.html
453 %{prefix}/share/swat/lang/*/help/*
454 %{prefix}/share/swat/using_samba/*
455 %config(noreplace) /etc/samba/lmhosts
456 %config(noreplace) /etc/samba/smb.conf
457 %config(noreplace) /etc/samba/smbusers
458 /etc/samba/samba.stack
459 /etc/samba/samba.xinetd
460 /etc/rc.d/init.d/smb
461 /etc/rc.d/init.d/winbind
462 /etc/logrotate.d/samba
463 %config(noreplace) /etc/pam.d/samba
464 MANDIR_MACRO/man1/*
465 MANDIR_MACRO/man5/*
466 MANDIR_MACRO/man7/*
467 MANDIR_MACRO/man8/*
468 %attr(755,root,root) %dir /var/lib/samba
469 %dir /var/log/samba
470 %dir /var/run/samba
471 %attr(1777,root,root) %dir /var/spool/samba
472 %attr(-,root,root) /lib/libnss_winbind.so*
473 %attr(-,root,root) /lib/security/pam_winbind.so
474 %attr(-,root,root) /lib/security/pam_smbpass.so