#!/usr/bin/env bash

# universal/essential-packages hash: {{ include (joinPath ".chezmoitemplates" "universal" "essential-packages") | sha256sum }}

{{- includeTemplate "universal/logg" }}

{{- $packages := splitList " " (includeTemplate "universal/essential-packages" .) -}}
{{- $pyenvDependencies := list
"make"
"build-essential"
"libssl-dev"
"zlib1g-dev"
"libbz2-dev"
"libreadline-dev"
"libsqlite3-dev"
"wget"
"curl"
"llvm"
"libncursesw5-dev"
"xz-utils"
"tk-dev"
"libxml2-dev"
"libxmlsec1-dev"
"libffi-dev"
"liblzma-dev"
-}}
{{- if .toolchains.python }}
{{- $packages = concat $packages $pyenvDependencies -}}
{{- end }}
{{- $gpgDependencies := list
gnupg2
gnupg-agent
gnupg-curl
scdaemon
pcscd
-}}
{{- if .toolchains.gpg }}
{{- $packages = concat $packages $gpgDependencies -}}
{{- end }}

logg 'Installing common dependencies using `apt-get`'
logg info 'Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}'

sudo apt-get update
sudo apt-get install -y --no-install-recommends {{ $packages | sortAlpha | uniq | join " " -}}
