#!/bin/sh
# Filename:      /etc/apt/listbugs
# Purpose:       display bugs of currently running system (used inside grml-live)
# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2 or any later version.
################################################################################

[ -n "$SEVERITY" ] || SEVERITY="critical,grave,serious"

if ! [ -x /usr/sbin/apt-listbugs ] ; then
   echo "Error: /usr/sbin/apt-listbugs not available. Exiting."
   exit 1
fi

if ! [ -x /usr/bin/apt-show-source ] ; then
   echo "Error: /usr/bin/apt-show-source not available. Exiting."
   exit 1
fi

if ! [ -x /usr/bin/dpkg-query ] ; then
   echo "Error: /usr/bin/dpkg-query not available. Exiting."
   exit 1
fi

if apt-show-source 1>/dev/null 2>&1 ; then
   apt-listbugs -q -n -s $SEVERITY list \
      $(apt-show-source | grep -v -e 'not installed' -e '--------------' -e \
      'Version' | awk '{print $4;}' | grep -v '^[() ]*$'| sort | uniq)
else
   apt-listbugs -q -n -s $SEVERITY list $(dpkg-query -W --showformat='${Package}\n')
fi

# $ROOTCMD apt-listbugs -s $SEVERITY list \
#          $(dpkg --get-selections| grep '       install' | awk '{print $1})

## END OF FILE #################################################################
