#! ${SH}
# $NetBSD: audit-packages,v 1.7 2001/12/29 10:07:31 agc Exp $

if [ ! -f ${DISTDIR}/vulnerabilities ] ;then
    echo "** Missing ${DISTDIR}/vulnerabilities" 1>&2
    echo "** run download-vulnerability-list" 1>&2
    exit 1
fi

if [ -n "$(find ${DISTDIR}/vulnerabilities -ctime +7)" ]
then
    echo "** ${DISTDIR}/vulnerabilities more than a week old" 1>&2
    echo "** run download-vulnerability-list" 1>&2
    exit 1
fi

${AWK} '
	/^#.*/ { next }
	NF == 0 { next }
	{ cmd = sprintf("${PKG_TOOLS_BIN}/pkg_info -qe \"%s\" && echo Package \"`${PKG_TOOLS_BIN}/pkg_info -e '\''%s\'\''`\" has a %s vulnerability, see %s", $1, $1, $2, $3);
	  system(cmd); }
' ${DISTDIR}/vulnerabilities

exit 0
