#!/bin/sh
#The files in this directory (except pbuilderrc) were written by
#(C) 2006 Kapil Hari Paranjape <kapil@imsc.res.in>. 
#They are placed in the public domain. You can do with them exactly as you wish.

# Source the pbuilderrc file
. /usr/lib/pbuilder/pbuilder-loadconfig

echo $HOME : $BASEDEV : $COWDEV

if [ -z "$BASEDEV" -o -z "$COWDEV" ]
then
	echo Please define BASEDEV and COWDEV in the pbuilderrc file
	exit 1
fi

# setup for creation
mke2fs -O dir_index $BASEDEV 
mount $BASEDEV $BUILDPLACE

# Use debootstrap to create
DISTRIBUTION=${DISTRIBUTION:-"sid"}
$DEBOOTSTRAP ${DEBOOTSTRAPOPTS[@]} $DISTRIBUTION $BUILDPLACE $MIRRORSITE

# run update
pbuilder update --no-targz 

# finalise base
umount $BUILDPLACE
e2fsck -f $BASEDEV
blockdev --setro $BASEDEV

echo Done.

