#!/bin/bash

export DEBIAN_FRONTEND=noninteractive

find "/etc/apt/sources.list.d/" -type f -exec sed -i "s|http://[a-zA-Z0-9_.]\+/|http://mirror.yandex.ru/|g" {} \;

apt-get update

# locales
apt-get install -y locales
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

TZ=Europe/Moscow
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone

# base soft
apt-get install -y \
"^libxcb.*" \
bison \
ccache \
cpio \
curl \
debconf \
debhelper \
default-libmysqlclient-dev \
doxygen \
dpkg \
flex \
g++ \
git \
gperf \
graphviz \
htop \
iputils-ping \
libbz2-dev \
libffi-dev \
libfontconfig1-dev \
libfreetype6-dev \
libgl1-mesa-dev \
libglew-dev \
libglu1-mesa-dev \
libgmp-dev \
libicu-dev \
libmpc-dev \
libmpfr-dev \
libncurses-dev \
libpkgconfig-perl \
libpq-dev \
libreadline-dev \
libssl-dev \
libusb-1.0-0-dev \
libwayland-dev \
libx11-dev \
libx11-xcb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev \
libxml2-dev \
libxrender-dev \
lsb-release \
mc \
md5deep \
nano \
net-tools \
ninja-build \
ocl-icd-opencl-dev \
p7zip-full \
patchelf \
python3 \
screen \
subversion \
unzip \
wget \
zip \
zlib1g-dev \
libhdf5-dev \
libcurl4-openssl-dev \
libpcsclite-dev

# install qt if not build it from source
if [[ -n "$1" && "$1" != "1" ]]; then
	apt-get install -y \
	qt6-tools-dev \
	qt6-tools-private-dev \
	qt6-declarative-dev \
	qt6-positioning-dev \
	qt6-datavisualization-dev \
	qt6-serialport-dev \
	qt6-serialbus-dev \
	qt6-charts-dev
fi

apt-get install -y lzma-dev || true
apt-get install -y python3-future || true
apt-get install -y python3-click || true
apt-get install -y python3-cryptography || true
apt-get install -y python3-pip || true
apt-get install -y python3-pyelftools || true
apt-get install -y python3-pyparsing || true
apt-get install -y python3-serial || true
apt-get install -y python3-setuptools || true

apt-get install -y libopencv-dev

# cleanup
rm -rf /var/cache/apt/archives/*
