#! /bin/sh
# BPP Regen Index - @1996-2002 by Antonio Gallo
# agx@linux.it - www.badpenguin.org - www.linux.it/~agx

# include bpp library
. /usr/libexec/bpp-functions

BPPLIST=/tmp/bpp-regen-index.tmp
BPPINFO=/tmp/bpp-regen-info.tmp
BPPDEPOT=/badpenguin/packages
BPPINDEX=$BPPDEPOT/INDEX

# init options and vars
echo "- looking for available packages..."
find $BPPDEPOT -iname "*.bpp" >$BPPLIST
wc -l $BPPLIST

echo >$BPPINDEX
for i in `cat $BPPLIST` ; do
  PKGNAME=`basename $i .bpp`
  PKGINFO=`dirname $i`/${PKGNAME}.txt
  if [ ! -f $PKGINFO ]; then
    echo "FILE INESISTENTE!"
    PKGINFO=$BPPINFO
    rm -f $BPPINFO
    tar -x -f "$i" -z -O install/INFO  1>$BPPINFO
  fi
  echo "analizing: $PKGNAME "
  echo "begin: $PKGNAME" >>$BPPINDEX
  fn_get_INFO "$PKGINFO"
  echo "Section=$PKGSECTION" >>$BPPINDEX

  if [ "$PKGREQFILE" != "" ]; then
    echo "require file:" >>$BPPINDEX
    for i in $PKGREQFILE ; do
      [ "$i" = "" ] && continue
      echo "$i" >>$BPPINDEX
    done
    echo "" >>$BPPINDEX
  fi

  if [ "$PKGREQBPP" != "" ]; then
    echo "require bpp:" >>$BPPINDEX
    for i in $PKGREQBPP ; do
      [ "$i" = "" ] && continue
      echo "$i" >>$BPPINDEX
    done
    echo "" >>$BPPINDEX
  fi

  echo "end." >>$BPPINDEX
  echo >>$BPPINDEX
done
exit 0

