From 94d32c7b75a248f9ebd9d40a23f14faf3c324fd7 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Fri, 28 Apr 2023 10:09:34 +0000 Subject: [PATCH] Squashed 'alpine-cloud-images/' changes from 759d473..59d83fd 59d83fd Rename option, add docs 1c04440 Support for custom Alpine repo keys, which allows package install from them via simple overlay config rather than having to script the install as postinstall git-subtree-dir: alpine-cloud-images git-subtree-split: 59d83fdf536c111dd48525430a6ce3d4028d6f8b --- CONFIGURATION.md | 5 +++++ alpine.pkr.hcl | 1 + image_config.py | 1 + scripts/setup | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 3466ed2..00d9fee 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -307,3 +307,8 @@ region, `true` or `false`/`null`. Determines whether the image will be encrypted when imported and published. Currently, only the **aws** cloud module supports this. + +### `repo_keys` array + +List of addtional repository keys to trust during the package installation phase. +This allows pulling in custom apk packages by simple specifying the repository name in packages block. diff --git a/alpine.pkr.hcl b/alpine.pkr.hcl index cc588fe..0e8fb27 100644 --- a/alpine.pkr.hcl +++ b/alpine.pkr.hcl @@ -174,6 +174,7 @@ build { "PACKAGES_NOSCRIPTS=${B.value.packages.noscripts}", "RELEASE=${B.value.release}", "REPOS=${B.value.repos}", + "REPO_KEYS=${B.value.repo_keys}", "SERVICES_ENABLE=${B.value.services.enable}", "SERVICES_DISABLE=${B.value.services.disable}", "VERSION=${B.value.version}", diff --git a/image_config.py b/image_config.py index 69a5be7..59dd3bd 100644 --- a/image_config.py +++ b/image_config.py @@ -151,6 +151,7 @@ class ImageConfig(): # stringify arrays self.name = '-'.join(self.name) self.description = ' '.join(self.description) + self.repo_keys = ' '.join(self.repo_keys) self._resolve_motd() self._resolve_urls() self._stringify_repos() diff --git a/scripts/setup b/scripts/setup index 8f00d29..1c826c7 100755 --- a/scripts/setup +++ b/scripts/setup @@ -71,6 +71,12 @@ install_base() { mkdir -p "$TARGET/etc/apk" echo "$REPOS" > "$TARGET/etc/apk/repositories" cp -a /etc/apk/keys "$TARGET/etc/apk" + + # shellcheck disable=SC2086 + for key in $REPO_KEYS; do + wget -q $key -P "$TARGET/etc/apk/keys" + done + # shellcheck disable=SC2086 apk --root "$TARGET" --initdb --no-cache add $PACKAGES_ADD # shellcheck disable=SC2086