diff options
| author | Olivier Gayot <[email protected]> | 2023-09-08 16:34:50 +0000 |
|---|---|---|
| committer | Server Team CI Bot <[email protected]> | 2023-09-08 16:34:50 +0000 |
| commit | d5f5dde574aca60935fc9e1acf9cb669e24f22de (patch) | |
| tree | d73de9ae2581af397318ba4696634a40801b66b5 | |
| parent | 307b32f7bf7eebc32f81b1f0f2f17184a7cffb22 (diff) | |
apt_source: do not produce a deb822 source stanza with zero suite
When no suite is set for a given repository, we end up with a
deb822 styled source such as:
Type: deb
Suites:
URIs: http://archive.ubuntu.com/ubuntu
This is invalid and apt/apt-get will raise the following error:
E: Malformed entry 2 in sources file
/etc/apt/sources.list.d/ubuntu.sources (Suite)
Signed-off-by: Olivier Gayot <[email protected]>
| -rw-r--r-- | curtin/commands/apt_config.py | 5 | ||||
| -rw-r--r-- | tests/unittests/test_apt_source.py | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py index f045163e..d2a12d5c 100644 --- a/curtin/commands/apt_config.py +++ b/curtin/commands/apt_config.py @@ -638,6 +638,11 @@ def _generate_sources_deb822(cfg, release, mirrors, target=None, arch=None): entry['Suites'] = list(set(entry['Suites']) - suites_to_disable) entry['Components'] = list(set(entry['Components']) - comps_to_disable) + if not entry['Suites']: + # It is invalid for a stanza to have zero suite configured. In + # practise, it can happen when -security is disabled. + continue + stanzas.append(deb822_entry_to_str(entry)) target_path = paths.target_path(target, sources_deb822) diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py index 63228790..8146c688 100644 --- a/tests/unittests/test_apt_source.py +++ b/tests/unittests/test_apt_source.py @@ -1306,7 +1306,14 @@ deb-src http://ubuntu.com//ubuntu xenial universe multiverse 'etc/apt/sources.list.d/ubuntu.sources': (( 'Types: deb\n' 'URIs: $MIRROR\n' - 'Suites: $RELEASE $RELEASE-updates $RELEASE-backports\n' + 'Suites: $RELEASE $RELEASE-updates\n' + 'components: main\n' + 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' + '\n' + # This section should be skipped because -backports is disabled + 'Types: deb\n' + 'URIs: $MIRROR\n' + 'Suites: $RELEASE-backports\n' 'components: main\n' 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' '\n' |
