#!/bin/sh
# script from Andres Mejia
# name this script 'pdebuild-woody', 'pdebuild-sid', 'pdebuild-sarge', 'pdebuild-experimental' etc.

DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
BASE_DIR="$HOME/pbuilder"
ALL_OPTIONS="$@"
PDEBUILD_OPTIONS="`echo "$ALL_OPTIONS" | sed 's/-- .*$//'`"
PBUILDER_OPTIONS="`echo "$ALL_OPTIONS" | sed '/^.*[--][\ ].*$/ !{d}' | sed 's/^.*-- //'`"

pdebuild --buildresult $BASE_DIR/result \
$PDEBUILD_OPTIONS \
-- \
--basetgz $BASE_DIR/$DISTRIBUTION-base.tgz \
--distribution $DISTRIBUTION \
$PBUILDER_OPTIONS
