#! /bin/sh
# Package Rebuild  -  @2000 by Antonio Gallo
# agx@linux.it - www.badpenguin.org - www.linux.it/~agx
# 20 May 2000, This script is used to help a mantainer to create
#              a package to be used on Bad Penguin.
# Requirements: awk, cat, du, grep
# Mon Jul 17 20:58:43 2000, can build packages without source
# Mon Aug 21 23:07:05 2000, contribution from Biagio Lucini
# Mon Sep 11 21:58:44 2000, updated to 2.0.3 format
# Sun Jun 24 08:49:24 2001, splitted



# Check if it is a package
if [ -f "$1" ]; then
  exec package-unpack "$1"
fi


##### =====================      tools    =========================  #####
. /usr/local/libexec/package-library
MYVERSION="2.2.0"

# Banner
echo "======================================================================"
echoc CYAN  "Bad Penguin - Package Rebuild $MYVERSION"
echo "======================================================================"

# Check Parameters
if [ "$1" = "" ]; then
  echoc RED "package-rebuild: need at least 1 argument !"
  exit 1
fi

# Define package subdirs
fn_read_settings $1
fn_read_pkginfo
fn_check_pkgdir

package-compile "$1" "$2" "$3"
R=$?
if [ $R -ne 0 ]; then
  echoc RED "! package-compile is terminated with error $R"
  exit $R
fi
exec package-check "$1"

echo "----------------------------------------------------------------------"
echoc GREEN "! package successfully rebuilded
exit 0
