From 74baeb4bf4fb63e9a8c21844d3349151316fdb6d Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 24 Sep 2023 15:22:14 +0200 Subject: [PATCH] bundles/apt: suport deb822-style sources --- bundles/apt/files/deb822-sources | 9 ++++++ bundles/apt/items.py | 49 +++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 bundles/apt/files/deb822-sources diff --git a/bundles/apt/files/deb822-sources b/bundles/apt/files/deb822-sources new file mode 100644 index 0000000..c1b8202 --- /dev/null +++ b/bundles/apt/files/deb822-sources @@ -0,0 +1,9 @@ +% for uri in sorted(uris): +Types: ${' '.join(sorted(data.get('types', {'deb'})))} +URIs: ${uri} +Suites: ${os_release} +Components: ${' '.join(sorted(data.get('components', {'main'})))} +Architectures: ${' '.join(sorted(data.get('architectures', {'amd64'})))} +Signed-By: /etc/apt/trusted.gpg.d/${name}.list.asc + +% endfor diff --git a/bundles/apt/items.py b/bundles/apt/items.py index 5dd236d..6adbab1 100644 --- a/bundles/apt/items.py +++ b/bundles/apt/items.py @@ -169,21 +169,44 @@ if node.os_version[0] >= 11: } for name, data in node.metadata.get('apt/repos', {}).items(): - files['/etc/apt/sources.list.d/{}.list'.format(name)] = { - 'content_type': 'mako', - 'content': ("\n".join(sorted(data['items']))).format( - os=node.os, - os_release=supported_os[node.os][node.os_version[0]], - ), - 'triggers': { - 'action:apt_update', - }, - } + if 'items' in data: + files['/etc/apt/sources.list.d/{}.list'.format(name)] = { + 'content_type': 'mako', + 'content': ("\n".join(sorted(data['items']))).format( + os=node.os, + os_release=supported_os[node.os][node.os_version[0]], + ), + 'triggers': { + 'action:apt_update', + }, + } + elif 'uris' in data: + uris = { + x.format( + os=node.os, + os_release=supported_os[node.os][node.os_version[0]], + ) for x in data['uris'] + } + + files['/etc/apt/sources.list.d/{}.sources'.format(name)] = { + 'source': 'deb822-sources', + 'content_type': 'mako', + 'context': { + 'data': data, + 'name': name, + 'os_release': supported_os[node.os][node.os_version[0]], + 'uris': uris, + }, + 'triggers': { + 'action:apt_update', + }, + } if data.get('install_gpg_key', True): - files['/etc/apt/sources.list.d/{}.list'.format(name)]['needs'] = { - 'file:/etc/apt/trusted.gpg.d/{}.list.asc'.format(name), - } + if 'items' in data: + files['/etc/apt/sources.list.d/{}.list'.format(name)]['needs'] = { + 'file:/etc/apt/trusted.gpg.d/{}.list.asc'.format(name), + } files['/etc/apt/trusted.gpg.d/{}.list.asc'.format(name)] = { 'source': 'gpg-keys/{}.asc'.format(name),