summaryrefslogtreecommitdiff
path: root/packaging/Solaris/makepkg.sh
blob: 2d599fca9b76060f4b24da78c14fe2b171ffeb90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/sh
#
# Copyright (C) Shirish A Kalele 2000
# Copyright (C) Gerald Carter    2004
#
# script for build solaris Samba package
#

INSTALL_BASE=/opt/samba

SBINPROGS="smbd nmbd winbindd swat"
BINPROGS="findsmb nmblookup eventlogadm pdbedit rpcclient smbclient smbcquotas smbspool smbtar tdbbackup testparm wbinfo net ntlm_auth profiles smbcacls smbcontrol smbpasswd smbstatus smbtree tdbdump"
MSGFILES="de.msg en.msg fr.msg it.msg ja.msg nl.msg pl.msg tr.msg"
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"
DATFILES="lowcase.dat upcase.dat valid.dat"
CHARSETLIBS="CP437.so CP850.so"
AUTHLIBS="script.so"

add_dynamic_entries() 
{
	# Add the binaries, docs and SWAT files
	cd $TMPINSTALLDIR/$INSTALL_BASE

	echo "#\n# Server Binaries \n#"	
 	for file in $SBINPROGS; do
		echo f none sbin/$file 0755 root other
	done

	echo "#\n# User Binaries \n#"
 	for file in $BINPROGS; do
		echo f none bin/$file 0755 root other
	done
	
	echo "#\n# Libraries\n#"
 	for file in $MSGFILES; do
		echo f none lib/$file 0644 root other
	done
 	for file in $DATFILES; do
		echo f none lib/$file 0644 root other
	done
 	for file in $VFSLIBS; do
		echo f none lib/vfs/$file 0755 root other
	done
 	for file in $CHARSETLIBS; do
		echo f none lib/charset/$file 0755 root other
	done
 	for file in $AUTHLIBS; do
		echo f none lib/auth/$file 0755 root other
	done
	
	echo "#\n# libsmbclient\n#"
	echo f none lib/libsmbclient.so 0755 root other
	echo f none lib/libsmbclient.a 0755 root other
	echo f none include/libsmbclient.h 0644 root other

	echo "#\n# libmsrpc\n#"
	echo f none lib/libmsrpc.so 0755 root other
	echo f none lib/libmsrpc.a 0755 root other
	echo f none include/libmsrpc.h 0644 root other

	if [ -f lib/smbwrapper.so -a -f bin/smbsh ]; then
		echo "#\n# smbwrapper\n#"
		echo f none lib/smbwrapper.so 0755 root other
		echo f none bin/smbsh 0755 root other
	fi

	echo "#\n# nss_winbind.so and nss_wins.so\n#"
	echo f none /lib/nss_winbind.so.1=lib/nss_winbind.so.1 0755 root other
	echo f none /lib/nss_wins.so.1=lib/nss_wins.so.1 0755 root other
	# echo s none /lib/nss_winbind.so.1=/usr/lib/nss_winbind.so.1 0755 root other
	# echo s none /lib/nss_wins.so.1=/usr/lib/nss_wins.so.1 0755 root other
	if [ -f lib/pam_winbind.so ]; then
		echo f none /usr/lib/security/pam_winbind.so=lib/pam_winbind.so 0755 root other
	fi

	echo "#\n# man pages \n#"

	# Create directories for man page sections if nonexistent
	cd man
	for i in 1 2 3 4 5 6 7 8 9; do
		manpages=`ls man$i 2>/dev/null`
		if [ $? -eq 0 ]; then
			echo d none man/man${i} ? ? ?
			for manpage in $manpages; do
				echo f none man/man${i}/${manpage} 0644 root other
			done
		fi
	done
	cd ..

	echo "#\n# SWAT \n#"
	list=`find swat -type d | grep -v "/.svn$"`
	for dir in $list; do
		if [ -d $dir ]; then
			echo d none $dir 0755 root other
		fi
	done

	list=`find swat -type f | grep -v /.svn/`
	for file in $list; do
		if [ -f $file ]; then
			echo f none $file 0644 root other
		fi
	done

	# Create entries for docs for the beginner
	echo 's none docs/using_samba=$BASEDIR/swat/using_samba'
	for file in docs/*pdf; do
		echo f none $file 0644 root other
	done
}

#####################################################################
## BEGIN MAIN 
#####################################################################

# Try to guess the distribution base..
DISTR_BASE=`dirname \`pwd\` |sed -e 's@/packaging$@@'`
echo "Distribution base:  $DISTR_BASE"

TMPINSTALLDIR="/tmp/`basename $DISTR_BASE`-build"
echo "Temp install dir:   $TMPINSTALLDIR"
echo "Install directory:  $INSTALL_BASE"

##
## first build the source
##

cd $DISTR_BASE/source

if [ "x$1" != "xnobuild" ]; then
	./configure --prefix=$INSTALL_BASE \
		--with-acl-support \
		--with-included-popt \
		--localstatedir=/var/lib/samba \
		--with-piddir=/var/run \
		--with-logfilebase=/var/log/samba \
		--with-privatedir=/etc/samba/private \
		--with-configdir=/etc/samba \
	&& make

	if [ $? -ne 0 ]; then
		echo "Build failed!  Exiting...."
		exit 1
	fi
fi
	
mkdir $TMPINSTALLDIR
make DESTDIR=$TMPINSTALLDIR install

## clear out *.old
find $TMPINSTALLDIR -name \*.old |while read x; do rm -rf "$x"; done
 
##
## Now get the install locations
##
SBINDIR=`bin/smbd -b | grep SBINDIR | awk '{print $2}'`
BINDIR=`bin/smbd -b | grep BINDIR | grep -v SBINDIR |  awk '{print $2}'`
SWATDIR=`bin/smbd -b | grep SWATDIR | awk '{print $2}'`
CONFIGFILE=`bin/smbd -b | grep CONFIGFILE | awk '{print $2}'`
LOCKDIR=`bin/smbd -b | grep LOCKDIR | awk '{print $2}'`
CONFIGDIR=`dirname $CONFIGFILE`
LOGFILEBASE=`bin/smbd -b | grep LOGFILEBASE | awk '{print $2}'`
LIBDIR=`bin/smbd -b | grep LIBDIR | awk '{print $2}'`
PIDDIR=`bin/smbd -b | grep PIDDIR | awk '{print $2}'`
PRIVATE_DIR=`bin/smbd -b | grep PRIVATE_DIR | awk '{print $2}'`
DOCDIR=$INSTALL_BASE/docs

## 
## copy some misc files that are not done as part of 'make install'
##
cp -fp nsswitch/libnss_wins.so $TMPINSTALLDIR/$LIBDIR/nss_wins.so.1
cp -fp nsswitch/libnss_winbind.so $TMPINSTALLDIR/$LIBDIR/nss_winbind.so.1
if [ -f nsswitch/pam_winbind.so ]; then
	cp -fp nsswitch/pam_winbind.so $TMPINSTALLDIR/$LIBDIR/pam_winbind.so
fi
if [ -f bin/smbwrapper.so ]; then
	cp -fp bin/smbwrapper.so $TMPINSTALLDIR/$INSTALL_BASE/lib
fi
if [ -f bin/smbsh ]; then
	cp -fp bin/smbsh $TMPINSTALLDIR/$INSTALL_BASE/bin
fi

mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/docs
cp -p ../docs/*pdf $TMPINSTALLDIR/$INSTALL_BASE/docs


cd $DISTR_BASE/packaging/Solaris

##
## Main driver 
##

# Setup version from smbd -V

VERSION=`$TMPINSTALLDIR/$SBINDIR/smbd -V | awk '{print $2}'`
sed -e "s|__VERSION__|$VERSION|" -e "s|__ARCH__|`uname -p`|" -e "s|__BASEDIR__|$INSTALL_BASE|g" pkginfo.master > pkginfo

sed -e "s|__BASEDIR__|$INSTALL_BASE|g" inetd.conf.master   > inetd.conf
sed -e "s|__BASEDIR__|$INSTALL_BASE|g" samba.init.master > samba.init

##
## copy over some scripts need for packagaing
##
mkdir -p $TMPINSTALLDIR/$INSTALL_BASE/scripts
for i in inetd.conf samba.init smb.conf.default services; do
	cp -fp $i $TMPINSTALLDIR/$INSTALL_BASE/scripts
done

##
## Start building the prototype file
##
echo "CONFIGDIR=$CONFIGDIR" >> pkginfo
echo "LOGFILEBASE=$LOGFILEBASE" >> pkginfo
echo "LOCKDIR=$LOCKDIR" >> pkginfo
echo "PIDDIR=$PIDDIR" >> pkginfo
echo "PRIVATE_DIR=$PRIVATE_DIR" >> pkginfo

cp prototype.master prototype

# Add the dynamic part to the prototype file
(add_dynamic_entries >> prototype)

##
## copy packaging files 
##
for i in prototype pkginfo copyright preremove postinstall request i.swat r.swat; do
	cp $i $TMPINSTALLDIR/$INSTALL_BASE
done

# Create the package
pkgmk -o -d /tmp -b $TMPINSTALLDIR/$INSTALL_BASE -f prototype

if [ $? = 0 ]; then
	pkgtrans /tmp samba.pkg samba
fi

echo The samba package is in /tmp