feat(apt): read the release each source names, move a file to the host's (NetOrk/netork#2614) #127

Merged
christianmanivong merged 1 commits from feature/apt-source-release into main 2026-11-17 12:44:12 +00:00
Owner

A release upgrade leaves third-party apt sources on the old release. They still answer, so apt says nothing, and their packages stop getting updates once the vendor stops building for that release. z2m-house (Ubuntu 24.04, noble) kept Docker's source on focal and never saw a Docker newer than 28.1.1 (NetOrk/netork#2614).

What changes

  • AptReleaseMixin.get_apt_source_releases(): the host's /etc/os-release (ID, ID_LIKE, VERSION_CODENAME, UBUNTU_CODENAME) and every enabled source apt reads, from sources.list and the *.list / *.sources files of sources.list.d wherever apt-config puts them. Each source carries its file, line, types, URI, suites and components. Commented-out lines and Enabled: no paragraphs are not sources. Read-only, no privileges, one command.
  • AptReleaseMixin.set_apt_source_release(path, release, codename): three steps. read refuses a path that is none of apt's source files. check fetches each new suite's InRelease, else Release, with apt-helper through apt's own proxy; when one is missing, nothing is written. rewrite writes the file whole through the driver's _write_apt_file (root, mode 644), with every suite of release on codename (focal-security → noble-security), enabled lines only. A URI or comment that names the release stays as it is.
  • AptProxyMixin now inherits AptReleaseMixin, so every apt driver (napalm-linux, napalm-proxmox) gets it without a change of its own. It reuses the transports those drivers already supply.
  • Which words are releases is the caller's decision. suite_release only gives the first word of a suite.

Tests

tests/test_apt_releases.py: parsing one-line and deb822 files (options blocks, comments, disabled lines, several URIs and suites, continuation lines, the HTTPS/// cache form), the read command run for real against a temporary apt tree, the rewrite (suffixes, URIs that name the release, prefixes that are not it, disabled paragraphs), and the mixin against a fake host (served / not served, Release fallback, one missing suite keeps the whole file, a path apt does not read is never written, nothing left to move, bad codenames). The full suite passes (1820), and ruff and mypy are clean.

Docs

README, docs/STRUCTURE.md, CHANGELOG (Unreleased).

A release upgrade leaves third-party apt sources on the old release. They still answer, so apt says nothing, and their packages stop getting updates once the vendor stops building for that release. z2m-house (Ubuntu 24.04, noble) kept Docker's source on `focal` and never saw a Docker newer than 28.1.1 (NetOrk/netork#2614). ## What changes - `AptReleaseMixin.get_apt_source_releases()`: the host's `/etc/os-release` (`ID`, `ID_LIKE`, `VERSION_CODENAME`, `UBUNTU_CODENAME`) and every enabled source apt reads, from `sources.list` and the `*.list` / `*.sources` files of `sources.list.d` wherever `apt-config` puts them. Each source carries its file, line, types, URI, suites and components. Commented-out lines and `Enabled: no` paragraphs are not sources. Read-only, no privileges, one command. - `AptReleaseMixin.set_apt_source_release(path, release, codename)`: three steps. `read` refuses a path that is none of apt's source files. `check` fetches each new suite's `InRelease`, else `Release`, with `apt-helper` through apt's own proxy; when one is missing, nothing is written. `rewrite` writes the file whole through the driver's `_write_apt_file` (root, mode 644), with every suite of *release* on *codename* (`focal-security` → `noble-security`), enabled lines only. A URI or comment that names the release stays as it is. - `AptProxyMixin` now inherits `AptReleaseMixin`, so every apt driver (napalm-linux, napalm-proxmox) gets it without a change of its own. It reuses the transports those drivers already supply. - Which words are releases is the caller's decision. `suite_release` only gives the first word of a suite. ## Tests `tests/test_apt_releases.py`: parsing one-line and deb822 files (options blocks, comments, disabled lines, several URIs and suites, continuation lines, the `HTTPS///` cache form), the read command run for real against a temporary apt tree, the rewrite (suffixes, URIs that name the release, prefixes that are not it, disabled paragraphs), and the mixin against a fake host (served / not served, `Release` fallback, one missing suite keeps the whole file, a path apt does not read is never written, nothing left to move, bad codenames). The full suite passes (1820), and ruff and mypy are clean. ## Docs README, `docs/STRUCTURE.md`, CHANGELOG (Unreleased).
christianmanivong added 1 commit 2026-11-17 12:32:01 +00:00
feat(apt): read the release each source names, move a file to the host's (NetOrk/netork#2614)
driver / lint (pull_request) Successful in 12s
driver / standard (pull_request) Successful in 15s
driver / types (pull_request) Successful in 55s
driver / test (3.13) (pull_request) Successful in 1m7s
driver / test (3.12) (pull_request) Successful in 1m16s
driver / lowest (pull_request) Successful in 38s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 2m28s
driver / publish (pull_request) Skipped
f654076560
A release upgrade leaves third-party apt sources on the old release, where they
still answer and their packages stop getting updates once the vendor stops
building for it: z2m-house, Ubuntu 24.04, kept Docker's source on focal and never
saw a Docker newer than 28.1.1.

AptReleaseMixin.get_apt_source_releases() reports the host's /etc/os-release and
every enabled source apt reads, one-line and deb822, with its file, line, types,
URI, suites and components. set_apt_source_release(path, release, codename) moves
every suite of release in one of apt's source files to codename, once each new
suite's InRelease or Release is fetched with apt-helper through apt's own proxy;
where the vendor has none, nothing is written. AptProxyMixin brings it, so every
apt driver has it.
christianmanivong merged commit e729b935a4 into main 2026-11-17 12:44:12 +00:00
Sign in to join this conversation.