#!/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 in the system and $OUTD of them needs 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_info(1) to see a full list of installed packages."
fi

info "Use pkg_version(1) to inspect what packages are outdated."
info "Use the portsnap(8) or csup(1) tool 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
