From ab14522e979e80b28b7357d336a3ebce03cad523 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 19 Jun 2021 09:04:05 +0200 Subject: [PATCH] wip --- bundles/apt/items.py | 23 ++++++++++------------- bundles/apt/metadata.py | 26 ++++++++++++++++++++++++++ bundles/gcloud/metadata.py | 1 + 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/bundles/apt/items.py b/bundles/apt/items.py index 1d19c32..17856bd 100644 --- a/bundles/apt/items.py +++ b/bundles/apt/items.py @@ -1,5 +1,4 @@ -from glob import glob -from os.path import join, basename +from os.path import join directories = { '/etc/apt/sources.list.d': { @@ -36,17 +35,15 @@ for name, content in node.metadata.get('apt/sources').items(): 'action:apt_update', }, } - - matches = glob(join(repo.path, 'data', 'apt', 'keys', f'{name}.*')) - if matches: - assert len(matches) == 1 - files[f'/etc/apt/trusted.gpg.d/{basename(matches[0])}'] = { - 'source': matches[0], - 'content_type': 'binary', - 'triggers': { - 'action:apt_update', - }, - } + +for key in node.metadata.get('apt/keys'): + files[f'/etc/apt/trusted.gpg.d/{key}'] = { + 'source': join(repo.path, 'data', 'apt', 'keys', key), + 'content_type': 'binary', + 'triggers': { + 'action:apt_update', + }, + } for package, options in node.metadata.get('apt/packages', {}).items(): diff --git a/bundles/apt/metadata.py b/bundles/apt/metadata.py index 9919741..0ae931e 100644 --- a/bundles/apt/metadata.py +++ b/bundles/apt/metadata.py @@ -1,6 +1,32 @@ +from glob import glob +from os.path import join, basename + defaults = { 'apt': { 'packages': {}, 'sources': {}, + 'keys': [], }, } + + +@metadata_reactor.provides( + 'apt/keys', +) +def keys(metadata): + keys = [] + + for name in node.metadata.get('apt/sources'): + matches = glob(join(repo.path, 'data', 'apt', 'keys', f'{name}.*')) + + if matches: + assert len(matches) == 1 + keys.append(basename(matches[0])) + + return { + 'apt': { + 'keys': keys, + }, + } + + diff --git a/bundles/gcloud/metadata.py b/bundles/gcloud/metadata.py index 80a08a2..9817faf 100644 --- a/bundles/gcloud/metadata.py +++ b/bundles/gcloud/metadata.py @@ -4,6 +4,7 @@ defaults = { 'apt-transport-https': {}, 'ca-certificates': {}, 'gnupg': {}, + 'google-cloud-sdk': {}, }, 'sources': { 'gcloud': 'deb https://packages.cloud.google.com/apt cloud-sdk main',