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