Select apt packages to install from config.json

This commit is contained in:
Kieron Wilkinson
2024-09-26 21:24:12 +01:00
parent b2eb63f4af
commit 4ffd42fa74
3 changed files with 69 additions and 34 deletions
+44 -1
View File
@@ -2,5 +2,48 @@
"user": {
"user-id": 1001,
"group-id": 121
}
},
"install": [
{
"category": "development",
"source": "apt",
"packages": [
"build-essential",
"zlib1g-dev",
"zstd",
"gettext",
"libcurl4-openssl-dev",
"libpq-dev",
"pkg-config",
"software-properties-common"
]
},
{
"category": "network-tools",
"source": "apt",
"packages": [
"inetutils-ping",
"wget",
"openssh-client",
"rsync"
]
},
{
"category": "nodejs",
"source": "apt",
"packages": [
"nodejs"
]
},
{
"category": "python",
"source": "apt",
"packages": [
"python3",
"python3-pip",
"python3-setuptools",
"python3-venv"
]
}
]
}
+10 -2
View File
@@ -1,10 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
function config_file() {
echo "$(dirname "${BASH_SOURCE[0]}")/config.json"
}
function user_id() {
jq -r '.user."user-id"' "$(dirname "${BASH_SOURCE[0]}")/config.json"
jq -r '.user."user-id"' "$(config_file)"
}
function group_id() {
jq -r '.user."group-id"' "$(dirname "${BASH_SOURCE[0]}")/config.json"
jq -r '.user."group-id"' "$(config_file)"
}
function apt_packages() {
jq -r '.install[] | select(.source == "apt") | .packages[]' "$(config_file)" | paste -sd ' ' -
}
+15 -31
View File
@@ -1,43 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
function install_bootstrap() {
# Required by the build or runner operation
function install_essentials() {
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
jq \
gnupg
gnupg \
tar \
unzip \
zip \
apt-transport-https \
sudo \
dirmngr \
locales \
gosu \
gpg-agent \
dumb-init
}
function install_tools_apt() {
apt-get install -y --no-install-recommends \
tar \
unzip \
zip \
apt-transport-https \
sudo \
gpg-agent \
software-properties-common \
dirmngr \
locales \
dumb-init \
gosu \
build-essential \
zlib1g-dev \
zstd \
gettext \
libcurl4-openssl-dev \
inetutils-ping \
wget \
openssh-client \
python3-pip \
python3-setuptools \
python3-venv \
python3 \
nodejs \
rsync \
libpq-dev \
pkg-config
apt_packages | xargs apt-get install -y --no-install-recommends
}
function remove_caches() {
@@ -61,7 +45,7 @@ source "$scripts_dir/tools.sh"
source "$scripts_dir/config.sh"
apt-get update
install_bootstrap
install_essentials
configure_sources
apt-get update