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