feat: AptProxyMixin, what apt fetches through and pointing it at a proxy (NetOrk/netork#1397)
CI / test (3.10) (push) Successful in 31s
CI / test (3.11) (push) Successful in 30s
CI / test (3.12) (push) Successful in 30s
CI / test (3.13) (push) Successful in 33s
CI / test (3.10) (pull_request) Successful in 30s
CI / test (3.11) (pull_request) Successful in 28s
CI / test (3.12) (pull_request) Successful in 29s
CI / test (3.13) (pull_request) Successful in 29s

apt reads apt.conf.d in order and apt.conf last; the last value wins. The
Debian installer writes its proxy into apt.conf, Ubuntu's into
90curtin-aptproxy: reading 00proxy alone missed both, and a fix that wrote
00proxy and read it back reported success while apt fetched elsewhere.

- get_package_proxy_report(): apt-config dump's proxy, per-host overrides,
  auto-detect, every line of apt's files that sets it (in reading order,
  editable or inside a block), the http and https sources.
- check_package_proxy(url, expect): a fetch with apt-helper, past any proxy;
  an HTTP error counts as an answer.
- configure_package_proxy(url): write 00proxy, comment out other proxy
  lines, read apt's proxy back, fetch one InRelease through it.
- same_proxy_url(): scheme, host and port, a trailing slash aside.

A driver supplies _run_apt_command, _run_apt_root_command and
_write_apt_file. Version 4.22.0.
This commit is contained in:
christianmanivong committed 2026-10-22 19:16:40 +02:00
1 parent ac8e7c4c11
commit d7ec558933
6 files changed
+940 -1

No files matched your search

+9
View File
@@ -130,6 +130,15 @@ that binary links against. An application needs it to let a statement about a se
(the postgresql unit) reach the findings on its packages. A driver supplies
`_run_service_packages_command`.
`AptProxyMixin` (`napalm_device_types.apt_proxy`, since 4.22) is `PackageProxyMixin` for a
Debian-family host, mixed in the same way. What apt fetches through is what `apt-config dump`
says, not one file: apt reads `apt.conf.d` in order and `apt.conf` last, and the last value
wins (`get_package_proxy`, `get_package_proxy_report` with every line that sets it).
`check_package_proxy(url, expect)` fetches a page with apt's own downloader, past any proxy.
`configure_package_proxy(url)` writes `00proxy`, comments out every other line that sets a
different proxy, reads the result back and fetches one http source's `InRelease` through it.
A driver supplies `_run_apt_command`, `_run_apt_root_command` and `_write_apt_file`.
`HostStatusMixin` (`get_host_status`) is mixed in the same way: whether a Linux host needs
a reboot to finish an update (`/var/run/reboot-required`, `needs-restarting -r`, or a newer
kernel of the running flavour installed), whether it patches itself (unattended-upgrades,