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