summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--curtin/commands/apt_config.py5
-rw-r--r--tests/unittests/test_apt_source.py9
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'