#!/bin/bash

rpms=`find . -name *.rpm`
rpm -qa > /tmp/rpm.all
TARGET=/tmp/RPM-UPGRADE

if [ -e $TARGET ]; then
	rm -f $TARGET/*
else
	mkdir -p $TARGET
fi

for rpm in $rpms
do
	rpmfile=`echo $rpm | cut -d "/" -f3`
	rpmname=`echo $rpmfile |  sed -e 's/.rpm//'`

	echo $rpmname | grep kernel > /dev/null 2> /dev/null	
	if [ $? -eq 0 ]; then
		continue
	fi

	cnt=`grep $rpmname /tmp/rpm.all -c` > /dev/null 2> /dev/null
	if [ $? -ne 0 ]; then 
		echo "$rpmname is not installed"
		cp -f $rpm $TARGET
	fi
	
done

rm /tmp/rpm.all


