+usage()
+{
+cat << EOF
+usage: $0 [<options>] [buildd]
+
+OPTIONS:
+ -a <ARCH> limit to ARCH
+ -c write config only
+ -h this help
+ -s <SUITE> limit to SUITE
+EOF
+}
+
+##########
+# "main"
+##########
+
+
+# parse options
+##########
+EXTRAARGS=""
+limitarch=""
+limitsuite=""
+while getopts "cha:s:" OPTION
+do
+ case $OPTION in
+ a)
+ limitarch="$OPTARG"
+ ;;
+ c)
+ EXTRAARGS="$EXTRAARGS -c"
+ ;;
+ h)
+ usage
+ exit 0
+ ;;
+ s)
+ limitsuite="$OPTARG"
+ ;;
+ *)
+ usage >&2
+ exit 1
+ ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+# parse arguments
+##########
+if [ "$#" -gt 1 ]; then
+ usage >&2
+ exit 1
+elif [ "$#" = 1 ]; then
+ if [ "${1:-}" = "buildd" ]; then
+ MODE=buildd
+ if ! [ -d /srv/buildd/ ]; then
+ echo >&2 "Error: /srv/buildd does not exist or is not a directory."
+ exit 1
+ fi
+ else
+ usage >&2
+ exit 1
+ fi
+else
+ MODE=porterbox
+fi
+
+# figure out whether to be verbose or not
+##########
+if [ -t 0 ] ; then
+ SILENT=""
+else
+ SILENT="chronic"
+fi
+
+# get list of archs based on dpkg architecture
+##########
+DPKGARCH=$(dpkg --print-architecture)
+archs="$DPKGARCH"
+case "$DPKGARCH" in
+ amd64)
+ archs="$archs i386"
+ ;;
+ arm64)
+ archs="$archs armhf armel"
+ ;;
+ armhf)
+ if [ "$(uname -m)" = "aarch64" ] ; then
+ archs="$archs arm64"
+ fi
+ archs="$archs armel"
+ ;;
+ armel)
+ if [ "$(uname -m)" = "armv7l" ] && grep -w vfpv3 -q /proc/cpuinfo ; then
+ archs="$archs armhf"
+ fi
+ ;;
+ mips64el)
+ archs="$archs mipsel"
+ ;;
+ mipsel)
+ archs="$archs mips64el"
+ ;;
+esac
+
+err=0
+