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
1diff --git a/curtin/commands/apt_config.py b/curtin/commands/apt_config.py
2index f045163..d2a12d5 100644
3--- a/curtin/commands/apt_config.py
4+++ b/curtin/commands/apt_config.py
5@@ -638,6 +638,11 @@ def _generate_sources_deb822(cfg, release, mirrors, target=None, arch=None):
6 entry['Suites'] = list(set(entry['Suites']) - suites_to_disable)
7 entry['Components'] = list(set(entry['Components']) - comps_to_disable)
8
9+ if not entry['Suites']:
10+ # It is invalid for a stanza to have zero suite configured. In
11+ # practise, it can happen when -security is disabled.
12+ continue
13+
14 stanzas.append(deb822_entry_to_str(entry))
15
16 target_path = paths.target_path(target, sources_deb822)
17diff --git a/tests/unittests/test_apt_source.py b/tests/unittests/test_apt_source.py
18index 6322879..8146c68 100644
19--- a/tests/unittests/test_apt_source.py
20+++ b/tests/unittests/test_apt_source.py
21@@ -1306,7 +1306,14 @@ deb-src http://ubuntu.com//ubuntu xenial universe multiverse
22 'etc/apt/sources.list.d/ubuntu.sources': ((
23 'Types: deb\n'
24 'URIs: $MIRROR\n'
25- 'Suites: $RELEASE $RELEASE-updates $RELEASE-backports\n'
26+ 'Suites: $RELEASE $RELEASE-updates\n'
27+ 'components: main\n'
28+ 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n'
29+ '\n'
30+ # This section should be skipped because -backports is disabled
31+ 'Types: deb\n'
32+ 'URIs: $MIRROR\n'
33+ 'Suites: $RELEASE-backports\n'
34 'components: main\n'
35 'signed-by: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n'
36 '\n'

Subscribers

People subscribed via source and target branches