#!/bin/ksh93 # $Id$ # mconnect source: # http://web.mit.edu/afs/net.mit.edu/project/sendmail/wrl-sendmail/aux/ || # http://src.illumos.org/source/xref/illumos-gate/usr/src/cmd/sendmail/aux/ SRCURL='http://www.sendmail.org/ftp/' VERSION=8.14.9 PKG_VERSION=${VERSION}.1 SRC=${SOURCE}/email TMPBUILD=${BUILD}/sendmail-${VERSION} . ${.sh.file%/*}/../../../etc/buildfunctions.sh LD_LIBRARY_PATH_64=/usr/lib/64:${LD_LIBRARY_PATH_64} # make sure smmsp is in /etc/passwd and /etc/group function doPrepare { SUNPKGS="SUNWcsl SUNWopenssl-libraries SUNWopenssl-include SUNWhea" IPSPKGS="/library/security/openssl /system/core-os /system/library /system/network" REQUIRED="LNFcyrus-sasl" prepareRoot4build gtar xzf ${SRC}/sendmail.${VERSION}.tar.gz cd ${TMPBUILD} # we now use IPv6 enabled OpenSolaris usr/src/cmd/sendmail/aux/mconnect.c # mkdir mconnect ; gunzip -c ${SRC}/mconnect.c.gz >mconnect/mconnect.c ( cd ${SDIR}/osol ; gtar cplf - * ) | \ (cd ${TMPBUILD} ; gtar xpf - --exclude='*.patch' ) # prepare the manual page cd mconnect xsltproc --stringparam profile.os solaris \ --xinclude \ --param man.authors.section.enabled 0 \ --param man.copyright.section.enabled 0 \ --param man.hyphenate 1 \ --param man.justify 1 \ --param refentry.meta.get.quietly 1 \ ${DOCBOOK_XSL_HOME}/manpages/profile-docbook.xsl ${SDIR}/mconnect.dbk # replace stupid groff colored links with a ref # also lines with '^.sp .' produce strange chars gsed -i -r -e 's,\\m\[blue\](.*)\\m\[\],\1,g' \ -e 's,\\s-2\\u(\[[0-9]+\])\\d\\s\+2,\1,g' \ -e 's,^\.sp \..*,.sp,g' \ mconnect.1 cd - for p in ${SDIR}/patches/*.patch ${SDIR}/osol/*.patch ; do gpatch -p1 -E -b -z .orig < $p done gsed -i -e '/Version/ s|";|+Sun";|' sendmail/version.c # build a shared lib cp ${SDIR}/shared_library.m4 devtools/M4/UNIX/ gsed -i -e '/bldPRODUCT_START/ s,library,shared_library,' \ libmilter/Makefile.m4 gsed -i -e '/^PS2PDF_CMD=/ s,=.*,= ps2pdf14,' doc/op/Makefile if [[ ${OSREL} == '5.11' ]]; then # conf.h has proper fallbacks [[ ! -r /usr/include/paths.h ]] && touch include/paths.h fi # patch always fails because enclosing $Id$ / $Date$ is changing - so: gsed -i -e '/California. All rights reserved./ { P; N; N; N; N; N; c \.\\" Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.\ .\\"\ .\\" The contents of this file are subject to the terms of the Common\ .\\" Development and Distribution License (the "License"). You may not use this\ .\\" file except in compliance with the License. You can obtain a copy of the\ .\\" license at usr/src/OPENSOLARIS.LICENSE or\ .\\" http://www.opensolaris.org/os/licensing.\ .\\" See the License for the specific language governing permissions and\ .\\" limitations under the License. When distributing Covered Code, include this\ .\\" CDDL HEADER in each file and include the License file at\ .\\" usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this\ .\\" CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your\ .\\" own identifying information: Portions Copyright [yyyy] [name of copyright\ .\\" owner] }' sendmail/sendmail.8 } function doMake { cd ${TMPBUILD} # we want new makefiles, not cached ones. So Build clean is not # sufficient export LD_LIBRARY_PATH_64 sed -e "s#@ROOT4BUILD@#${ROOT4BUILD}#g" \ -e "s#@CFLAGS@#${L_CFLAGS}#" \ -e "s#@MEM_MODEL@#${MEM_MODEL}#" \ -e "s#@ARCH_DIR@#${ARCH_DIR}#" \ -e "s#@ARCH@#${ARCH}#g" \ -e "s#@MAPDIR@#${SCRIPTDIR}#g" \ ${SDIR}/site.config.m4 > devtools/Site/site.config.m4 rm -rf obj.* Log.info "make log goes to ${MAKELOG}" ./Build >${MAKELOG} cd libmilter ./Build >>${MAKELOG} cd ${TMPBUILD}/doc/op # solaris has no pic # rm -f op.ps ; make op.pdf ; rm -f op.ps make op.pdf } function doPackage { clean_dst ${PROTO} cd ${TMPBUILD} mkdir -m 0755 -p ${PROTO}/usr/{sbin,bin,lib} \ ${PROTO}/usr/share/man/{man1,man4,man1m} export MAKE=gmake ./Build install INSTALL="${SCRIPTDIR}/${ARCH}/install -s" DESTDIR=${PROTO} cd mail.local ./Build force-install INSTALL="${SCRIPTDIR}/${ARCH}/install -s" DESTDIR=${PROTO} cd ../libmilter ./Build install INSTALL=${SCRIPTDIR}/${ARCH}/install DESTDIR=${PROTO} if [[ ${STRIP} != 'true' ]]; then chmod u+w ${PROTO}/usr/bin/* ${PROTO}/usr/sbin/* ${PROTO}/usr/lib/* $STRIP ${PROTO}/usr/bin/* ${PROTO}/usr/sbin/* for f in ${PROTO}/usr/lib/* ; do [[ ${f: -1:2} == '.a' ]] && \ Log.info "skipping strip of $f" && continue Log.info "stripping of $f" && $STRIP $f done chmod u-w ${PROTO}/usr/bin/* ${PROTO}/usr/sbin/* fi # fix man pages TMP_MAN=/tmp/man.$$ for sect in 1 1m 4 ; do cd ${PROTO}/usr/share/man/man${sect} for f in * ; do gsed -e '/^.TH/ s/ 5 / 4 /' -e '/^.TH/ s/ 8 / 1M /' \ -e '/^.TH/ s,\$Date: \([0-9/]*\).*\$,\1,' \ -e 's/\(.\)(8)/\1(1M)/g' \ -e 's/\(.\)(5)/\1(4)/g' \ -e 's/\(.\)(6)/\1(5)/g' $f >$TMP_MAN chmod 644 $f cp $TMP_MAN $f done done rm -f ${TMP_MAN} cd ${TMPBUILD} cp contrib/etrn.1m ${PROTO}/usr/share/man/man1m/ cp contrib/*.4 ${PROTO}/usr/share/man/man4/ print '.so man4/sendmail.4' >${PROTO}/usr/share/man/man4/sendmail.cf.4 print '.so man4/sendmail.4' >${PROTO}/usr/share/man/man4/submit.cf.4 print '.so man4/aliases.4' >${PROTO}/usr/share/man/man4/addresses.4 print '.so man4/aliases.4' >${PROTO}/usr/share/man/man4/forward.4 print '.so man1m/sendmail.1m' >${PROTO}/usr/share/man/man1m/purgestat.1m print '.so man1m/sendmail.1m' >${PROTO}/usr/share/man/man1m/hoststat.1m ksh ${TMPBUILD}/cf/sh/check-hostname.sh --nroff \ 2> ${PROTO}/usr/share/man/man1m/check-hostname.1m ksh ${TMPBUILD}/cf/sh/check-permissions.sh --nroff \ 2> ${PROTO}/usr/share/man/man1m/check-permissions.1m if [[ -n ${ARCH_DIR} ]]; then mkdir ${PROTO}/usr/lib${ARCH_DIR} mv ${PROTO}/usr/lib/lib* ${PROTO}/usr/lib${ARCH_DIR}/ fi gsed -f ${SCRIPTDIR}/perl.sed contrib/etrn.pl >${PROTO}/usr/sbin/etrn chmod 0555 ${PROTO}/usr/sbin/etrn print ' +-------------------+ | BUILDING A FILTER | +-------------------+ The following command presumes that the sample code from the end of this README is saved to a file named "sample.c". cc -m64 -D_REENTRANT -o sample sample.c -lmilter Filters must be thread-safe! The compiler flag to link with threading support differs according to the compiler and linker used. Many operating systems like Solaris now provide support for POSIX threads in the standard C libraries. For those there is no need to link with additional libraries like libpthread etc.! Note that since filters use threads, it may be necessary to alter per process limits in your filter. For example, you might look at using setrlimit() to increase the number of open file descriptors if your filter is going to be busy. ' >${PROTO}/usr/include/libmilter/README pkginfo2arch [[ ! -d cf/defaults ]] && mkdir cf/defaults touch cf/defaults/local-host-names print 'root' >cf/defaults/trusted-users cat>${TMPBUILD}/prototype.lnf<>${TMPBUILD}/prototype.lnf [[ -n ${ARCH_DIR} ]] && gsed -e "/ lib\/${ARCH_DIR}/ d" \ ${TMPBUILD}/prototype.lnf cp devtools/Site/site.config.m4 cf/siteconfig/this.build.m4 pkgproto ${TMPBUILD}/cf=lib/mail | awk '{ if ( $3 ~ /\.cf=/ || $3 ~ /\.orig=/ ) { next; } else if ( $1 == "d" || $3 ~ /\.sh=/ ) { print $1, $2, $3, "0755 root mail" } else { print $1, $2, $3, "0444 root mail" } }' >>${TMPBUILD}/prototype.lnf print "i pkginfo=${TMPBUILD}/pkginfo.milter.lnf" >prototype.milter.lnf pkgproto ${PROTO}/usr/include/=include/ ${PROTO}/usr/lib/=lib/ | nawk ' { if ( $1 == "s" ) { print; } else if ( $1 == "d" ) { if ( $3 ~ /\/libmilter/ ) { print $1, $2, $3, "0755 root bin" } else { print $1, $2, $3, "? ? ?" } } else if ( $3 ~ "\.so(\.| )" || $3 ~ "/include/" ) { print $1, $2, $3, $4, "root bin" } }' >>${TMPBUILD}/prototype.milter.lnf # # documentation # cat>${TMPBUILD}/prototype.doc.lnf<prototype.milter.doc.lnf pkgproto ${TMPBUILD}/libmilter/docs/=libmilter/ | nawk ' { if ( $3 ~ "\.(fig|ps)$" ) next; print $1, $2, $3, "0644 bin bin" }' >>prototype.milter.doc.lnf call_pkgmk ${TMPBUILD}/prototype.lnf call_pkgmk ${TMPBUILD}/prototype.milter.lnf call_pkgmk ${TMPBUILD}/prototype.doc.lnf call_pkgmk ${TMPBUILD}/prototype.milter.doc.lnf typeset -a PDIRS SASL=${ grep 'set name=pkg.fmri' ${SDIR}/../../network/cyrus-sasl/lnfpkg.p5m ; } SASL="${SASL#*value=}" [[ -z ${SASL} ]] && \ Log.fatal 'Unable to determine cyrus-sasl version - abort.' && exit 1 cat >${TMPBUILD}/${IPS_MANIFEST}.inc< set facet.doc.html true> delete facet.doc true> ' >lnf.milter.mog createIPS -X milter -p 'network/smtp' -c 'System/Libraries' \ -s ${SRCURL} -I pkginfo.milter.doc.lnf -m lnf.milter.mog PDIRS publishIPS -X milter PDIRS } doBuild "$@"