# functions specific to Debian (and possibly derived distros)

add_mirrors() {
    # feed a list of comma-separated or enter-separated mirrors,
    # add them to the chroot's sources.list

    echo "$1" | tr ',' '\n' \
    | while read mirror dist components; do
        if [ -z "$mirror" ] || [ "$mirror" = "none" ]; then
            continue
        fi
        if [ -z "$dist" ]; then
            dist="$DIST"
            # components are only optional if dist does not end with a trailing
            # slash; always include them if dist is not specified.
            components="$COMPONENTS"
        fi

        case $mirror in
            file:///*)
                if [ "$TRUST_FILE_MIRROR" = "True" ]; then
                    echo "deb [trusted=yes] $mirror $dist $components" >> $ROOT/etc/apt/sources.list
                fi
                dir=$(echo "$mirror" | sed -e 's,^file://,,g')
                mkdir -p $ROOT/$dir
                chroot_mount $dir $dir --bind
                ;;
            *)
                echo "deb $mirror $dist $components" >> $ROOT/etc/apt/sources.list
                ;;
        esac
    done
}

add_mirror() {
    # compatibility function
    echo "WARNING: use of deprecated add_mirror or add_multiple_mirrors"
    echo "function. please update your ltsp-build-client plugins."
    add_mirrors "$@"
}

add_multiple_mirrors() {
   add_mirror "$@" 
}
