Subject: pkg/7158: a package for mailwrapper for NetBSD < 1.4
To: None <gnats-bugs@gnats.netbsd.org>
From: None <woods@mail.weird.com>
List: netbsd-bugs
Date: 03/14/1999 15:42:40
>Number:         7158
>Category:       pkg
>Synopsis:       a package for mailwrapper for NetBSD < 1.4
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 14 12:50:01 1999
>Last-Modified:
>Originator:     Greg A. Woods
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Release:        NetBSD-1.3.x, pkgsrc-current
>Environment:

NetBSD 1.3.3

>Description:

	I'd like to propose a package very similar to the one enclosed
	be added to pkgsrc so that it's possible to upgrade older
	systems to use mailwrapper and thus also make it possible for
	pkgsrc (and pkg binaries) to include packages for alternate
	mailers that will work both on -current, as well as 1.3.x.

	I also propose using something like the following in alternate
	MTA package makefiles to determine whether or not the target
	system will require the mailwrapper upgrade, or not:

	---------- section to include in MTA package makefile ----------
	NETBSD_VERSION!= grep __NetBSD_Version__ /usr/include/sys/param.h | \
			awk 'BEGIN{v=0} $$1 == "\#define" {v=$$3} END{print v}'

	# Note that we cannot just check for /usr/sbin/mailwrapper because it
	# installs with PREFIX=/usr and may already have been installed yet
	# when we build a binary package we need to record this dependency.
	#
	.if ${NETBSD_VERSION} < 103100000
	DEPENDS+=	pkgmailwrapper-19990311:../../pkgtools/mailwrapper
	.endif
	---------- end include in MTA package makefile ----------

	I'm not 100% sure that the 103100000 value is correct for
	identifying when mailwrapper is needed, but it seems to be
	close and works fine for me on NetBSD-1.3I  ;-)  In any case an
	off-by-one error for -current users won't screw anything up
	much, other than cause the upgrade package to be installed over
	an existing mailwrapper binary.

	As soon as something like this is put into place I'll submit a
	working package for smail-3 that uses mailwrapper.  (I have one
	already, but I'll probably fix some remaining pointer bugs
	stirred up by recent changes in smail before releasing it.)

	Note that whomever builds the actual mailwrapper-1999xxxx
	package will have to include at least fparseln.c and util.h
	(just as ftp does in 1.3.x), as well as either adjusting the
	includes of util.h from <> to "" or adding -I. to CFLAGS, and of
	course modify the Makefile to compile and link in fparseln.o.
	My test package source archive is available here:

	    ftp://ftp.weird.com/pub/mirror/mailwrapper-19990311.tar.gz

	BTW, building this package made me realize that all /etc
	configuration files should be handled as we're starting to do
	with packages -- i.e. they should be installed into the
	/usr/share/examples and then copied to /etc if not already
	present.

>How-To-Repeat:
	
	Think about how to install smail or postfix, etc. on 1.3.x with
	the same package that'll work on -current, using mailwrapper.

