<?xml version="1.0"?>
<package name="postfix">
	<description>mail transfer agent</description>
	<releases>
		<release version="3.11.7" revision="1">
			<deps>
				<dep name="lmdb"/>
				<dep name="cyrus-sasl"/>
				<dep name="pcre"/>
				<dep name="openssl"/>
			</deps>
			<preinst>
				<cmd>sed -i "/postfix/d" /etc/passwd</cmd>
				<cmd>sed -i -e "/postfix/d" -e "/postdrop/d" /etc/group</cmd>
				<cmd check="no">echo "postfix:x:8:8:postfix::/bin/false" &gt;&gt; /etc/passwd</cmd>
				<cmd check="no">echo "postfix:x:8" &gt;&gt; /etc/group</cmd>
				<cmd check="no">echo "postdrop:x:9:" &gt;&gt; /etc/group</cmd>
			</preinst>
			<build>
				<script>
					<archive name="postfix-$VERSION">
						<cmd>chown postfix:postfix /var/mail</cmd>
						<cmd>make makefiles shared=yes default_database_type=lmdb default_cache_db_type=lmdb CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS -DNO_NIS -DNO_DB -DHAS_LMDB" AUXLIBS="-lsasl2 -lpthread -lssl -lcrypto -llmdb"</cmd>
						<cmd>make</cmd>
						<cmd>make upgrade daemon_directory=/usr/lib/postfix manpage_directory=/usr/share/man sample_directory=/usr/share/doc/postfix html_directory=/usr/share/doc/postfix</cmd>
						<cmd check="no">echo "pwcheck_method: saslauthd
mech_list: plain login" &gt; /usr/lib/sasl2/smtpd.conf</cmd>

						<cmd>mkdir -p $DOCDIR</cmd>
						<!-- copy not modified config files -->
						<cmd>for f in conf/{access,aliases,canonical,generic,header_checks,master.cf,relocated,transport,virtual}; do cp -v $f $DOCDIR/$(basename $f).paldo; done</cmd>

						<install name="postfix.service-20120625" dest="/lib/systemd/system/postfix.service"/>
					</archive>
				</script>
			</build>
			<postinst>
				<!-- update configuration to use lmdb instead of berkeley db (hash) -->
				<cmd>grep -q lmdb: /etc/postfix/main.cf || sed -i -e 's@hash:/@lmdb:/@g' /etc/postfix/main.cf</cmd>

				<cmd>newaliases</cmd>
				<cmd>postmap /etc/postfix/access</cmd>
				<cmd>postmap /etc/postfix/canonical</cmd>
				<cmd>postmap /etc/postfix/generic</cmd>
				<cmd>postmap /etc/postfix/relocated</cmd>
				<cmd>postmap /etc/postfix/transport</cmd>
				<cmd>postmap /etc/postfix/virtual</cmd>
			</postinst>
			<prerm>
				<cmd>sed -i "/postfix/d" /etc/passwd</cmd>
				<cmd>sed -i -e "/postfix/d" -e "/postdrop/d" /etc/group</cmd>
			</prerm>
			<config>
				<configfile default="$DOCDIR/access.paldo" dest="/etc/postfix/access"/>
				<configfile default="$DOCDIR/aliases.paldo" dest="/etc/postfix/aliases"/>
				<configfile default="$DOCDIR/canonical.paldo" dest="/etc/postfix/canonical"/>
				<configfile default="$DOCDIR/generic.paldo" dest="/etc/postfix/generic"/>
				<configfile default="$DOCDIR/header_checks.paldo" dest="/etc/postfix/header_checks"/>
				<configfile name="main.cf-20240508" default="$DOCDIR/main.cf.paldo" dest="/etc/postfix/main.cf"/>
				<configfile default="$DOCDIR/master.cf.paldo" dest="/etc/postfix/master.cf"/>
				<configfile default="$DOCDIR/relocated.paldo" dest="/etc/postfix/relocated"/>
				<configfile default="$DOCDIR/transport.paldo" dest="/etc/postfix/transport"/>
				<configfile default="$DOCDIR/virtual.paldo" dest="/etc/postfix/virtual"/>
			</config>
		</release>
	</releases>
</package>
