1#!/bin/sh 2# 3# Copyright (C) Shirish A Kalele 2000 4# Copyright (C) Gerald Carter 2004 5# 6# script for build solaris Samba package 7# 8 9INSTALL_BASE=/opt/samba 10 11SBINPROGS="smbd nmbd winbindd swat" 12BINPROGS="findsmb nmblookup pdbedit rpcclient smbclient smbcquotas smbspool smbtar tdbbackup testparm wbinfo net ntlm_auth profiles smbcacls smbcontrol smbpasswd smbstatus smbtree tdbdump testprns" 13MSGFILES="de.msg en.msg fr.msg it.msg ja.msg nl.msg pl.msg tr.msg" 14VFSLIBS="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" 15DATFILES="lowcase.dat upcase.dat valid.dat" 16CHARSETLIBS="CP437.so CP850.so" 17 18add_dynamic_entries() 19{ 20 # Add the binaries, docs and SWAT files 21 cd $TMPINSTALLDIR/$INSTALL_BASE 22 23 echo "#\n# Server Binaries \n#" 24 for file in $SBINPROGS; do 25 echo f none sbin/$file 0755 root other 26 done 27 28 echo "#\n# User Binaries \n#" 29 for file in $BINPROGS; do 30 echo f none bin/$file 0755 root other 31 done 32 33 echo "#\n# Libraries\n#" 34 for file in $MSGFILES; do 35 echo f none lib/$file 0644 root other 36 done 37 for file in $DATFILES; do 38 echo f none lib/$file 0644 root other 39 done 40 for file in $VFSLIBS; do 41 echo f none lib/vfs/$file 0755 root other 42 done 43 for file in $CHARSETLIBS; do 44 echo f none lib/charset/$file 0755 root other 45 done 46 47 echo "#\n# libsmbclient\n#" 48 echo f none lib/libsmbclient.so 0755 root other 49 echo f none include/libsmbclient.h 0644 root other 50 51 if [ -f lib/smbwrapper.so -a -f bin/smbsh ]; then 52 echo "#\n# smbwrapper\n#" 53 echo f none lib/smbwrapper.so 0755 root other 54 echo f none bin/smbsh 0755 root other 55 fi 56 57 echo "#\n# nss_winbind.so\n#" 58 echo f none /lib/nss_winbind.so.1=lib/nss_winbind.so.1 0755 root other 59 # echo s none /lib/nss_winbind.so.1=/usr/lib/nss_winbind.so.1 0755 root other 60 if [ -f lib/pam_winbind.so ]; then 61 echo f none /usr/lib/security/pam_winbind.so=lib/pam_winbind.so 0755 root other 62 fi 63 64 echo "#\n# man pages \n#" 65 66 # Create directories for man page sections if nonexistent 67 cd man 68 for i in 1 2 3 4 5 6 7 8 9; do 69 manpages=`ls man$i 2>/dev/null` 70 if [ $? -eq 0 ]; then 71 echo d none man/man${i} ? ? ? 72 for manpage in $manpages; do 73 echo f none man/man${i}/${manpage} 0644 root other 74 done 75 fi 76 done 77 cd .. 78 79 echo "#\n# SWAT \n#" 80 list=`find swat -type d | grep -v "/.svn$"` 81 for dir in $list; do 82 if [ -d $dir ]; then 83 echo d none $dir 0755 root other 84 fi 85 done 86 87 list=`find swat -type f | grep -v /.svn/` 88 for file in $list; do 89 if [ -f $file ]; then 90 echo f none $file 0644 root other 91 fi 92 done 93 94 # Create entries for docs for the beginner 95 echo 's none docs/using_samba=$BASEDIR/swat/using_samba' 96 for file in docs/*pdf; do 97 echo f none $file 0644 root other 98 done 99} 100 101##################################################################### 102## BEGIN MAIN 103##################################################################### 104 105# Try to guess the distribution base.. 106DISTR_BASE=`dirname \`pwd\` |sed -e 's@/packaging$@@'` 107echo "Distribution base: $DISTR_BASE" 108 109TMPINSTALLDIR="/tmp/`basename $DISTR_BASE`-build" 110echo "Temp install dir: $TMPINSTALLDIR" 111echo "Install directory: $INSTALL_BASE" 112 113## 114## first build the source 115## 116 117cd $DISTR_BASE/source 118 119if [ "x$1" != "xnobuild" ]; then 120 ./configure --prefix=$INSTALL_BASE \ 121 --with-acl-support \ 122 --with-included-popt \ 123 --localstatedir=/var/lib/samba \ 124 --with-piddir=/var/run \ 125 --with-logfilebase=/var/log/samba \ 126 --with-privatedir=/etc/samba/private \ 127 --with-configdir=/etc/samba \ 128 && make 129 130 if [ $? -ne 0 ]; then 131 echo "Build failed! Exiting...." 132 exit 1 133 fi 134fi 135 136mkdir $TMPINSTALLDIR 137make DESTDIR=$TMPINSTALLDIR install 138 139## clear out *.old 140find $TMPINSTALLDIR -name \*.old |while read x; do rm -rf "$x"; done 141 142## 143## Now get the install locations 144## 145SBINDIR=`bin/smbd -b | grep SBINDIR | awk '{print $2}'` 146BINDIR=`bin/smbd -b | grep BINDIR | grep -v SBINDIR | awk '{print $2}'` 147SWATDIR=`bin/smbd -b | grep SWATDIR | awk '{print $2}'` 148CONFIGFILE=`bin/smbd -b | grep CONFIGFILE | awk '{print $2}'` 149CONFIGDIR=`dirname $CONFIGFILE` 150LOGFILEBASE=`bin/smbd -b | grep LOGFILEBASE | awk '{print $2}'` 151LIBDIR=`bin/smbd -b | grep LIBDIR | awk '{print $2}'` 152PIDDIR=`bin/smbd -b | grep PIDDIR | awk '{print $2}'` 153PRIVATE_DIR=`bin/smbd -b | grep PRIVATE_DIR | awk '{print $2}'` 154DOCDIR=$INSTALL_BASE/docs 155 156## 157## copy some misc files that are ont done as part of 'make install' 158## 159cp -fp nsswitch/libnss_winbind.so $TMPINSTALLDIR/$LIBDIR/nss_winbind.so.1 160if [ -f nsswitch/pam_winbind.so ]; then 161 cp -fp nsswitch/pam_winbind.so $TMPINSTALLDIR/$LIBDIR/pam_winbind.so 162fi 163if [ -f bin/smbwrapper.so ]; then 164 cp -fp bin/smbwrapper.so $TMPINSTALLDIR/$INSTALL_BASE/lib 165fi 166if [ -f bin/smbsh ]; then 167 cp -fp bin/smbsh $TMPINSTALLDIR/$INSTALL_BASE/bin 168fi 169 170mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/docs 171cp -p ../docs/*pdf $TMPINSTALLDIR/$INSTALL_BASE/docs 172 173 174cd $DISTR_BASE/packaging/Solaris 175 176## 177## Main driver 178## 179 180# Setup version from smbd -V 181 182VERSION=`$TMPINSTALLDIR/$SBINDIR/smbd -V | awk '{print $2}'` 183sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master > pkginfo 184 185sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master > inetd.conf 186sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.init.master > samba.init 187 188## 189## copy over some scripts need for packagaing 190## 191mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/scripts 192for i in inetd.conf samba.init smb.conf.default services; do 193 cp -fp $i $TMPINSTALLDIR/$INSTALL_BASE/scripts 194done 195 196## 197## Start building the prototype file 198## 199echo "CONFIGDIR=$CONFIGDIR" >> pkginfo 200echo "LOGFILEBASE=$LOGFILEBASE" >> pkginfo 201echo "PIDDIR=$PIDDIR" >> pkginfo 202echo "PRIVATE_DIR=$PRIVATE_DIR" >> pkginfo 203 204cp prototype.master prototype 205 206# Add the dynamic part to the prototype file 207(add_dynamic_entries >> prototype) 208 209## 210## copy packaging files 211## 212for i in prototype pkginfo copyright preremove postinstall request i.swat r.swat; do 213 cp $i $TMPINSTALLDIR/$INSTALL_BASE 214done 215 216# Create the package 217pkgmk -o -d /tmp -b $TMPINSTALLDIR/$INSTALL_BASE -f prototype 218 219if [ $? = 0 ]; then 220 pkgtrans /tmp samba.pkg samba 221fi 222 223echo The samba package is in /tmp 224