>Fix:

	Add the following package to pkgsrc.

	Note that it is extremely important that this package be
	registered and "packagable" so that it can accompany binary
	packages made for other mailers.

	Note also that I go one step further than the -current
	mailer.conf in getting rid of sendmail, which I think is very
	important to do.  I'd like to do something about manual pages
	too though (eg. smail-3 installs a sendmail.8 manual page, and
	if PREFIX=/usr then it obliterates the original sendmail manual
	page -- perhaps something can be done to move sendmail's manual
	pages into a subdirectory too).

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	pkgtools/mailwrapper
#	pkgtools/mailwrapper/Makefile
#	pkgtools/mailwrapper/files
#	pkgtools/mailwrapper/files/mailer.conf
#	pkgtools/mailwrapper/files/md5
#	pkgtools/mailwrapper/pkg
#	pkgtools/mailwrapper/pkg/COMMENT
#	pkgtools/mailwrapper/pkg/DESCR
#	pkgtools/mailwrapper/pkg/INSTALL
#	pkgtools/mailwrapper/pkg/PLIST
#
echo c - pkgtools/mailwrapper
mkdir -p pkgtools/mailwrapper > /dev/null 2>&1
echo x - pkgtools/mailwrapper/Makefile
sed 's/^X//' >pkgtools/mailwrapper/Makefile << 'END-of-pkgtools/mailwrapper/Makefile'
X# $NetBSD$
X
XDISTNAME=		mailwrapper-19990311
X# XXX is it useful to prefix the "pkg" indicator to the name?
XPKGNAME=		pkgmailwrapper-19990311
XWRKSRC=			${WRKDIR}/mailwrapper
XCATEGORIES=		pkgtools mail
XMASTER_SITES=		${MASTER_SITE_LOCAL}
X
XMAINTAINER=		packages@netbsd.org
XHOMEPAGE=		http://www.netbsd.org/
X
XPREFIX=			/usr
XMAKE_ENV+=		BINDIR=/usr/sbin MANDIR=/usr/share/man
X
XNO_PATCH=		yes
XNO_CONFIGURE=		yes
X
X# Note that this package must be installed and registered in order
X# that it can be listed as a dependency for other binary packages.
X
X# NOTE: this variable name is magic
XINSTALL_FILE=		${WRKDIR}/.INSTALL
X
X.include "../../mk/bsd.prefs.mk"
X
Xpost-build:
X	${SED} -e 's|@PREFIX@|${PREFIX}|g' ${PKGDIR}/INSTALL > ${INSTALL_FILE}
X
X# Need to run INSTALL script as this doesn't happen automagically from pkgsrc.
Xpre-install:
X	@${SHELL} ${INSTALL_FILE} ${PKGNAME} PRE-INSTALL
X
X# install sample configuration file too....
X# Need to run INSTALL script as this doesn't happen automagically from pkgsrc.
Xpost-install:
X	${INSTALL_DATA_DIR} ${PREFIX}/share/examples
X	${INSTALL_DATA} ${FILESDIR}/mailer.conf ${PREFIX}/share/examples
X	@${SHELL} ${INSTALL_FILE} ${PKGNAME} POST-INSTALL
X
X.include "../../mk/bsd.pkg.mk"
END-of-pkgtools/mailwrapper/Makefile
echo c - pkgtools/mailwrapper/files
mkdir -p pkgtools/mailwrapper/files > /dev/null 2>&1
echo x - pkgtools/mailwrapper/files/mailer.conf
sed 's/^X//' >pkgtools/mailwrapper/files/mailer.conf << 'END-of-pkgtools/mailwrapper/files/mailer.conf'
X#	$NetBSD$
X#
X# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
X#
Xsendmail	/usr/libexec/sendmail/sendmail
Xsend-mail	/usr/libexec/sendmail/sendmail
Xmailq		/usr/libexec/sendmail/sendmail
Xnewaliases	/usr/libexec/sendmail/sendmail
X#
Xmailstats	/usr/libexec/sendmail/mailstats
Xmakemap		/usr/libexec/sendmail/makemap
Xpraliases	/usr/libexec/sendmail/praliases
Xrmail		/usr/libexec/sendmail/rmail
Xsmrsh		/usr/libexec/sendmail/smrsh
END-of-pkgtools/mailwrapper/files/mailer.conf
echo x - pkgtools/mailwrapper/files/md5
sed 's/^X//' >pkgtools/mailwrapper/files/md5 << 'END-of-pkgtools/mailwrapper/files/md5'
X$NetBSD$
X
XMD5 (mailwrapper-19990311.tar.gz) = 30e746b16ee20096b67fee7778c09da6
END-of-pkgtools/mailwrapper/files/md5
echo c - pkgtools/mailwrapper/pkg
mkdir -p pkgtools/mailwrapper/pkg > /dev/null 2>&1
echo x - pkgtools/mailwrapper/pkg/COMMENT
sed 's/^X//' >pkgtools/mailwrapper/pkg/COMMENT << 'END-of-pkgtools/mailwrapper/pkg/COMMENT'
XNetBSD-current's mailwrapper(8) tool
END-of-pkgtools/mailwrapper/pkg/COMMENT
echo x - pkgtools/mailwrapper/pkg/DESCR
sed 's/^X//' >pkgtools/mailwrapper/pkg/DESCR << 'END-of-pkgtools/mailwrapper/pkg/DESCR'
XThis is a copy of NetBSD-current's mailwrapper(8) tool in a format which is
Xable to be installed as a package.  It simply installs itself in /usr/sbin.
END-of-pkgtools/mailwrapper/pkg/DESCR
echo x - pkgtools/mailwrapper/pkg/INSTALL
sed 's/^X//' >pkgtools/mailwrapper/pkg/INSTALL << 'END-of-pkgtools/mailwrapper/pkg/INSTALL'
X#! /bin/sh
X:
X#
X#	mailwrapper package INSTALL script
X#
X# Copyright assigned to the Public Domain
X# by Greg A. Woods <woods@planix.com> March 1999
X#
X# $NetBSD$
X
Xcase $2 in
XPRE-INSTALL)
X	if [ ! -h /usr/sbin/sendmail -a -f /usr/sbin/sendmail ] ; then
X		echo "Moving sendmail to a safe place"
X		if [ ! -d /usr/libexec/sendmail ] ; then
X			install -o root -g wheel -m 755 -d /usr/libexec/sendmail
X		fi
X		mv /usr/sbin/sendmail /usr/libexec/sendmail
X		mv /usr/sbin/mailstats /usr/libexec/sendmail
X		mv /usr/sbin/makemap /usr/libexec/sendmail
X		mv /usr/sbin/praliases /usr/libexec/sendmail
X		mv /usr/libexec/rmail /usr/libexec/sendmail
X		mv /usr/libexec/smrsh /usr/libexec/sendmail
X		rm /usr/bin/newaliases
X		rm /usr/bin/mailq
X		ln -s mailwrapper /usr/sbin/mailstats
X		ln -s mailwrapper /usr/sbin/makemap
X		ln -s mailwrapper /usr/sbin/praliases
X		ln -s ../sbin/mailwrapper /usr/libexec/rmail
X		ln -s ../sbin/mailwrapper /usr/libexec/smrsh
X		# these three are made by mailwrapper's install?
X		ln -s mailwrapper /usr/sbin/sendmail
X		ln -s ../sbin/mailwrapper /usr/bin/newaliases
X		ln -s ../sbin/mailwrapper /usr/bin/mailq
X	else
X		echo "assuming sendmail was never installed...."
X	fi
X	;;
XPOST-INSTALL)
X	if [ ! -f /etc/mailer.conf ] ; then
X		echo "Installing default /etc/mailer.conf"
X		cp @PREFIX@/share/examples/mailer.conf /etc/mailer.conf
X	fi
X	;;
Xesac
X
Xexit 0
END-of-pkgtools/mailwrapper/pkg/INSTALL
echo x - pkgtools/mailwrapper/pkg/PLIST
sed 's/^X//' >pkgtools/mailwrapper/pkg/PLIST << 'END-of-pkgtools/mailwrapper/pkg/PLIST'
X@comment $NetBSD$
Xsbin/mailwrapper
Xman/man8/mailwrapper.8
Xman/cat8/mailwrapper.0
Xshare/examples/mailer.conf
END-of-pkgtools/mailwrapper/pkg/PLIST
exit

>Audit-Trail:
>Unformatted: