PORTNAME=	go-cve-dictionary
DISTVERSIONPREFIX=v
DISTVERSION=	0.16.2
CATEGORIES=	security

MAINTAINER=	girgen@FreeBSD.org
COMMENT=	Build local copies of vulnerabilities from NVD and JVN
WWW=		https://github.com/vulsio/go-cve-dictionary/

LICENSE=	APACHE20

RUN_DEPENDS=	ca_root_nss>=0:security/ca_root_nss

USES=		go:modules

GO_MODULE=	github.com/vulsio/go-cve-dictionary

USE_RC_SUBR=	${PORTNAME}

GO_BUILDFLAGS=	-ldflags "-X main.version=${PORTVERSION}"

SUB_FILES=	pkg-message periodic-go-cve-dictionary
SUB_LIST=	PORTNAME=${PORTNAME} USERS=${USERS} GROUPS=${GROUPS}

USERS=		vuls
GROUPS=		vuls

post-patch:
	${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX},g' ${WRKSRC}/commands/root.go

post-install:
	${MKDIR} ${STAGEDIR}/var/db/vuls \
		${STAGEDIR}/var/log/vuls \
		${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d \
		${STAGEDIR}${PREFIX}/etc/periodic/daily
	${INSTALL_DATA} ${FILESDIR}/newsyslog-${PORTNAME}.conf \
		${STAGEDIR}${PREFIX}/etc/newsyslog.conf.d/${PORTNAME}.conf.sample
	${INSTALL_DATA} ${FILESDIR}/${PORTNAME}.yaml \
		${STAGEDIR}${PREFIX}/etc/${PORTNAME}.yaml.sample
	${INSTALL_SCRIPT} ${WRKDIR}/periodic-${PORTNAME} \
		${STAGEDIR}${PREFIX}/etc/periodic/daily/${PORTNAME}

.include <bsd.port.mk>
