r3399: a few more packaging fixes
[kai/samba.git] / packaging / Solaris / makepkg.sh
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
9 INSTALL_BASE=/opt/samba
10
11 SBINPROS="smbd nmbd winbindd swat"
12 BINPROGS="findsmb nmblookup pdbedit rpcclient smbclient smbcquotas smbspool smbtar tdbbackup testparm wbinfo net ntlm_auth profiles smbcacls smbcontrol smbpasswd smbstatus smbtree tdbdump testprns"
13 MSGFILES="de.msg en.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
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 $DATFILES; do
41                 echo f none lib/$file 0644 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         echo "#\n# nss_winbind.so\n#"
52         echo f none /usr/lib/nss_winbind.so.1=lib/libnss_winbind.so 0755 root other
53         echo s none /lib/nss_winbind.so.1=../usr/lib/nss_winbind.so.1 0755 root other
54         if [ -f lib/pam_winbind.so ]; then
55                 echo f none /usr/lib/security/pam_winbind.so=lib/pam_winbind.so 0755 root other
56         fi
57
58         # Add the manpages
59         echo "#\n# man pages \n#"
60         echo d none /usr ? ? ?
61         echo d none /usr/share ? ? ?
62         echo d none /usr/share/man ? ? ?
63
64         # Create directories for man page sections if nonexistent
65         cd man
66         for i in 1 2 3 4 5 6 7 8 9; do
67                 manpages=`ls *.$i 2>/dev/null`
68                 if [ $? -eq 0 ]; then
69                         echo d none /usr/share/man/man$i ? ? ?
70                         for manpage in $manpages; do
71                                 echo f none /usr/share/man/man${i}/${manpage}=docs/manpages/$manpage 0644 root other
72                         done
73                 fi
74         done
75         cd ..
76
77         echo "#\n# SWAT \n#"
78         list=`find swat -type d | grep -v "/.svn$"`
79         for dir in $list; do
80                 if [ -d $dir ]; then
81                         echo d none $dir 0755 root other
82                 fi
83         done
84
85         list=`find swat -type f | grep -v /.svn/`
86         for file in $list; do
87                 if [ -f $file ]; then
88                         echo f none $file 0644 root other
89                 fi
90         done
91
92         # Create entries for docs for the beginner
93         echo s none docs/using_samba=$BASEDIR/swat/help/using_samba
94         for file in docs/*pdf; do
95                 echo f none $file 0644 root other
96         done
97 }
98
99 #####################################################################
100 ## BEGIN MAIN 
101 #####################################################################
102
103 TMPINSTALLDIR=$HOME/build
104
105 # Try to guess the distribution base..
106 CURR_DIR=`pwd`
107 DISTR_BASE=`echo $CURR_DIR | sed 's|\(.*\)/packaging.*|\1|'`
108 echo "Assuming Samba distribution is rooted at $DISTR_BASE.."
109
110 ##
111 ## first build the source
112 ##
113
114 cd $DISTR_BASE/source
115
116 if [ "x$1" != "xnobuild" ]; then
117         ./configure --prefix=$INSTALL_DIR \
118                 --with-acl-support \
119                 --with-included-popt \
120                 --localstatedir=/var/lib/samba \
121                 --with-piddir=/var/run \
122                 --with-logfilebase=/var/log/samba \
123                 --with-privatedir=/etc/samba/private \
124                 --with-configdir=/etc/samba \
125         && make
126
127         if [ $? -ne 0 ]; then
128                 echo "Build failed!  Exiting...."
129                 exit 1
130         fi
131 fi
132         
133 make DESTDIR=$TMPINSTALLDIR install
134
135 ## clear out *.old
136 ( cd $TMPINSTALLDIR; du -a | grep \.old$ | awk '{print "rm -rf "$2}' | sh )
137
138  
139 ##
140 ## Now get the install locations
141 ##
142 SBINDIR=`bin/smbd -b | grep SBINDIR | awk '{print $2}'`
143 BINDIR=`bin/smbd -b | grep BINDIR | grep -v SBINDIR |  awk '{print $2}'`
144 SWATDIR=`bin/smbd -b | grep SWATDIR | awk '{print $2}'`
145 CONFIGFILE=`bin/smbd -b | grep CONFIGFILE | awk '{print $2}'`
146 CONFIGDIR=`dirname $CONFIGFILE`
147 LOGFILEBASE=`bin/smbd -b | grep LOGFILEBASE | awk '{print $2}'`
148 LIBDIR=`bin/smbd -b | grep LIBDIR | awk '{print $2}'`
149 PIDDIR=`bin/smbd -b | grep PIDDIR | awk '{print $2}'`
150 PRIVATE_DIR=`bin/smbd -b | grep PRIVATE_DIR | awk '{print $2}'`
151 DOCDIR=$INSTALL_BASE/docs
152
153 ## 
154 ## copy some misc files that are ont done as part of 'make install'
155 ##
156 cp -fp nsswitch/libnss_winbind.so $TMPINSTALLDIR/$LIBDIR/libnss_winbind.so
157 if [ -f nsswitch/pam_winbind.so ]; then
158         cp -fp nsswitch/pam_winbind.so $TMPINSTALLDIR/$LIBDIR/pam_winbind.so
159 fi
160
161 mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/docs
162 cp -p ../docs/*pdf $TMPINSTALLDIR/$INSTALL_BASE/docs
163
164
165 cd $DISTR_BASE/packaging/Solaris
166
167 ##
168 ## Main driver 
169 ##
170
171 # Setup version from smbd -V
172
173 VERSION=`$TMPINSTALLDIR/$SBINDIR/smbd -V | awk '{print $2}'`
174 sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master > pkginfo
175
176 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master   > inetd.conf
177 sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.init.master > samba.init
178
179 ##
180 ## copy over some scripts need for packagaing
181 ##
182 mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/scripts
183 for i in inetd.conf samba.init smb.conf.default services; do
184         cp -fp $i $TMPINSTALLDIR/$INSTALL_BASE/scripts
185 done
186
187 ##
188 ## Start building the prototype file
189 ##
190 echo "SBINDIR=sbin" >> pkginfo
191 echo "BINDIR=bin" >> pkginfo
192 echo "SWATDIR=swat" >> pkginfo
193 echo "CONFIGDIR=$CONFIGDIR" >> pkginfo
194 echo "LOGFILEBASE=$LOGFILEBASE" >> pkginfo
195 echo "LIBDIR=lib" >> pkginfo
196 echo "PIDDIR=$PIDDIR" >> pkginfo
197 echo "DOCDIR=docs" >> pkginfo
198 echo "PRIVATE_DIR=$PRIVATE_DIR" >> pkginfo
199
200 cp prototype.master prototype
201
202 # Add the dynamic part to the prototype file
203 (add_dynamic_entries >> prototype)
204
205 ##
206 ## copy packaging files 
207 ##
208 for i in prototype pkginfo copyright preremove postinstall request i.swat r.swat; do
209         cp $i $TMPINSTALLDIR/$INSTALL_BASE
210 done
211
212 # Create the package
213 pkgmk -o -d /tmp -b $TMPINSTALLDIR/$INSTALL_BASE -f prototype
214
215 if [ $? = 0 ]; then
216         pkgtrans /tmp samba.pkg samba
217 fi
218
219 echo The samba package is in /tmp