# Logilab lgp configuration file for pbuilder.
# Copyright (c) 2003-2008 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr

# the file in /usr/share/pbuilder/pbuilderrc is the default template.
# /etc/pbuilderrc is the one meant for editing.
#
# read pbuilderrc.5 document for notes on specific options.

# This file is largely inspired by:
# https://wiki.ubuntu.com/PbuilderHowto
# Thanks a lot guys !

# Codenames for Debian suites according to their alias. Update these when needed
UNSTABLE_CODENAME="sid"
TESTING_CODENAME="lenny"
STABLE_CODENAME="etch"

# List of Debian suites
DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME
    "unstable" "testing" "stable")

# List of Ubuntu suites. Update these when needed
UBUNTU_SUITES=("jaunty" "intrepid" "hardy" "gutsy" "feisty" "dapper")

# Mirrors to use. Update these to your preferred mirror.
#DEBIAN_MIRROR="cdn.debian.net/debian"
DEBIAN_MIRROR="ftp.fr.debian.org"
UBUNTU_MIRROR="fr.archive.ubuntu.com"

# You can use valid sources.list files to add your personal repositories...
DEBIAN_SOURCESLIST="/etc/lgp/sources.list.debian"
UBUNTU_SOURCESLIST="/etc/lgp/sources.list.ubuntu"
# Note: files matching *_SOURCESLIST.${DIST} in the same directory can be used
#       to override generic values
# ... or set theses variables in a sources.list format (see pbuilder man page)
# They will be used in the distribution image to fetch developped packages
DEBIAN_OTHERMIRROR=
UBUNTU_OTHERMIRROR=

# Optionally use the changelog of a package to determine the suite to use if
# none set.
#if [ -z "${DIST}" ] && [ -r "debian/changelog" ]; then
#    DIST=$(dpkg-parsechangelog | awk '/^Distribution: / {print $2}')
#    # Use the unstable suite for Debian experimental packages.
#    if [ "${DIST}" == "experimental" ]; then
#        DIST="unstable"
#    fi
#fi

# Optionally set a default distribution if none is used. Note that you can set
# your own default (i.e. ${DIST:="unstable"}).
: ${DIST:="$(lsb_release --short --codename)"}

# Optionally change Debian codenames in $DIST to their aliases.
case "$DIST" in
    $UNSTABLE_CODENAME)
        DIST="unstable"
        ;;
    $TESTING_CODENAME)
        DIST="testing"
        ;;
    $STABLE_CODENAME)
        DIST="stable"
        ;;
esac

# Optionally set the architecture to the host architecture if none set. Note
# that you can set your own default (i.e. ${ARCH:="i386"}).
: ${ARCH:="$(dpkg --print-architecture)"}

NAME="$DIST"
if [ -n "${ARCH}" ]; then
    NAME="$NAME-$ARCH"
    #DEBOOTSTRAPOPTS=("--include" "sysv-rc" "--debug" "-v" "--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")
    DEBOOTSTRAPOPTS=("--include" "sysv-rc" "--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")

fi
DISTRIBUTION="$DIST"
BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
APTCACHE="/var/cache/pbuilder/$NAME/aptcache/"
BUILDPLACE="/var/cache/pbuilder/build/"

# BASETGZ directory
BASETGZ="/opt/buildd/$NAME.tgz"
mkdir -p $(dirname $BASETGZ) 2>/dev/null

if $(echo ${DEBIAN_SUITES[@]} | grep -q $DIST); then
    # Debian configuration
    MIRRORSITE="http://$DEBIAN_MIRROR/debian/"
    COMPONENTS="main contrib non-free"
    eval "OTHERMIRROR=\"$(grep -v '#' $DEBIAN_SOURCESLIST | tr '\n' '|')\""
    [[ -f $DEBIAN_SOURCESLIST.$DIST ]] && OTHERMIRROR=$(grep -v '#' $DEBIAN_SOURCESLIST.$DIST | tr '\n' '|')
    OTHERMIRROR=${OTHERMIRROR:-$DEBIAN_OTHERMIRROR}
elif $(echo ${UBUNTU_SUITES[@]} | grep -q $DIST); then
    # Ubuntu configuration
    MIRRORSITE="http://$UBUNTU_MIRROR/ubuntu/"
    COMPONENTS="main restricted universe multiverse"
    eval "OTHERMIRROR=\"$(grep -v '#' $UBUNTU_SOURCESLIST | tr '\n' '|')\""
    [[ -f $UBUNTU_SOURCESLIST.$DIST ]] && OTHERMIRROR=$(grep -v '#' $UBUNTU_SOURCESLIST.$DIST | tr '\n' '|')
    OTHERMIRROR=${OTHERMIRROR:-$UBUNTU_OTHERMIRROR}
else
    echo "Unknown distribution: $DIST"
    exit 1
fi


#EXTRAPACKAGES=gcc3.0-athlon-builder
#export DEBIAN_BUILDARCH=athlon

#export http_proxy=http://your-proxy:8080/
USEPROC=yes
USEDEVPTS=yes
USEDEVFS=no

#specify the cache for APT 
APTCACHEHARDLINK="yes"
REMOVEPACKAGES="lilo"

# make debconf not interact with user
export DEBIAN_FRONTEND="noninteractive"

DEBEMAIL=""

#for pbuilder debuild
BUILDSOURCEROOTCMD="fakeroot"
PBUILDERROOTCMD="sudo"

# command to satisfy build-dependencies; the default is an internal shell
# implementation which is relatively slow; there are two alternate
# implementations, the "experimental" implementation,
# "pbuilder-satisfydepends-experimental", which might be useful to pull
# packages from experimental or from repositories with a low APT Pin Priority,
# and the "aptitude" implementation, which will resolve build-dependencies and
# build-conflicts with aptitude which helps dealing with complex cases but does
# not support unsigned APT repositories
PBUILDERSATISFYDEPENDSCMD="/usr/lib/pbuilder/pbuilder-satisfydepends"

#Command-line option passed on to dpkg-buildpackage.
#DEBBUILDOPTS="-IXXX -iXXX"
DEBBUILDOPTS=""

# Hooks directory for pbuilder
#HOOKDIR="/etc/lgp/hooks.d"

# APT configuration files directory
#APTCONFDIR="/etc/lgp/apt.d"

# the username and ID used by pbuilder, inside chroot. Needs fakeroot, really
#BUILDUSERID=1234
#BUILDUSERNAME=pbuilder
BUILDUSERID=0

# BINDMOUNTS is a space separated list of things to mount
# inside the chroot.
BINDMOUNTS=""

# Set the PATH I am going to use inside pbuilder
#export PATH="/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin"

# SHELL variable is used inside pbuilder by commands like 'su'; and they need sane values
export SHELL=/bin/bash

# The name of debootstrap command.
DEBOOTSTRAP="cdebootstrap"

# default file extension for pkgname-logfile
PKGNAME_LOGFILE_EXTENTION="_$(dpkg --print-architecture).build"

# default PKGNAME_LOGFILE
PKGNAME_LOGFILE=""
