| 1 |
#!/bin/bash -x |
| 2 |
|
| 3 |
# run configure and make |
| 4 |
scripts/build-solaris.sh || exit 1 |
| 5 |
|
| 6 |
MAKE=/opt/csw/bin/gmake |
| 7 |
|
| 8 |
# verify that configure has been run |
| 9 |
if ! [ -f solaris/pkginfo ]; |
| 10 |
then |
| 11 |
echo "Can't find solaris/pkginfo. Please run configure." |
| 12 |
exit 1 |
| 13 |
fi |
| 14 |
|
| 15 |
# Extract information about the package from pkginfo |
| 16 |
# This information is needed to create the filename |
| 17 |
# and for other purposes |
| 18 |
PKGSNAME=`grep '^PKG=' solaris/pkginfo | cut -f2 -d=` |
| 19 |
PKGNAME=`grep '^NAME=' solaris/pkginfo | cut -f2 -d= | cut -f1 -d' '` |
| 20 |
PKGVERSION=`grep '^VERSION=' solaris/pkginfo | cut -f2- -d= | tr ' ' '_' ` |
| 21 |
BASEDIR=`grep '^BASEDIR=' solaris/pkginfo | cut -f2 -d=` |
| 22 |
PKGARCH=`grep '^ARCH=' solaris/pkginfo | cut -f2 -d=` |
| 23 |
|
| 24 |
PKGFILENAME=${PKGNAME}-${PKGVERSION}-${PKGARCH}.pkg |
| 25 |
|
| 26 |
# Prepare a directory for DESTDIR |
| 27 |
INST_TMP=`pwd`/inst_tmp |
| 28 |
rm -rf "${ISNT_TMP}" || exit 1 |
| 29 |
mkdir -p "${ISNT_TMP}" || exit 1 |
| 30 |
|
| 31 |
# Prepare a directory for holding the output of pkgmk |
| 32 |
PKG_TMP=`pwd`/pkg_tmp |
| 33 |
rm -rf "${PKG_TMP}" || exit 1 |
| 34 |
mkdir -p "${PKG_TMP}" || exit 1 |
| 35 |
|
| 36 |
# Install the files to our working directory |
| 37 |
${MAKE} DESTDIR="${INST_TMP}" install || exit 1 |
| 38 |
|
| 39 |
# Install some stuff that is not installed by make |
| 40 |
cp -f contrib/ganglia_gmond.xml "${INST_TMP}"/gmond.xml || exit 1 |
| 41 |
cp -f gmond/gmond.solaris.init "${INST_TMP}/gmond.init" || exit 1 |
| 42 |
cp -f gmond/modules/conf.d/modgstatus.conf "${INST_TMP}" || exit 1 |
| 43 |
cp -f gmond/modules/conf.d/modpython.conf "${INST_TMP}" || exit 1 |
| 44 |
cp -f gmond/python_modules/conf.d/example.pyconf "${INST_TMP}/example.pyconf.disabled" || exit 1 |
| 45 |
|
| 46 |
# Generate a config file if necessary |
| 47 |
if [ -f gmond/gmond.conf.solaris ]; |
| 48 |
then |
| 49 |
cp -f gmond/gmond.conf.solaris "${INST_TMP}/gmond.conf" || exit 1 |
| 50 |
else |
| 51 |
gmond/gmond -t > "${INST_TMP}/gmond.conf" || exit 1 |
| 52 |
fi |
| 53 |
|
| 54 |
# Build a prototype file |
| 55 |
SOLARIS_PKG=`pwd`/solaris |
| 56 |
cat > "${INST_TMP}/prototype" << EOF |
| 57 |
i pkginfo=${SOLARIS_PKG}/pkginfo |
| 58 |
i checkinstall=${SOLARIS_PKG}/checkinstall |
| 59 |
i preinstall=${SOLARIS_PKG}/preinstall |
| 60 |
i postinstall=${SOLARIS_PKG}/postinstall |
| 61 |
i preremove=${SOLARIS_PKG}/preremove |
| 62 |
i i.nonsmf=${SOLARIS_PKG}/i.nonsmf |
| 63 |
i i.smf=${SOLARIS_PKG}/i.smf |
| 64 |
i depend=${SOLARIS_PKG}/depend |
| 65 |
f nonsmf /etc/init.d/gmond=${INST_TMP}/gmond.init 0755 root bin |
| 66 |
l nonsmf /etc/rc0.d/K15gmond=../init.d/gmond |
| 67 |
l nonsmf /etc/rc1.d/K15gmond=../init.d/gmond |
| 68 |
l nonsmf /etc/rc2.d/K15gmond=../init.d/gmond |
| 69 |
l nonsmf /etc/rc3.d/S30gmond=../init.d/gmond |
| 70 |
l nonsmf /etc/rcS.d/K15gmond=../init.d/gmond |
| 71 |
d none etc 0755 root root |
| 72 |
f none etc/gmond.conf=${INST_TMP}/gmond.conf 0644 root root |
| 73 |
d none etc/conf.d 0755 root root |
| 74 |
f none etc/conf.d/modpython.conf=${INST_TMP}/modpython.conf 0644 root root |
| 75 |
f none etc/conf.d/example.pyconf.disabled=${INST_TMP}/example.pyconf.disabled 0644 root root |
| 76 |
f none etc/conf.d/modgstatus.conf=${INST_TMP}/modgstatus.conf 0644 root root |
| 77 |
d smf var 0755 root root |
| 78 |
d smf var/svc 0755 root root |
| 79 |
d smf var/svc/manifest 0755 root root |
| 80 |
d smf var/svc/manifest/ganglia 0755 root root |
| 81 |
f smf var/svc/manifest/ganglia/gmond.xml=${INST_TMP}/gmond.xml 0755 root root |
| 82 |
d smf lib/svc 0755 root root |
| 83 |
d smf lib/svc/method 0755 root root |
| 84 |
f smf lib/svc/method/svc-gmond=${INST_TMP}/gmond.init 0755 root root |
| 85 |
EOF |
| 86 |
|
| 87 |
(cd inst_tmp/usr/local ; find . | pkgproto | sed -e 's/em_pocod other$/root bin/' ) >> "${INST_TMP}/prototype" || exit 1 |
| 88 |
|
| 89 |
# Prepare a package |
| 90 |
(cd "${INST_TMP}" ; pkgmk \ |
| 91 |
-b "${INST_TMP}/${BASEDIR}" \ |
| 92 |
-f "${INST_TMP}/prototype" \ |
| 93 |
-d "${PKG_TMP}" ) || exit 1 |
| 94 |
|
| 95 |
# Bundle the package data into a single file |
| 96 |
pkgtrans -s ${PKG_TMP} `pwd`/${PKGFILENAME} ${PKGSNAME} || exit 1 |
| 97 |
|
| 98 |
# Compress the package for distribution |
| 99 |
gzip -f ${PKGFILENAME} |
| 100 |
|