##################### GENERAL ##################### 
GARNAME = dspam
GARVERSION = 3.10.2
GARELEASE = 3
HOME_URL = http://www.nuclearelephant.com/
CATEGORIES = net/mail
MASTER_SITES += http://downloads.sourceforge.net/project/dspam/dspam/dspam-$(GARVERSION)/
DISTFILES = dspam-$(GARVERSION).tar.gz
PATCHFILES += dspam_2sql_virtuser-3.10.2.patch
PATCHFILES += dspam-s6-notify.patch
MAINTAINER = Felipe Sanchez <izto@asic-linux.com.mx>
LICENSE = GPL

DESCRIPTION = An open-source, freely available anti-spam solution
define BLURB
DSPAM v$(GARVERSION)
COPYRIGHT (C) 2002-2012 DSPAM Project
http://dspam.sourceforge.net/

Includes patch which adds virtusers support to dspam_2sql.
endef

##################### PACKAGING #####################


#IZTACI_PACKAGE_PATH =

# Users and groups the binary package will create
# WHEN INSTALLED ON THE DESTINATION SYSTEM
CREATE_GROUPS = dspam:200
CREATE_USERS  = dspam:200:200

# This is to be appended to the package's installation script
# Use it to set file owners, permissions, DB initialization, etc.
# Remember any shell variables (Such as $ROOT) have to be escaped
# like this: \$$ROOT

define DOINST_APPEND
echo "Setting owner for $(DSPAM_HOME)/{data,log}: dspam:dspam"
chown -R dspam:dspam \$$ROOT/$(DSPAM_HOME)
chown -v dspam:dspam \$$ROOT/$(sysconfdir)/dspam.conf
chmod -v 0511 \$$ROOT/$(bindir)/dspam
echo
echo ------------------------------------------------------------------
echo s6-rc services installed:
echo
echo \"    dspam-server\"
echo \"    dspam-log\"
echo \"    dspam\"
echo
echo Run \'rc update\' to add them to the live services database.
echo ------------------------------------------------------------------
echo
endef

# Required dependencies
define SLACK_REQUIRED
postgresql-libs | postgresql
dspam-tools >= 0.6.1
endef

# Suggested dependencies
define SLACK_SUGGESTS
endef

# Package conflicts (lprng vs cups for example)
define SLACK_CONFLICTS
endef



##################### BUILDING #####################


CONFIGURE_SCRIPTS = $(WORKSRC)/configure
BUILD_SCRIPTS = $(WORKSRC)/Makefile
INSTALL_SCRIPTS = $(WORKSRC)/Makefile

CONFIGURE_ARGS = $(DIRPATHS)
NODIRPATHS = 

# Directories to be created as part of the install process.
# Can be inside the final package or just transient dirs we need
# while building it.
INSTALL_DIRS += $(DESTDIR)$(docdir)
INSTALL_DIRS += $(DESTDIR)/etc/s6-rc/source
INSTALL_DIRS += $(DESTDIR)/etc/sysconfig
INSTALL_DIRS += $(DESTDIR)/etc/cron.daily
INSTALL_DIRS += $(DESTDIR)$(sysconfdir)/dspam.d
INSTALL_DIRS += $(DESTDIR)$(DSPAM_HOME)/log
INSTALL_DIRS += $(DESTDIR)$(DSPAM_HOME)/data
INSTALL_DIRS += $(DESTDIR)$(docdir)/contrib
INSTALL_DIRS += $(DESTDIR)$(libdir)/dspam/tools.pgsql_drv

# If some dirs are trying to install into /, list their names
# here, such as: prefix bindir mandir
INSTALL_OVERRIDE_DIRS = 


# Dependencies are of the form categorydir/packagedir
# LIBDEPS are for libraries, and DEPENDS are for everything else
DEPENDS =
LIBDEPS =
DEPENDS =
# Builddeps are installed in the build DESTIMG
BUILDDEPS =

##################### GAR #####################

# This should go before any hand-made rules.
include config.mk
include ../level.mk

##################### CUSTOMIZING #####################

test:
	@echo
	@echo -e "$(WARNCOLOR)No tests are available for this package$(NORMALCOLOR)"
	@echo
	$(MAKECOOKIE)


post-install:
	$(MAKE) test
	$(MAKE) etcnew
	$(MAKE) s6rc
	$(MAKE) sysconfig
	install -m0644 files/dspam_2sql_virtuser-3.10.2.patch                    $(DESTDIR)$(docdir)
	install -m0644 $(WORKSRC)/src/tools.pgsql_drv/purge-pe.sql               $(DESTDIR)$(libdir)/dspam/tools.pgsql_drv
	install -m0700 $(WORKSRC)/contrib/dspam_maintenance/dspam_maintenance.sh $(DESTDIR)$(bindir)/dspam_maintenance.sh
	install -m0644 $(WORKSRC)/contrib/dspam_maintenance/dspam_maintenance.1  $(DESTDIR)$(mandir)/man1/dspam_maintenance.1
	install -m0700 files/dspam-maintenance.cron                              $(DESTDIR)/etc/cron.daily/dspam-maintenance
	$(MAKE) strip
	$(MAKE) gzip-man
	$(MAKECOOKIE)

