#!/bin/sh

get_apt_conf_for_task()
{
    local target task repobranch conffile
    target=$1
    task=$2
    repobranch=$AUTOREPO_BRANCH
    [ -n "$task" ] && task=build
    aptconf_for_task=
    for conffile in \
    "$AUTOREPO_LOCAL_APT_DIR/$task.conf.$repobranch.$target" \
    "$AUTOREPO_LOCAL_APT_DIR/$task.conf.$target" \
    "$AUTOREPO_LOCAL_APT_DIR/apt.conf.$target" \
    "$AUTOREPO_GLOBAL_APT_DIR/apt.conf.$repobranch.$target" \
	; do
	if [ -e "$conffile" ]; then
	    aptconf_for_task="$conffile"
	    return
	fi
    done
    
    echo "get_apt_conf_for_task: failed to find apt.conf for $task ($repobranch/$target) in $AUTOREPO_LOCAL_APT_DIR:$AUTOREPO_GLOBAL_APT_DIR"
    exit 1
}
