diff options
Diffstat (limited to 'dist/net-snmp-solaris-build')
-rw-r--r-- | dist/net-snmp-solaris-build/DEVENV | 44 | ||||
-rw-r--r-- | dist/net-snmp-solaris-build/README | 19 | ||||
-rw-r--r-- | dist/net-snmp-solaris-build/buildpackage-solaris | 182 | ||||
-rwxr-xr-x | dist/net-snmp-solaris-build/elfdepend.sh | 87 |
4 files changed, 332 insertions, 0 deletions
diff --git a/dist/net-snmp-solaris-build/DEVENV b/dist/net-snmp-solaris-build/DEVENV new file mode 100644 index 0000000..b905cae --- /dev/null +++ b/dist/net-snmp-solaris-build/DEVENV @@ -0,0 +1,44 @@ +PREFIX=/opt/OSS +export PREFIX + +PATH=$PREFIX/bin:/usr/bin:/usr/dt/bin:/usr/openwin/bin:/usr/sbin:/usr/ccs/bin:/usr/ucb +export PATH + +LD_LIBRARY_PATH=$PREFIX/lib +LD_RUN_PATH=$LD_LIBRARY_PATH +export LD_LIBRARY_PATH LD_RUN_PATH + +CC=gcc +export CC + +CPPFLAGS="-I$PREFIX/include" +CFLAGS="-mv8 -mtune=ultrasparc" +LDFLAGS="-L$PREFIX/lib -R$PREFIX/lib" +export CPPFLAGS CFLAGS LDFLAGS + +TMP=/tmp +export TMP + +TOP=/ctbto/idc/cicn/source/build/`basename $PREFIX` +export TOP + +SRC=$TOP/dist +export SRC + +WORK=$TOP/work +export WORK + + +# for superpack: + +CHECKLIST=$TOP/Checklist; export CHECKLIST +MAKE=$PREFIX/bin/make +export MAKE + +#CATEGORY=OpenSource; export CATEGORY +#VENDOR="Free Software Foundation"; export VENDOR +BASEDIR=/opt; export BASEDIR +PREFIX=$BASEDIR/`basename $TOP`; export PREFIX +RELEASE_AREA=$TOP/../packages/`/bin/uname -p`/`/bin/uname -r`; export RELEASE_AREA + +umask 022 diff --git a/dist/net-snmp-solaris-build/README b/dist/net-snmp-solaris-build/README new file mode 100644 index 0000000..53e25a6 --- /dev/null +++ b/dist/net-snmp-solaris-build/README @@ -0,0 +1,19 @@ +The "buildpackage-solaris" script does a "one-shot" build +and packaging of an untarred net-snmp distribution +on Solaris without requiring root access. + +The resulting native Solaris package can then be +(automatically) installed/removed using the Solaris +pkgadd(1)/pkgrm(1) commands. + +The script requires customization of your +development environment - see attached file +DEVENV - before it can be used. + + Basic usage: ./buildpackage-solaris distclean + +The script "elfdepend.sh" is required to +determine the dependencies of all built ELF binaries +and libraries to create a "package dependency file" - +see depend(4). + diff --git a/dist/net-snmp-solaris-build/buildpackage-solaris b/dist/net-snmp-solaris-build/buildpackage-solaris new file mode 100644 index 0000000..31f4f0c --- /dev/null +++ b/dist/net-snmp-solaris-build/buildpackage-solaris @@ -0,0 +1,182 @@ +#!/bin/ksh +# +# automatic build (configure/make/package) script +# for NET-SNMP on Solaris +# +# 2004/11 Rewrite to strictly build the package jfrank@fastrieve.com +# 2002/11 Stefan.Radman@CTBTO.ORG + + +# If you define DEBUG, the script will be verbose, and we won't remove temporary files + +#DEBUG=Y +if [ ! -z $DEBUG ]; then + set -x # be verbose +fi + +# TMP is where we are temporarily installing the package to +TMP=`pwd`/pkgroot + +# PKG is the internal and external name for the package +PKG=OSSnet-snmp + +#PREFIX is the top level architecture dependent directory. +# This should be normally determined by configure +#prefix=/opt/${PKG} +prefix=/usr/local + +# VARDIR is the persistent dir from configure +VARDIR=/var/net-snmp + +expandedprefix=${TMP}/${prefix} + +PERL=${PERL:=`which perl`} +MAKE=${MAKE:=`which make`} + +if [ -d ${TMP} ]; then + rm -rf ${TMP}; +fi + +# install to temporary package build root +cd ../.. + +$MAKE install prefix=${expandedprefix} exec_prefix=${expandedprefix} || exit 1 + +# We now have the main software installed, copy over the auxillary files +cd - + +awk /^___snmpd-init.d/,/___EOF/ $0 | grep -v ^___ | sed "s,@prefix@,$prefix,g" >|snmpd-init.d + +# create persistent directory if it does not exist +[ -d $TMP/$VARDIR ] || install -d -m 0755 $TMP/$VARDIR + +# postinstall +LD_LIBRARY_PATH=$TMP$prefix/lib:$LD_LIBRARY_PATH $TMP/$prefix/bin/snmptranslate\ + -M$TMP/$prefix/share/snmp/mibs -m SNMPv2-SMI .1 >&- || exit $? # create MIB index + +# package +version=`../../net-snmp-config --version` +os=`uname -s` +rel=`uname -r` +class=snmp +owner=$LOGNAME +groups | awk '{print $1}' | read group +cat <<== >|pkginfo +PKG="${PKG}" +NAME="net-snmp-$version" +ARCH="`uname -p`" +VERSION="$version, $os $rel, `date +%Y.%m.%d.%H.%M.%S`" +CATEGORY="OpenSource" +DESC="The NET-SNMP Tools and Library" +VENDOR="http://net-snmp.sourceforge.net" +CLASSES="$class" +BASEDIR="$prefix" +== +. ./pkginfo + +echo 'checking dependencies' +unset LD_LIBRARY_PATH # binaries and libraries should have RPATH now +./elfdepend.sh $TMP | grep -v "P *$PKG " >|depend # ignore own package + +echo 'creating prototype file' +cat <<== >|prototype +i pkginfo +i copyright=../../COPYING +#i preinstall=./preinstall-postremove +#i postinstall=./preinstall-postremove +i depend +# set default mode, owner and group +! default 0775 root sys +d snmp /etc 0755 root sys +d snmp /etc/init.d 0755 root sys +f snmp /etc/init.d/snmpd=./snmpd-init.d 0755 root sys +#l snmp /etc/rc2.d/S76snmpd=/etc/init.d/snmpd # not yet +== + +pkgproto -c snmp $TMP=/ |\ +egrep -v '^d .* / |^d .* /var |^d .* /opt |^ .*perllocal.pod=' |\ +sed -e "s/ $owner $group\$//" >> prototype || exit $? +# and ignore top level directories (must pre-exist) + +echo 'creating package' +pkgmk -od . || exit $? +pkgtrans . $PKG-$version-$ARCH-$os$rel.pkg $PKG || exit $? + +# We should really do some cleanup here +if [ -z $DEBUG ]; then + rm -rf snmpd-init.d $PKG $TMP pkginfo prototype depend +fi + +echo "build was successfull" +exit 0 + +# /etc/init/snmpd +# This is packaged inside of buildpackage-solaris because we need to substitute +# in the actual server name. + +___snmpd-init.d___ +#! /bin/sh +# +# start/stop the NET-SNMP master agent (snmpd) +# +# Location: /etc/init.d/snmpd +# /etc/rc3.d/S??snmpd +# +name="NET-SNMP agent" +daemon=@prefix@/sbin/snmpd + +case "$1" in +start) + [ ! -x $daemon ] && echo "ERROR: cannot start $name ($daemon)" && exit 1 + echo "Starting $name ... \c" + PGREP=`which pgrep` + if [ -z $PGREP ]; then + pid=`pgrep -fx $daemon` + else + pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'` + fi + + [ ! -z "$pid" ] && echo "already running with pid $pid." && exit 0 + $daemon && echo "done." + ;; +stop) + echo "Stopping $name ... \c" + PGREP=`which pgrep` + if [ -z $PGREP ]; then + pid=`pgrep -fx $daemon` + else + pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'` + fi + [ ! -z "$pid" ] && (kill $pid && echo "done" ) || echo "not running" + + ;; +status) + echo "$name is \c" + PGREP=`which pgrep` + if [ -z $PGREP ]; then + pid=`pgrep -fx $daemon` + else + pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'` + fi + [ -z "$pid" ] && echo "not running" || echo "running with pid $pid" + ;; +restart) + $0 stop && $0 start + ;; +reload) + echo "Re-initializing $name ...\c" + PGREP=`which pgrep` + if [ -z $PGREP ]; then + pid=`pgrep -fx $daemon` + else + pid=`ps -ef | grep $daemon | grep -v grep | awk '{print $2}'` + fi + [ ! -z "$pid" ] && (kill -HUP $pid && echo "done" ) || echo "not running" + ;; +*) + echo "Usage: $0 { start | stop | status | restart | reload }" + ;; +esac + +exit 0 +___EOF___ diff --git a/dist/net-snmp-solaris-build/elfdepend.sh b/dist/net-snmp-solaris-build/elfdepend.sh new file mode 100755 index 0000000..547c4cc --- /dev/null +++ b/dist/net-snmp-solaris-build/elfdepend.sh @@ -0,0 +1,87 @@ +#!/bin/ksh +# +# elfdepend.sh +# +# given a path, this scripts searches for ELF binaries and libraries +# and generates package dependency file entries according to ther dependencies +# +# Usage: elfdepend <ELF-binary>|<directory> +# +# 2002/11 Stefan.Radman@CTBTO.ORG +# +# /var/sadm/install/contents format: +# +# /dev d none 0775 root sys SUNWcsr SUNWcsd +# path type class mode owner group packages +# /etc/.login f renamenew 0644 root sys 516 37956 904647695 SUNWcsr +# /etc/acct/holidays e preserve 0664 bin bin 289 22090 904647603 SUNWaccr +# path type class mode owner group x x x packages +# /bin=./usr/bin s none SUNWcsr +# path=link type class packages +# /devices/pseudo/clone@0:hme c none 11 7 0600 root sys SUNWcsd +# path type class x x owner mode packages +# +# types e (sed), v (volatile) have same format like type f (file) +# type l (hardlink) has same format like type s (symlink) +# +prog=`basename $0` +LAST_CHANCE=/opt/OSS/lib + +if [ -d "$1" ] ; then + find $1 -type f -exec file {} \; +elif [ -x "$1" ] ; then + file $1 +else + echo 1>&2 "usage: $0 <directory>|<ELF executable>" + exit 1 +fi | awk '$2 == "ELF" { print }' | cut -d: -f1 |\ +while read elf +do + ldd "$elf" | while read lib x path + do + [ -z "$path" ] && continue + if [ "$path" = '(file not found)' ] + then + if [ -x $LAST_CHANCE/$lib ] + then + path="$LAST_CHANCE/$lib" + else + echo "# $prog: $lib $x $path" + continue # not found + fi + fi + echo "$path" + # need symlink handling here - see /usr/platform/SUNW,*/lib/* + done +done | sort -u | while read libpath other +do + [ "$libpath" = "#" ] && echo "$libpath $other" && continue # error message + set -- `grep "^$libpath[ =]" /var/sadm/install/contents | head -1` + path=$1; type=$2 + case $type in + f) # file + shift 9 # first package + ;; + s|l) # link + shift 3 # first package + ;; + '') # not found + echo "# $prog: $libpath is not associated with any package" + continue + ;; + *) # dubious file type + echo "# $prog: path $1 has dubious file type $2" + continue + ;; + esac + set -- `echo $1 | tr : ' '` + echo $1 # strip off classes +done | sort -u | while read pkg other +do + if [ "$pkg" = "#" ] ; then # error message + echo 1>&2 "$other" # goes to stderr + continue + fi + eval `pkgparam -v $pkg PKG NAME` + printf "P %-15s%s\n" "$PKG" "$NAME" +done |