distupgrade: Handle comments in sources.list file

Tests:

- Add a comment and /etc/apt/sources.list file. Distribution upgrade page does
not load and fails with an error.

- With the patch, page loads properly. Distribution upgrade can be triggered.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[jvalleroy: Fix test for release date]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-07-31 22:48:02 -07:00 committed by James Valleroy
parent 8eb33e9c78
commit 0bf14948b2
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 4 additions and 1 deletions

View File

@ -116,6 +116,9 @@ def _get_sources_list_codename() -> str | None:
dists = set()
for match_ in aug.match('*'):
dist = aug.get(match_ + '/distribution')
if not dist:
continue
dist = dist.removesuffix('-updates')
dist = dist.removesuffix('-security')
dists.add(dist)

View File

@ -190,7 +190,7 @@ def test_get_status(check_auto, is_dist_upgrade_enabled,
assert status['current_release_date'] == current_date
assert status['next_codename'] == 'trixie'
assert status['next_version'] == 13
next_date = datetime_original(2025, 8, 20, tzinfo=timezone.utc)
next_date = datetime_original(2025, 8, 9, tzinfo=timezone.utc)
assert status['next_release_date'] == next_date
assert status['next_action'] == 'manual'