#!/bin/sh

###################################################
##
## This was written by:
##     Simon Mudd - simon.mudd@alltrading.es
##
###################################################

RPMQA=/var/local/dailyscript/rpmqa
RPMVA=/var/local/dailyscript/rpmva

START=$SECONDS

unalias mv

# this is to check differences of rpm -Va from one day to another

echo "`basename $0` run on `date`"

if [ -f $RPMQA.new ]; then
	echo "WARNING: partial package list already present, ignoring"
fi
echo "Listing installed packages..."
rpm -qa > $RPMQA.new
echo "`wc -l $RPMQA.new | awk '{print $1}'` packages installed"
if [ -f $RPMQA ]; then
	echo "changes from previous run..."
	echo "---"
	diff $RPMQA $RPMQA.new
	echo "---"
else
	echo "no file from previous run to compare"
fi
mv $RPMQA.new $RPMQA

echo "Checking Packages..."
if [ -f $RPMVA.new ]; then
	echo "WARNING: partial file exists from previous run, ignoring"
fi
rpm -Va > $RPMVA.new
if [ -f $RPMVA ]; then
	echo "changes from previous run..."
	echo "---"
	diff $RPMVA $RPMVA.new
	echo "---"
else
	echo "no file from previous run to compare"
fi
mv $RPMVA.new $RPMVA

STOP=$SECONDS
let mm=${STOP}-${START}
echo "runtime $mm seconds"

