apt source multiple urls

This commit is contained in:
cronekorkn 2023-08-01 12:15:49 +02:00
parent 843712d7bf
commit 637ab05590
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
10 changed files with 61 additions and 16 deletions

View file

@ -9,7 +9,13 @@
},
'sources': {
'debian': {
'urls': 'https://deb.debian.org/debian',
'types': { # optional, defaults to `{'deb'}``
'deb',
'deb-src',
},
'urls': {
'https://deb.debian.org/debian',
},
'suites': { # at least one
'{codename}',
'{codename}-updates',

View file

@ -8,7 +8,9 @@ defaults = {
'sources': {
'crystal': {
# https://software.opensuse.org/download.html?project=devel%3Alanguages%3Acrystal&package=crystal
'url': 'https://download.opensuse.org/repositories/devel:/languages:/crystal/Debian_Testing/',
'urls': {
'https://download.opensuse.org/repositories/devel:/languages:/crystal/Debian_Testing/',
},
'suites': {
'/',
},

View file

@ -9,7 +9,9 @@ defaults = {
},
'sources': {
'grafana': {
'url': 'https://packages.grafana.com/oss/deb',
'urls': {
'https://packages.grafana.com/oss/deb',
},
'suites': {
'stable',
},

View file

@ -10,8 +10,13 @@ defaults = {
},
'sources': {
'icinga': {
'types': {'deb', 'deb-src'},
'url': 'https://packages.icinga.com/debian',
'types': {
'deb',
'deb-src',
},
'urls': {
'https://packages.icinga.com/debian',
},
'suites': {
'icinga-{codename}',
},

View file

@ -15,8 +15,13 @@ defaults = {
},
'sources': {
'icinga': {
'types': {'deb', 'deb-src'},
'url': 'https://packages.icinga.com/debian',
'types': {
'deb',
'deb-src',
},
'urls': {
'https://packages.icinga.com/debian',
},
'suites': {
'icinga-{codename}',
},

View file

@ -8,7 +8,9 @@ defaults = {
},
'sources': {
'influxdata': {
'url': 'https://repos.influxdata.com/debian',
'urls': {
'https://repos.influxdata.com/debian',
},
'suites': {
'stable',
},

View file

@ -10,7 +10,9 @@ defaults = {
},
'sources': {
'jfrog': {
'url': 'https://openhab.jfrog.io/artifactory/openhab-linuxpkg',
'urls': {
'https://openhab.jfrog.io/artifactory/openhab-linuxpkg',
},
'suites': {
'stable',
},

View file

@ -10,7 +10,9 @@ defaults = {
},
'sources': {
'influxdata': {
'url': 'https://repos.influxdata.com/debian',
'urls': {
'https://repos.influxdata.com/debian',
},
'suites': {
'stable',
},

View file

@ -13,7 +13,9 @@
'apt': {
'sources': {
'debian': {
'url': 'https://deb.debian.org/debian',
'urls': {
'https://deb.debian.org/debian',
},
'suites': {
'{codename}',
'{codename}-updates',
@ -27,7 +29,9 @@
'key': 'debian-{version}',
},
'debian-security': {
'url': 'https://security.debian.org/',
'urls': {
'https://security.debian.org/',
},
'suites': {
'{codename}-security',
},

View file

@ -1,6 +1,3 @@
# https://manpages.debian.org/latest/apt/sources.list.5.de.html
# https://repolib.readthedocs.io/en/latest/deb822-format.html
from re import match
from glob import glob
from os.path import join, basename, exists
@ -23,6 +20,7 @@ def find_keyfile_extension(node, key_name):
raise Exception(f"no keyfile '{formatted_key_name}.(asc|gpg)' found")
# https://manpages.ubuntu.com/manpages/latest/en/man5/apt.conf.5.html
def render_apt_conf(section, depth=0):
buffer = ''
@ -47,10 +45,27 @@ def render_apt_conf(section, depth=0):
# https://manpages.debian.org/latest/apt/sources.list.5.de.html
# https://repolib.readthedocs.io/en/latest/deb822-format.html
def render_source(node, source_name):
config = node.metadata.get(f'apt/sources/{source_name}')
lines = []
keys_and_types = {
'types': (set, list),
'urls': (set, list),
'suites': (set, list),
'components': (set, list),
'options': dict,
'key': str,
}
for key, value in config.items():
if key not in keys_and_types:
raise Exception(f"{node}: invalid source '{source_name}' conf key: '{key}' (expecting one of: {', '.join(keys_and_types)})")
elif not isinstance(value, keys_and_types[key]):
raise Exception(f"{node}: invalid source '{source_name}' conf value type for '{key}': '{type(value)}' (expecting: '{keys_and_types[key]}')")
# X-Repolib-Name
lines.append(
f'X-Repolib-Name: ' + source_name
@ -63,7 +78,7 @@ def render_source(node, source_name):
# url
lines.append(
f'URIs: ' + config['url']
f'URIs: ' + ' '.join(sorted(config['urls']))
)
# suites