#!/bin/bash

set -u # Error on unset variables
set -e # Exit immediately if a command returns non-zero

export DEBIAN_FRONTEND=noninteractive

mapfile -t sources_files <<< "$(find /etc/apt/sources.list* -type f)"

test -n "${UBUNTU_REPO_OVERRIDE:=}" && sed -E -i "s/(archive|security).ubuntu.com/${UBUNTU_REPO_OVERRIDE}/" "${sources_files[@]}"

apt-get -q update

packages=(
    build-essential
    debhelper
    devscripts
    dh-python
    git
    libdatrie1
    libdbus-1-dev
    libgmp-dev
    libidn11-dev
    libnetfilter-conntrack-dev
    libpcap-dev
    libyajl2
    m4
    nettle-dev
    python3-all
    python3-setuptools
    texinfo
)

apt-get install -y -q "${packages[@]}"

apt-get clean -y
