Index: Keywords/service.ucl =================================================================== --- /dev/null +++ Keywords/service.ucl @@ -0,0 +1,39 @@ +# $FreeBSD: head/Keywords/shell.ucl 417133 2016-06-19 22:21:22Z bapt $ +# +# MAINTAINER: bapt@FreeBSD.org +# +# @service service port protocol service entry +# +# Handle adding and remove entries in /etc/services +# + +actions: [] +post-install: < add entry in etc/services: '$name $port/$protocol'" + echo "$name $port/$protocol # $comment" >> ${PKG_ROOTDIR}/etc/services + fi +EOD +pre-deinstall: < Removing entry in etc/services: '$1 $2/$3'" + sed -i '' \ + -Ee "/^$1[[:space:]]+$2\/$3[[:space:]].*/d" \ + ${PKG_ROOTDIR}/etc/services + fi +EOD Index: mail/spamd/Makefile =================================================================== --- mail/spamd/Makefile +++ mail/spamd/Makefile @@ -3,7 +3,7 @@ PORTNAME= spamd PORTVERSION= 4.9.1 -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= mail MASTER_SITES= SF/freebsdspamd/spamd @@ -28,7 +28,10 @@ man/man8/spamd-setup.8.gz \ man/man8/spamd.8.gz \ man/man8/spamdb.8.gz \ - man/man8/spamlogd.8.gz + man/man8/spamlogd.8.gz \ + "@service spamd 8025 tcp spamd(8)" \ + "@service spamd-sync 8025 udp spamd(8) synchronisation" \ + "@service spamd-cfg 8026 tcp spamd(8) configuration" SUB_LIST= SPAMDUSER=${USERS} \ SPAMDGROUP=${GROUPS} Index: mail/spamd/files/pkg-install.in =================================================================== --- mail/spamd/files/pkg-install.in +++ mail/spamd/files/pkg-install.in @@ -7,7 +7,6 @@ SPAMDUSER=%%SPAMDUSER%% SPAMDGROUP=%%SPAMDGROUP%% -FILE="/etc/services" check_db() { DB=/var/db/spamd @@ -25,48 +24,6 @@ fi } -check_service() { - local SERVICE PORT PROTO COMMENT - - SERVICE=$1 - PORT=$2 - PROTO=$3 - COMMENT=$4 - - # check - OK=no - HAS_SERVICE=no - COUNT=1 - for i in $(grep ^${SERVICE} ${FILE}); do - if [ ${COUNT} -eq 1 ] && [ x"${i}" = x"${SERVICE}" ]; then - HAS_SERVICE=yes - elif [ ${COUNT} -eq 2 ] && [ "${HAS_SERVICE}" = "yes" ] && \ - [ x"${i}" = x"${PORT}/${PROTO}" ]; then - OK=yes - break - fi - COUNT=$(( ${COUNT} + 1 )) - done - # add an entry for SERVICE to /etc/services - if [ "${OK}" = "no" ]; then - echo "==> add entry \"${SERVICE} ${PORT}/${PROTO}\"" - ( - grep -v -e "^${SERVICE}.*${PORT}/${PROTO}" ${FILE} - echo "${SERVICE} ${PORT}/${PROTO} # ${COMMENT}" - ) >> ${FILE}.new - mv ${FILE}.new ${FILE} - fi -} - -# always add service entries -if [ "$2" = "PRE-INSTALL" ]; then - echo "Checking ${FILE} for missing service entries" - [ ! -f ${FILE} ] && echo "==> cannot find ${FILE} ... => exit" && exit 1 - check_service spamd 8025 tcp "spamd(8)" - check_service spamd-sync 8025 udp "spamd(8) synchronisation" - check_service spamd-cfg 8026 tcp "spamd(8) configuration" -fi - if [ "$2" = "POST-INSTALL" ]; then check_db fi Index: mail/spamd/pkg-deinstall =================================================================== --- mail/spamd/pkg-deinstall +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# -# ex:ts=4:sw=4:noet -#-*- mode: makefile; tab-width: 4; -*- -# -# $FreeBSD$ - -if [ "$2" = "DEINSTALL" ]; then - FILE="/etc/services" - echo "===> Removing spamd entries from ${FILE}" - sed -i '' \ - -e "/^spamd-sync.*8025/d" \ - -e "/^spamd-cfg.*8026/d" \ - -e "/^spamd.*8025/d" \ - ${FILE} -fi