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