##################### GENERAL ##################### 
GARNAME = openvpn
GARVERSION = 2.4.9
GARELEASE = 2
HOME_URL = https://openvpn.net
CATEGORIES = net/vpn
MASTER_SITES += https://swupdate.openvpn.org/community/releases/
DISTFILES = openvpn-$(GARVERSION).tar.xz
MAINTAINER = Felipe Sanchez <izto@asic-linux.com.mx>
LICENSE = GPL

DESCRIPTION = A secure IP tunnel daemon
define BLURB
endef

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


#IZTACI_PACKAGE_PATH =

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

# 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
echo ------------------------------------------------------------------
echo s6-rc services installed:
echo
echo \"    openvpn-server\"
echo \"    openvpn-log\"
echo \"    openvpn\"
echo
echo Run \'rc update\' to add them to the live services database.
echo
echo ------------------------------------------------------------------
echo

endef

# Required dependencies
define SLACK_REQUIRED
linux-pam
lz4
lzo
openssl
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)/etc/sysconfig
INSTALL_DIRS += $(DESTDIR)/etc/s6-rc/source
INSTALL_DIRS += $(DESTDIR)/etc/rc.d
INSTALL_DIRS += $(DESTDIR)/etc/openvpn/conns
INSTALL_DIRS += $(DESTDIR)/etc/openvpn/keys
INSTALL_DIRS += $(DESTDIR)/etc/openvpn/certs

# 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) s6rc
	$(MAKE) sysconfig
	cp -av files/run-image $(DESTDIR)/etc/openvpn/run-image
	install -o root -g root -m 0700 files/rc.openvpn $(DESTDIR)/etc/rc.d/rc.openvpn
	cp -av $(WORKSRC)/sample/sample-config-files/ $(DESTDIR)/$(docdir)
	$(MAKE) strip
	$(MAKE) gzip-man
	$(MAKECOOKIE)

