IGNOREPATH=/home:/dev:/boot:/root:/tmp:/usr/local:/bin:/tmp:/var
STRIPLIB=y
STRIPBIN=y

VERSION=2.2.8a
PROGNAME="samba $VERSION"
DESC="\
Samba is a Unix based SMB file and print server.  This allows a Unix   \n\
host to act as a file and print server for SMB clients.  This includes \n\
Lan-Manager compatible clients such as LanManager for DOS, Windows     \n\
95/98/NT/2000, OS/2, Pathworks and many more.  If you have any PCs     \n\
running SMB clients, such as a PC running Windows98, then you can      \n\
mount file space or printers from a Linux host, so that directories,   \n\
files and printers on the Linux host are available on the Windows PC."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.samba.org/pub/samba
PKGNAME=samba-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   tar -yxvf $CWD/samba-$VERSION.tar.bz2
   cd samba-$VERSION/
   chown -R root.root .
   find . -perm 664 | xargs chmod 644

   cd source/
   ./configure --with-fhs \
               --enable-cups \
               --prefix=/usr \
               --localstatedir=/var \
               --bindir=/usr/bin \
               --sbindir=/usr/sbin \
               --with-lockdir=/var/cache/samba \
               --sysconfdir=/etc \
               --with-configdir=/etc/samba \
               --with-privatedir=/etc/samba/private \
               --with-codepagedir=/etc/codepages \
               --with-smbmount \
               --with-quotas \
               --with-syslog \
               --with-utmp \
               --with-sambabook=/usr/share/swat/using_samba \
               --with-ssl \
               --with-sslinc=/usr/include/openssl \
               --with-ssllib=/usr \
               --with-msdfs \
               --with-vfs \
               --with-libsmbclient \
               s390-slackware-linux
   make
}

install() {
   mkdir -p /usr/share/samba/codepages \
            /usr/doc/samba-$VERSION/swat \
            /etc/samba/private

   make install

   # Make sure libsmbclient gets installed:
   if [ -r bin/libsmbclient.so ]; then
     cp -a bin/libsmbclient.so /usr/lib/libsmbclient.so.0.0
     chown root.root /usr/lib/libsmbclient.so.0.0
     chmod 755 /usr/lib/libsmbclient.so.0.0
     ( cd /usr/lib
       rm -f libsmbclient.so.0 libsmbclient.so
       ln -sf libsmbclient.so.0.0 libsmbclient.so.0
       ln -sf libsmbclient.so.0.0 libsmbclient.so )
     cp -a include/libsmbclient.h /usr/include/libsmbclient.h
     chown root.root /usr/include/libsmbclient.h
     chmod 644 /usr/include/libsmbclient.h
   fi

   rmdir /usr/private /usr/share/samba/codepages

   cp $CWD/smb.conf-sample /etc/samba/smb.conf-sample

   # We'll add rc.samba to the init directory, but chmod 644 so that it doesn't
   # start by default:
   mkdir -p /etc/rc.d
   cat $CWD/rc.samba > /etc/rc.d/rc.samba.new

   cd ..
   cp -r COPYING Manifest README Read-Manifest-Now \
         Roadmap WHATSNEW.txt docs examples /usr/doc/samba-$VERSION
   cp swat/README /usr/doc/samba-$VERSION/swat
   ( cd /usr/doc/samba-$VERSION/docs/htmldocs
     rm -rf using_samba
     ln -sf /usr/share/samba/swat/using_samba .
   )

   ( cd /sbin ; rm -rf mount.smbfs )
   ( cd /sbin ; ln -sf /usr/bin/smbmount mount.smbfs )
}

attributes() {
   chmod 755 $PKG/usr/doc/samba-$VERSION/docs/docbook/configure* \
             $PKG/usr/doc/samba-$VERSION/examples/VFS/configure*
}

special() {
   cd $PKG
   mkdir -p var/cache/samba/ \
            var/log/samba/ \
            var/run/samba/ \
            var/spool/samba/

   chmod 700 etc/samba/private
   chmod 1777 var/spool/samba/
 
   cd $CTL
   cat $CWD/slack-desc > slack-desc

   cat $CWD/config.sh >> doinst.sh
   cat << EOF >> doinst.sh
config etc/rc.d/rc.samba.new
# This won't be needed.  The point here is to preserve the permissions of the existing
# file, if there is one.  I don't see major new development happening in rc.samba...  ;-)
rm -f etc/rc.d/rc.samba.new
EOF
}
