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