#!/bin/sh

DIR=$(grep WORKINGDIR /etc/slapt-get/slapt-getrc|cut -f2 -d=)
FILE=${DIR}/pending_updates
OUTPUT=$(slapt-get --upgrade -s 2>/dev/null|grep 'not upgraded\.$')
UPGRADE_COUNT=$(echo $OUTPUT|awk '{print $1}')
INSTALL_COUNT=$(echo $OUTPUT|awk '{print $3}')

if [[ $UPGRADE_COUNT -gt 0 || $INSTALL_COUNT -gt 0 ]]; then
  touch $FILE
else
  if [ -f $FILE ]; then
    rm $FILE
  fi
fi

