#!/bin/ksh # $Id: Build.sh,v 1.5 2005/01/01 01:08:44 elkner Exp $ # source: ftp://ftp.cac.washington.edu/imap/ # license: Apache 2 VERSION=2006c1 SDIR=`dirname $0` if [ "$SDIR" == "." ]; then SDIR=`pwd` fi # 64bit does not work - breaks SSL (returns -1 for server port) PKG_ARCH=v8plus SCRIPTDIR=${SDIR}/../../../etc . ${SCRIPTDIR}/buildfunctions.sh SRC=$SOURCE/email TMPBUILD=$BUILD/imap-$VERSION unset LD_RUN_PATH doPrepare() { #SUNPKGS="SUNWopenssl-libraries SUNWopenssl-include" REQUIRED="LNFopenssl" . ${SCRIPTDIR}/root4build gtar xzf ${SRC}/imap-${VERSION}.tar.Z cd $TMPBUILD for p in ${SDIR}/*.patch ; do gpatch -p1 -b -z .orig <$p done MKFILES=`find src -name Makefile | grep -v osdep | \ grep -v 'src/Makefile' | xargs` echo $MKFILES # don't use the CFLAGS generated for the c-client, i.e. no KPIC flag gsed -i -e 's,`cat $C/CFLAGS`,${L_CFLAGS},g' $MKFILES gsed -i -e "s,^SSLDIR=.*,SSLDIR=/usr/sfw," \ -e 's,^SSLCERTS=.*,SSLCERTS=/etc/ssl/certs,' \ -e 's,^SSLKEYS=.*,SSLKEYS=/etc/ssl/keys,' \ -e "/^SSLLIB=/ s,lib,lib${ARCH_DIR}," \ -e 's,BASECFLAGS=".*",BASECFLAGS=,g' \ -e 's,ACTIVEFILE=/[^[:space:]]*,ACTIVEFILE=/var/news/active,g' \ -e 's,CC=[^[:space:]]*,CC=cc,g' \ -e 's,^LOCKPGM=.*,LOCKPGM=/usr/sbin/mlock,' \ src/osdep/unix/Makefile # gsed -i -e '/long tcpdebug =/ s,NIL,100,' src/osdep/unix/tcp_unix.c } doMake() { cd $TMPBUILD echo "make log goes to $MAKELOG, errors to ${MAKELOG}.errors" echo "y y" | make soc \ EXTRACFLAGS="$L_CFLAGS -KPIC" L_CFLAGS="$L_CFLAGS" \ EXTRALDFLAGS="$L_LDFLAGS" \ IP=6 \ SSLTYPE=unix \ >$MAKELOG 2> ${MAKELOG}.errors } doPackage() { clean_dst $PROTO cd $TMPBUILD # make install: mkdir -p ${PROTO}/usr/bin ${PROTO}/usr/sbin cp -p imapd/imapd ipopd/ipop?d mlock/mlock mtest/mtest \ ${PROTO}/usr/sbin/ cp -p mailutil/mailutil dmail/dmail tmail/tmail ${PROTO}/usr/bin/ mkdir -p ${PROTO}/usr/include/imap chmod 0755 ${PROTO}/usr/include/imap cd c-client cp -R -L 'c-client.h' mail.h imap4r1.h \ rfc822.h linkage.h misc.h smtp.h nntp.h osdep.h env_unix.h \ env.h fs.h ftl.h nl.h tcp.h \ ${PROTO}/usr/include/imap/ cd .. mkdir -p ${PROTO}/usr/lib${ARCH_DIR} # cp -p c-client/c-client.a ${PROTO}/usr/lib/imap-client.a cp -p c-client/libc-client.so.1.0.0 ${PROTO}/usr/lib${ARCH_DIR}/ ( cd ${PROTO}/usr/lib${ARCH_DIR}/ ; \ ln -s libc-client.so.1.0.0 libc-client.so.1; \ ln -s libc-client.so.1 libc-client.so ) mkdir -p ${PROTO}/usr/share/man/man1m ${PROTO}/usr/share/man/man1 for f in ipopd/ipopd.8 imapd/imapd.8 ; do dst="${PROTO}/usr/share/man/man1m/${f##*/}" sed -e 's#/usr/etc/#/usr/sbin/#g' \ -e 's,(8),(1M),g' \ -e '/^\.TH / s,8,1M,' \ ${TMPBUILD}/src/$f >${dst%.8}.1m chmod 644 ${dst%.8}.1m done cd ${PROTO}/usr/share/man/man1m ln -s ipopd.1m popd.1m ln -s ipopd.1m pop3d.1m cd $TMPBUILD cp -p src/mailutil/mailutil.1 src/dmail/dmail.1 src/tmail/tmail.1 \ ${PROTO}/usr/share/man/man1/ gsed -i -e 's,(8),(1M),g' -e 's,(5),(4),g' -e '/binmail/ d' \ ${PROTO}/usr/share/man/man1/* $STRIP ${PROTO}/usr/sbin/* ${PROTO}/usr/bin/* $STRIP -x ${PROTO}/usr/lib/* PATH=${PATH}:/usr/sfw/openssl/bin for cert in imapd pop3d ; do openssl req -newkey rsa:1024 -keyout ${TMPBUILD}/key.lnf \ -nodes -x509 \ -config ${SDIR}/openssl.cnf \ -days 365 -out ${TMPBUILD}/crt.lnf << EOF de SomeState SomeCity SomeOrganization SomeOrganizationalUnit localhost.unknown root@localhost.unknown EOF cat ${TMPBUILD}/key.lnf >${TMPBUILD}/cert.${cert}.pem.lnf echo "" >>${TMPBUILD}/cert.${cert}.pem.lnf cat ${TMPBUILD}/crt.lnf >>${TMPBUILD}/cert.${cert}.pem.lnf done cat<${TMPBUILD}/prototype.lnf !default 0755 bin bin i pkginfo=${SDIR}/pkginfo i postinstall=${SDIR}/postinstall i depend=${SDIR}/depend i i.manifest=${SDIR}/i.manifest i r.manifest=${SCRIPTDIR}/r.manifest i copyright=${TMPBUILD}/NOTICE d none /etc ? ? ? d none /etc/ssl ? ? ? d none /etc/ssl/certs ? ? ? d none /etc/ssl/keys 0700 root mail f none /etc/ssl/certs/imapd.pem.default=${TMPBUILD}/cert.imapd.pem.lnf 0600 root sys f none /etc/ssl/certs/pop3d.pem.default=${TMPBUILD}/cert.pop3d.pem.lnf 0600 root sys d none /var ? ? ? d none /var/svc ? ? ? d none /var/svc/manifest ? ? ? d none /var/svc/manifest/network ? ? ? f manifest /var/svc/manifest/network/pop2.xml=${SDIR}/pop2.xml 0444 root sys f manifest /var/svc/manifest/network/pop3.xml=${SDIR}/pop3.xml 0444 root sys f manifest /var/svc/manifest/network/imap.xml=${SDIR}/imap.xml 0444 root sys f manifest /var/svc/manifest/network/imaps.xml=${SDIR}/imaps.xml 0444 root sys f manifest /var/svc/manifest/network/pop3s.xml=${SDIR}/pop3s.xml 0444 root sys EOF pkgproto ${PROTO}/usr/= | nawk '{ if ( $1 == "s") { print } else if ( $1 == "d" ) { if ( $3 !~ "/" || $3 ~ "/(man|share|sparcv9)" ) { print $1, $2, $3, "? ? ?" } else { print $1, $2, $3, $4, "bin bin" } } else { print $1, $2, $3, $4, "bin bin" } }' >>${TMPBUILD}/prototype.lnf cat<${TMPBUILD}/prototype.doc.lnf i pkginfo=${SDIR}/pkginfo.doc EOF (cd ${TMPBUILD}/docs/; rm -rf BUILD CONFIG SSLBUILD ) pkgproto ${TMPBUILD}/docs/=imap/ | nawk '{ print $1, $2, $3, $4, "bin bin" }' >>${TMPBUILD}/prototype.doc.lnf echo "calling ${TMPBUILD}/prototype.lnf" call_pkgmk ${TMPBUILD}/prototype.lnf echo "calling ${TMPBUILD}/prototype.doc.lnf" call_pkgmk ${TMPBUILD}/prototype.doc.lnf } doBuild "$1"