#!/bin/sh

# Use addrpm <area index> <rpm file> to insert an entry for the
# rpm package with description.

if [ $# != 2 ]; then
  echo "addrpm - add rpm package to Black Box file area"
  echo "usage: addrpm <index file> <package file>"
  exit 1
fi

if [ ! -f $2 ]; then
  echo "$2 not found"
  exit 1
fi

if [ -f $1 ] && grep -qx $2 $1; then
  echo "$2 is already in $1"
  exit 1
fi

echo $2 >> $1
rpm -qip $2 | tail --lines=+9 | awk '{ printf "*" $0 "\n"; }' >> $1
