#!/bin/sh

#REDHAT=/usr/src/redhat
PACKAGE=pcap
export BUILDROOT=/tmp/pcap-buildroot
pushd ..
  rm -rf config
  yes | ./bootstrap
  ./configure
  make dist
  if test $? -eq 0; then
    popd
    version=`cat ../VERSION`
    revision=`cat ../REVISION`
    sed -e 's#V_ERSION#'$version'#' -e 's#R_EVISION#'$revision'#' -e 's#B_UILDROOT#'$BUILDROOT'#' < pcap.spec.IN > pcap.spec
    if test $? -eq 0; then
      echo "going forward with rpmbuild.  Check 'results' when finished."
      rm -rf /tmp/lib${PACKAGE}-buildroot
      cp ../lib${PACKAGE}-${version}.${revision}.tar.gz $REDHAT/SOURCES
      cp pcap.spec $REDHAT/SPECS
      rpmbuild -ba $PACKAGE.spec
    fi
  else
    popd
    echo libpcap make dist failed
  fi
