#!/bin/sh
#
# This program is a part of debnest.
#
# $Id: debnest_make,v 1.9 2004/10/05 10:33:00 taru Exp $

set -e

if test "x$1" = "x"; then
    echo "Usage: $0 <.dsc> [<suffix>]"
    exit 1
fi

if ! test -f "$1"; then
    echo "No such file or directory: $1"
    echo "Usage: $0 <.dsc> [<suffix>]"
    exit 1
fi

if test -f "/usr/share/debnest/modules"; then
    . /usr/share/debnest/modules
fi

if test -x "/usr/share/debnest/dsc2upstream"; then
    SCRIPTDIR=/usr/share/debnest
fi

suffix=-debian
if test "x$2" != "x"; then
    suffix=$2
fi

if test "x$EXTRA_BUILDDEP" = "x"; then
  EXTRA_BUILDDEP=", debnest"
  export EXTRA_BUILDDEP
fi

dsc=$1
src=`src $1`
verne=`version_noepoch $1`

echo -n "Creating upstream working tree... "
$SCRIPTDIR/dsc2upstream $1 $suffix
echo "$src$suffix-$verne.orig"
echo -n "Creating debian source working tree... "
/bin/cp -a $src$suffix-$verne.orig $src$suffix-$verne
$SCRIPTDIR/dsc2debian $1 $src$suffix-$verne $suffix
echo "$src$suffix-$verne"

