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