Skip to content

feat(selfupdate): update .deb installs through a registered APT repository - #21

Merged
dgrieser merged 2 commits into
mainfrom
feat/selfupdate-apt
Nov 25, 2026
Merged

dgrieser merged 2 commits into
mainfrom
feat/selfupdate-apt

Conversation

@dgrieser

Copy link
Copy Markdown
Collaborator

Summary

selfupdate refused every executable a package manager owns. A .deb from an APT repository that is registered on the system (for example one whose package adds the repository on install) can now be updated through APT, opt-in via Updater.APT.

  • Detection: managed path as before, plus: Linux, the repository's sources file exists, and dpkg-query --search names exactly one owner (no diversion; merged-/usr aliases handled; architecture qualifier kept).
  • Check without Source: the repository's index is fetched without root into a temporary directory (Dir::State::Lists, Dir::Cache, Dir::Etc::sourcelist limited to the sources file). The latest version is APT's candidate, and the package must be listed by apt-cache madison, so the installed version never passes for the latest. A failed fetch is an error (APT::Update::Error-Mode=any, plus a check that an index arrived). Source and Asset are not needed on this path, so no GitLab/GitHub token.
  • Install: the .deb is downloaded without root from the repository (APT checks it against the signed index). After APT.Confirm approves the plan, apt-get update and apt-get install --yes --allow-downgrades -- <file> run as root (through sudo -- when not root), so dependencies come from all of the system's repositories. The installed version is checked afterwards.
  • Confirm: gets an APTPlan (package, installed, target version, file, sudo, commands; String() prints them shell-quoted). False ends with ErrDeclined; nil runs without asking (--yes).

Testing

  • Unit tests with a faked dpkg/apt (selfupdate/apt_test.go), race, Go 1.27.0, lint on linux/darwin/windows, cross builds.
  • In debian:trixie-slim against the real mittwald-tools repository: 0.1.12 → 0.1.13 of mittwald-outlook-bridge-headless as a user via sudo and as root; declined; already current; APT::Default-Release set system-wide; unreachable repository (error, no false "up to date").

🤖 Generated with Claude Code

dgrieser and others added 2 commits November 25, 2026 17:24
…itory

An executable a .deb installed was always refused with ErrManaged. With
Updater.APT set, one whose package comes from an APT repository that is
registered on the system is updated through APT instead:

- Check, Update and Install read the latest version from that repository,
  not from Source, so no Source credential is needed.
- The repository's index and the package are fetched without root into a
  temporary directory, limited to the repository's sources file; APT
  verifies both against the repository key.
- APT.Confirm is shown the exact commands (apt-get update, apt-get install
  of the downloaded file) before they run as root, through sudo when the
  process is not root. Nil Confirm installs without asking, for --yes.

Anything else (no sources file, no single dpkg owner, not Linux) is still
refused with ErrManaged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows temporary paths hold backslashes, which APTPlan.String quotes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dgrieser
dgrieser merged commit ca318cd into main Nov 25, 2026
14 checks passed
@dgrieser
dgrieser deleted the feat/selfupdate-apt branch November 25, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant