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