##################### GENERAL ##################### 
GARNAME = clamav
GARVERSION = 0.102.2
GARELEASE = 1
HOME_URL = https://www.clamav.net
CATEGORIES = app/antivirus
MASTER_SITES += https://www.clamav.net/downloads/production/
DISTFILES = clamav-$(GARVERSION).tar.gz
PATCHFILES = clamd-s6-notify.patch
MAINTAINER = Felipe Sanchez <izto@asic-linux.com.mx>
LICENSE = GPL

DESCRIPTION = An open source antivirus engin 
define BLURB
ClamAV is an open source antivirus engine for
detecting trojans, viruses, malware & other
malicious threats.

endef

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


#IZTACI_PACKAGE_PATH =

# Users and groups the binary package will create
# WHEN INSTALLED ON THE DESTINATION SYSTEM
CREATE_GROUPS = $(CLAMAV_USER):201
CREATE_USERS  = $(CLAMAV_GROUP):201:201

# 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 to $(CLAMAV_USER):$(CLAMAV_GROUP) on $(CLAMAV_DBDIR)"
chown -R $(CLAMAV_USER):$(CLAMAV_GROUP) \$$ROOT$(CLAMAV_DBDIR)
echo
echo ------------------------------------------------------------------
echo s6-rc services installed:
echo
echo \"    clamd-server\"
echo \"    clamd-log\"
echo \"    clamd\"
echo
echo Run \'rc update\' to add them to the live services database.
echo ------------------------------------------------------------------
echo
echo If this is a new ClamAV installation you probably want to download
echo the latest database update by running:
echo
echo    freshclam
echo
echo ------------------------------------------------------------------
echo
endef

# Required dependencies
define SLACK_REQUIRED
bzip2
curl
gcc-so | gcc
json-c
libtool
libxml2
ncurses
openssl
pcre
xz
zlib
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)$(CLAMAV_DBDIR)
INSTALL_DIRS += $(DESTDIR)/$(docdir)
INSTALL_DIRS += $(DESTDIR)/etc/cron.daily
INSTALL_DIRS += $(DESTDIR)/etc/s6-rc/source
INSTALL_DIRS += $(DESTDIR)/etc/sysconfig

# 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:
	cd $(WORKSRC); $(MAKE) check
	$(MAKECOOKIE)


post-install:
#	$(MAKE) test
	$(MAKE) strip
	$(MAKE) gzip-man
	$(MAKE) s6rc
	$(MAKE) sysconfig
	mv -v $(DESTDIR)/etc/*.sample $(DESTDIR)/$(docdir)
	install -o root -g root -m0644 files/clamd.conf     $(DESTDIR)/etc/clamd.conf.new
	install -o root -g root -m0644 files/freshclam.conf $(DESTDIR)/etc/freshclam.conf.new
	install -o root -g root -m0700 files/clamav-update  $(DESTDIR)/etc/cron.daily/clamav-update
	sed -i 's/GARVERSION/$(GARVERSION)/g' $(DESTDIR)/etc/*.new
	$(MAKECOOKIE)

