#!/bin/sh

# Set default values
APPDIR=${APPDIR:-..}

. ${APPDIR}/common.subr

sect "Packages information";

NUMP=`pkg info | wc -l | awk '{print $1}'`
OUTD=`pkg version -Iv | grep -c "needs updating"`

echo -e "There are $NUMP packages installed on the system and $OUTD of them need updating."
echo -e "${C_BOLD_S}Note that this number may be inaccurate, as your ports tree may be outdated too.${C_BOLD_E}\n"

if is_verbose 1; then
	pkg_info
	echo
else
	info "Run 'pkg(8) info' to see a full list of installed packages."
fi

info "Use 'pkg(8) version' to inspect what packages are outdated."
info "Use portsnap(8) or git(1) to update your ports tree."

echo

if which -s portaudit; then
	subsect "Packages with known security vulnerabilities:"
	portaudit -a
	echo -e "\n${C_BOLD_S}Note that this information may be inaccurate, \
as the portaudit(1) database may be outdated.${C_BOLD_E}\n"
else
	warn "You should install the portaudit(1) tool in order to get information \
about known security vulnerabilities in your packages."
fi

exit 0
