#!/bin/bash
#
# plogin
#
# © 2011-2015 Alf Gaida <agaida@siduction.org>
#

export TARGET="siduction"
export REPOSITORY="extra"
export DISTRI="unstable"
export ARCH="amd64"

while getopts “t:r:d:a:sh” OPTION; do
     case ${OPTION} in
         t)
             export TARGET=${OPTARG}
             ;;
         r)
             export REPOSITORY=${OPTARG}
             ;;
         d)
             export DISTRI=${OPTARG}
             ;;
         a)
             export ARCH=${OPTARG}
             ;;
         s)
             SAVESETTINGS='--save-after-login'
             ;;
         h)
             #usage
             exit
             ;;
     esac
done

case ${ARCH} in 
    i386)
        export debian_chroot="\[\033[1;33m\]pbuild-${DISTRI}-${ARCH} $$\[\033[0m\]"
        ;;
    amd64)
        export debian_chroot="\[\033[1;33m\]pbuild-${DISTRI}-${ARCH} $$\[\033[0m\]"
        ;;
esac

. /usr/share/pbuilder-scripts/set_pbuilder

sudo -E pbuilder --allow-untrusted --login ${SAVESETTINGS}

