echo "Install deps..."
repo_list=/etc/apt/sources.list.d/temp_repo.list
echo "deb [trusted=yes] file:$(pwd)/deps ./" > $repo_list

# Non-interactive: without this, maintainer scripts that ask debconf
# questions (e.g. kexec-tools' "Should kexec-tools handle reboots?") block
# waiting for input instead of taking their default. We explicitly preseed
# kexec-tools to "false" too - we don't want it hijacking every normal
# reboot, only the on-demand kexec the re-image tool triggers itself
# (package/.../trigger-reimage.sh).
export DEBIAN_FRONTEND=noninteractive
echo "kexec-tools kexec-tools/load_kexec boolean false" | debconf-set-selections

# Extract Version and Architecture from metadata.txt
VERSION=$(grep '^Version:' METADATA.txt | awk '{print $2}')
apt-get update -o Dir::Etc::sourcelist=$repo_list -o Dir::Etc::sourceparts=/dev/null
# apt-get install -y systemd-timesyncd
apt-get install -y --reinstall --allow-downgrades retina-websq=$VERSION

rm $repo_list
apt-get autoremove -y
apt-get clean -y