#!/bin/bash
# 2009-04-09 tyler - use previously built packages as an apt source
# http://blog.edseek.com/~jasonb/articles/pbuilder_backports/pbuilderbuild.html#pbuilderhook

echo Calling $0

: ${DIST:=$(lsb_release --short --codename)}
: ${ARCH:=$(dpkg --print-architecture)}
BUILDRESULT="${HOME}/pbuilder/${DIST}-${ARCH}_result/"

# create apt archive of previously built packages
( cd ${BUILDRESULT} ; apt-ftparchive packages . > ${BUILDRESULT}/Packages )

# see ~/.pbuilderrc for creation of $BUILDRESULT/Release
echo "deb [trusted=yes] file://${BUILDRESULT} ./" >> /etc/apt/sources.list
apt-get update
