#! ${SH}
# $NetBSD: audit-packages,v 1.9 2002/06/04 23:01:34 kim Exp $

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

if [ -n "$(find ${PKGVULNDIR}/vulnerabilities -ctime +7)" ]
then
    echo "** ${PKGVULNDIR}/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 ; wait", $1, $1, $2, $3);
	  system(cmd); }
' ${PKGVULNDIR}/vulnerabilities

exit 0
