#!/bin/sh
#
# Copyright (C) Shirish A Kalele 2000
+# Copyright (C) Gerald Carter 2004
#
-# Builds a Samba package from the samba distribution.
-# By default, the package will be built to install samba in /usr/local
-# Change the INSTALL_BASE variable to change this: will modify the pkginfo
-# and samba.server files to point to the new INSTALL_BASE
+# script for build solaris Samba package
#
-INSTALL_BASE=/usr/local
+
+INSTALL_BASE=/opt/samba
+
+SBINPROGS="smbd nmbd winbindd swat"
+BINPROGS="findsmb nmblookup eventlogadm pdbedit rpcclient smbclient smbcquotas smbspool smbtar tdbbackup testparm wbinfo net ntlm_auth profiles smbcacls smbcontrol smbpasswd smbstatus smbtree tdbdump"
+MSGFILES="de.msg en.msg fr.msg it.msg ja.msg nl.msg pl.msg tr.msg"
+VFSLIBS="audit.so default_quota.so extd_audit.so full_audit.so readonly.so shadow_copy.so cap.so expand_msdfs.so fake_perms.so netatalk.so recycle.so"
+DATFILES="lowcase.dat upcase.dat valid.dat"
+CHARSETLIBS="CP437.so CP850.so"
+AUTHLIBS="script.so"
add_dynamic_entries()
{
- # First build the codepages and append codepage entries to prototype
- echo "#\n# Codepages \n#"
- echo d none samba/lib/codepages 0755 root other
-
- CODEPAGELIST="437 737 850 852 861 932 866 949 950 936"
- # Check if make_smbcodepage exists
- if [ ! -f $DISTR_BASE/source/bin/make_smbcodepage ]; then
- echo "Could not find $DISTR_BASE/source/bin/make_smbcodepage to generate codepages.\n\
- Please create the binaries before packaging." >&2
- exit 1
- fi
-
- for p in $CODEPAGELIST; do
- $DISTR_BASE/source/bin/make_smbcodepage c $p $DISTR_BASE/source/codepages/codepage_def.$p $DISTR_BASE/source/codepages/codepage.$p
- echo f none samba/lib/codepages/codepage.$p=source/codepages/codepage.$p 0644 root other
- done
-
- # Add the binaries, docs and SWAT files
-
- echo "#\n# Binaries \n#"
- cd $DISTR_BASE/source/bin
- for binfile in *
- do
- if [ -f $binfile ]; then
- echo f none samba/bin/$binfile=source/bin/$binfile 0755 root other
- fi
- done
- echo "#\n# HTML documentation \n#"
- echo d none samba/docs/htmldocs 0755 root other
- cd $DISTR_BASE/docs/htmldocs
- for htmldoc in *
- do
- if [ -f $htmldoc ]; then
- echo f none samba/docs/htmldocs/$htmldoc=docs/htmldocs/$htmldoc 0644 root other
- fi
- done
- echo "#\n# Text Docs \n#"
- echo d none samba/docs/textdocs 0755 root other
- cd $DISTR_BASE/docs/textdocs
- for textdoc in *
- do
- if [ -f $textdoc ]; then
- echo f none samba/docs/textdocs/$textdoc=docs/textdocs/$textdoc 0644 root other
- fi
- done
- echo "#\n# SWAT \n#"
- cd $DISTR_BASE
- list=`find swat -type d`
- for i in $list
- do
- echo "d none samba/$i 0755 root other"
- done
- list=`find swat -type f`
- for i in $list
- do
- echo "f none samba/$i=$i 0644 root other"
- done
- echo "#\n# HTML documentation for SWAT\n#"
- cd $DISTR_BASE/docs/htmldocs
- for htmldoc in *
- do
- if [ -f $htmldoc ]; then
- echo f none samba/swat/help/$htmldoc=docs/htmldocs/$htmldoc 0644 root other
- fi
- done
+ # Add the binaries, docs and SWAT files
+ cd $TMPINSTALLDIR/$INSTALL_BASE
+
+ echo "#\n# Server Binaries \n#"
+ for file in $SBINPROGS; do
+ echo f none sbin/$file 0755 root other
+ done
+
+ echo "#\n# User Binaries \n#"
+ for file in $BINPROGS; do
+ echo f none bin/$file 0755 root other
+ done
+
+ echo "#\n# Libraries\n#"
+ for file in $MSGFILES; do
+ echo f none lib/$file 0644 root other
+ done
+ for file in $DATFILES; do
+ echo f none lib/$file 0644 root other
+ done
+ for file in $VFSLIBS; do
+ echo f none lib/vfs/$file 0755 root other
+ done
+ for file in $CHARSETLIBS; do
+ echo f none lib/charset/$file 0755 root other
+ done
+ for file in $AUTHLIBS; do
+ echo f none lib/auth/$file 0755 root other
+ done
+
+ echo "#\n# libsmbclient\n#"
+ echo f none lib/libsmbclient.so 0755 root other
+ echo f none lib/libsmbclient.a 0755 root other
+ echo f none include/libsmbclient.h 0644 root other
+
+ echo "#\n# libmsrpc\n#"
+ echo f none lib/libmsrpc.so 0755 root other
+ echo f none lib/libmsrpc.a 0755 root other
+ echo f none include/libmsrpc.h 0644 root other
+
+ if [ -f lib/smbwrapper.so -a -f bin/smbsh ]; then
+ echo "#\n# smbwrapper\n#"
+ echo f none lib/smbwrapper.so 0755 root other
+ echo f none bin/smbsh 0755 root other
+ fi
+
+ echo "#\n# nss_winbind.so and nss_wins.so\n#"
+ echo f none /lib/nss_winbind.so.1=lib/nss_winbind.so.1 0755 root other
+ echo f none /lib/nss_wins.so.1=lib/nss_wins.so.1 0755 root other
+ # echo s none /lib/nss_winbind.so.1=/usr/lib/nss_winbind.so.1 0755 root other
+ # echo s none /lib/nss_wins.so.1=/usr/lib/nss_wins.so.1 0755 root other
+ if [ -f lib/pam_winbind.so ]; then
+ echo f none /usr/lib/security/pam_winbind.so=lib/pam_winbind.so 0755 root other
+ fi
+
+ echo "#\n# man pages \n#"
+ # Create directories for man page sections if nonexistent
+ cd man
+ for i in 1 2 3 4 5 6 7 8 9; do
+ manpages=`ls man$i 2>/dev/null`
+ if [ $? -eq 0 ]; then
+ echo d none man/man${i} ? ? ?
+ for manpage in $manpages; do
+ echo f none man/man${i}/${manpage} 0644 root other
+ done
+ fi
+ done
+ cd ..
+
+ echo "#\n# SWAT \n#"
+ list=`find swat -type d | grep -v "/.svn$"`
+ for dir in $list; do
+ if [ -d $dir ]; then
+ echo d none $dir 0755 root other
+ fi
+ done
+
+ list=`find swat -type f | grep -v /.svn/`
+ for file in $list; do
+ if [ -f $file ]; then
+ echo f none $file 0644 root other
+ fi
+ done
+
+ # Create entries for docs for the beginner
+ echo 's none docs/using_samba=$BASEDIR/swat/using_samba'
+ for file in docs/*pdf; do
+ echo f none $file 0644 root other
+ done
}
-if [ $# = 0 ]
-then
- # Try to guess the distribution base..
- CURR_DIR=`pwd`
- DISTR_BASE=`echo $CURR_DIR | sed 's|\(.*\)/packaging.*|\1|'`
- echo "Assuming Samba distribution is rooted at $DISTR_BASE.."
-else
- DISTR_BASE=$1
-fi
+#####################################################################
+## BEGIN MAIN
+#####################################################################
-#
-if [ ! -d $DISTR_BASE ]; then
- echo "Source build directory $DISTR_BASE does not exist."
- exit 1
+# Try to guess the distribution base..
+DISTR_BASE=`dirname \`pwd\` |sed -e 's@/packaging$@@'`
+echo "Distribution base: $DISTR_BASE"
+
+TMPINSTALLDIR="/tmp/`basename $DISTR_BASE`-build"
+echo "Temp install dir: $TMPINSTALLDIR"
+echo "Install directory: $INSTALL_BASE"
+
+##
+## first build the source
+##
+
+cd $DISTR_BASE/source
+
+if [ "x$1" != "xnobuild" ]; then
+ ./configure --prefix=$INSTALL_BASE \
+ --with-acl-support \
+ --with-included-popt \
+ --localstatedir=/var/lib/samba \
+ --with-piddir=/var/run \
+ --with-logfilebase=/var/log/samba \
+ --with-privatedir=/etc/samba/private \
+ --with-configdir=/etc/samba \
+ && make
+
+ if [ $? -ne 0 ]; then
+ echo "Build failed! Exiting...."
+ exit 1
+ fi
fi
+
+mkdir $TMPINSTALLDIR
+make DESTDIR=$TMPINSTALLDIR install
-# Set up the prototype file from prototype.master
-if [ -f prototype ]; then
- rm prototype
+## clear out *.old
+find $TMPINSTALLDIR -name \*.old |while read x; do rm -rf "$x"; done
+
+##
+## Now get the install locations
+##
+SBINDIR=`bin/smbd -b | grep SBINDIR | awk '{print $2}'`
+BINDIR=`bin/smbd -b | grep BINDIR | grep -v SBINDIR | awk '{print $2}'`
+SWATDIR=`bin/smbd -b | grep SWATDIR | awk '{print $2}'`
+CONFIGFILE=`bin/smbd -b | grep CONFIGFILE | awk '{print $2}'`
+LOCKDIR=`bin/smbd -b | grep LOCKDIR | awk '{print $2}'`
+CONFIGDIR=`dirname $CONFIGFILE`
+LOGFILEBASE=`bin/smbd -b | grep LOGFILEBASE | awk '{print $2}'`
+LIBDIR=`bin/smbd -b | grep LIBDIR | awk '{print $2}'`
+PIDDIR=`bin/smbd -b | grep PIDDIR | awk '{print $2}'`
+PRIVATE_DIR=`bin/smbd -b | grep PRIVATE_DIR | awk '{print $2}'`
+DOCDIR=$INSTALL_BASE/docs
+
+##
+## copy some misc files that are not done as part of 'make install'
+##
+cp -fp nsswitch/libnss_wins.so $TMPINSTALLDIR/$LIBDIR/nss_wins.so.1
+cp -fp nsswitch/libnss_winbind.so $TMPINSTALLDIR/$LIBDIR/nss_winbind.so.1
+if [ -f nsswitch/pam_winbind.so ]; then
+ cp -fp nsswitch/pam_winbind.so $TMPINSTALLDIR/$LIBDIR/pam_winbind.so
+fi
+if [ -f bin/smbwrapper.so ]; then
+ cp -fp bin/smbwrapper.so $TMPINSTALLDIR/$INSTALL_BASE/lib
fi
+if [ -f bin/smbsh ]; then
+ cp -fp bin/smbsh $TMPINSTALLDIR/$INSTALL_BASE/bin
+fi
+
+mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/docs
+cp -p ../docs/*pdf $TMPINSTALLDIR/$INSTALL_BASE/docs
+
+
+cd $DISTR_BASE/packaging/Solaris
-# Setup version from version.h
-VERSION=`sed 's/#define VERSION \"\(.*\)\"$/\1/' ../../source/include/version.h`
-sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master >pkginfo
+##
+## Main driver
+##
-sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master >inetd.conf
-sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.server.master >samba.server
+# Setup version from smbd -V
+
+VERSION=`$TMPINSTALLDIR/$SBINDIR/smbd -V | awk '{print $2}'`
+sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master > pkginfo
+
+sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master > inetd.conf
+sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.init.master > samba.init
+
+##
+## copy over some scripts need for packagaing
+##
+mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/scripts
+for i in inetd.conf samba.init smb.conf.default services; do
+ cp -fp $i $TMPINSTALLDIR/$INSTALL_BASE/scripts
+done
+
+##
+## Start building the prototype file
+##
+echo "CONFIGDIR=$CONFIGDIR" >> pkginfo
+echo "LOGFILEBASE=$LOGFILEBASE" >> pkginfo
+echo "LOCKDIR=$LOCKDIR" >> pkginfo
+echo "PIDDIR=$PIDDIR" >> pkginfo
+echo "PRIVATE_DIR=$PRIVATE_DIR" >> pkginfo
cp prototype.master prototype
# Add the dynamic part to the prototype file
(add_dynamic_entries >> prototype)
+##
+## copy packaging files
+##
+for i in prototype pkginfo copyright preremove postinstall request i.swat r.swat; do
+ cp $i $TMPINSTALLDIR/$INSTALL_BASE
+done
+
# Create the package
-pkgmk -o -d /tmp -b $DISTR_BASE -f prototype
-if [ $? = 0 ]
-then
+pkgmk -o -d /tmp -b $TMPINSTALLDIR/$INSTALL_BASE -f prototype
+
+if [ $? = 0 ]; then
pkgtrans /tmp samba.pkg samba
fi
+
echo The samba package is in /tmp
-rm -f prototype