Merge ~ogayot/curtin:deb822-no-suite-stanza into curtin:master

Proposed by Olivier Gayot
Status: Merged
Approved by: Dan Bungert
Approved revision: 29b3faf7c30eea08e5a955d9a9fbe3a32846e314
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~ogayot/curtin:deb822-no-suite-stanza
Merge into: curtin:master
Diff against target: 36 lines (+13/-1)
2 files modified
curtin/commands/apt_config.py (+5/-0)
tests/unittests/test_apt_source.py (+8/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
curtin developers Pending
Review via email: mp+450893@code.launchpad.net

Commit message

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 address hidden>

Description of the change

Prevent creation of invalid deb822 source when no suite is configured.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dan Bungert (dbungert) wrote :

Same, unit test please. Thanks!

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

Commit message lints:
- Line #11 has 9 too many characters. Line starts with: "E: Malformed entry 2"...

review: Needs Fixing
Revision history for this message
Server Team CI bot (server-team-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
index f045163..d2a12d5 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):
638 entry['Suites'] = list(set(entry['Suites']) - suites_to_disable)638 entry['Suites'] = list(set(entry['Suites']) - suites_to_disable)
639 entry['Components'] = list(set(entry['Components']) - comps_to_disable)639 entry['Components'] = list(set(entry['Components']) - comps_to_disable)
640640
641 if not entry['Suites']:
642 # It is invalid for a stanza to have zero suite configured. In
643 # practise, it can happen when -security is disabled.
644 continue
645
641 stanzas.append(deb822_entry_to_str(entry))646 stanzas.append(deb822_entry_to_str(entry))
642647
643 target_path = paths.target_path(target, sources_deb822)648 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 6322879..8146c68 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
1306 'etc/apt/sources.list.d/ubuntu.sources': ((1306 'etc/apt/sources.list.d/ubuntu.sources': ((
1307 'Types: deb\n'1307 'Types: deb\n'
1308 'URIs: $MIRROR\n'1308 'URIs: $MIRROR\n'
1309 'Suites: $RELEASE $RELEASE-updates $RELEASE-backports\n'1309 'Suites: $RELEASE $RELEASE-updates\n'
1310 'components: main\n'
1311 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n'
1312 '\n'
1313 # This section should be skipped because -backports is disabled
1314 'Types: deb\n'
1315 'URIs: $MIRROR\n'
1316 'Suites: $RELEASE-backports\n'
1310 'components: main\n'1317 'components: main\n'
1311 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n'1318 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n'
1312 '\n'1319 '\n'

Subscribers

People subscribed via source and target branches