Repository navigation
feat(update): tell system package installs about new releases, sooner - #314
Conversation
CLIs installed from the apt, yum/dnf or apk repositories did not check for or announce new releases, on the assumption that the OS updates them. Third-party repositories are not covered by unattended upgrades by default, so these users only got a release when they happened to upgrade. - Check and notify for package installs. The package manager is the one whose database owns the executable (dpkg, rpm, apk), asked only before printing a notice; for RPM it is dnf if on PATH, or else yum. The install methods are now apt, dnf, yum and apk, with "package" for an unknown package manager (generic link). - Add the wrapper.package_name config key, and suggest a command that refreshes the index and upgrades the package, with sudo unless root. - Make the weekly throttle per version: a version newer than the one last announced (notified_version in the state) is announced at once. - Announce a release at the end of the run whose background check found it, if the check finished in time, rather than on the next run. The package repositories are updated by the release workflow within a minute of the GitHub release, so the GitHub check is used as is. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 2 warnings · 🔵 2 minor points
🔍 Full review · 14 files reviewed
Verification
StartUpdateChecksavesKnownLatestVersionbeforeclose(done), so whenWaitreturns true, the exit-timePendingNotificationreads the new version.- The
shownflag stops the exit-time call from repeating a notice already shown before the command's output, and quiet mode skips both calls. notificationFromStatethrottles a version for a week only whenNotifiedVersionis at least as new; an emptyNotifiedVersionkeeps the old weekly behaviour.- No caller of the removed
AutoUpdating/IsAutoUpdating/pkgOwnedsymbols remains in the tree. rpmFrontendprefers dnf over yum and falls back topackagewhen neither is on PATH (e.g. zypper).
The diff adds unit tests for upgradeCommandFor/packageUpgradeCommand, detectInstallMethod with an injected pkgManager, rpmFrontend, parseMethod, the per-version throttle and Wait's return value; CI's make test-go step in ci.yml runs them. Nothing tests the real owningPackageManager subprocess queries or the exit-time notice path in finishUpdateCheck.
Review details
- Commit: 1eaf5e5
- Model: claude-opus-5-5
Review 1 of 10 for this pull request · View the full run
CLI buildsBuilt from 3b2876f (merged into the base branch). Downloads need a GitHub login, and expire after 7 days.
Or download one with the GitHub CLI, e.g.: gh run download 44599565815 -R upsun/cli -n cli-linux-amd64
chmod +x upsun
./upsun --versionOn macOS, if you downloaded it with a browser, remove the quarantine attribute before running it: |
Address review findings on the package install notice: - A downloaded package (installed with dpkg -i, rpm -i or apk add --allow-untrusted) is owned by the package database, but cannot be upgraded with the package manager. The method is now only apt, dnf, yum or apk if the package manager's configuration mentions the host of the repository (the new wrapper.package_repository config key). Otherwise it is "package", which gets the generic link. - The yum command now runs "yum clean expire-cache" first, as yum otherwise uses its cached metadata for hours. - Suggest doas instead of sudo if doas is installed and sudo is not, as is usual on Alpine. - Correct the design document on manual package installs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 9 files reviewed
Verification
packageMethodreturns before callingrepoInUsewhenpkgRepois empty or the owner is unknown/package, so test probes withoutrepoInUsenever call a nil func.installer.shwriteshttps://repositories.upsun.comintoupsun.list,upsun.repoand/etc/apk/repositories, so the substringwrapper.package_repository: repositories.upsun.commatches what the installer configures.privilegeCommandreturnsdoasonly whensudois missing anddoasis present, and returns no prefix for root;TestPrivilegeCommandcovers all four combinations.- The yum command now starts with
yum clean expire-cache, and both parts get the privilege prefix, as the updatedTestUpgradeCommandForcase expects.
This diff adds or updates unit tests: TestDetectInstallMethod gains cases for a repository that is not in use and for a missing repository config, plus new TestAnyFileContains, TestPrivilegeCommand and TestPackageUpgradeCommandPrivilege. They run under make test-go. No test covers commented-out or disabled repository entries.
Review 2 of 10 for this pull request · View the full run
The repository counted as in use if its host appeared anywhere in the package manager's configuration, including in entries that a release upgrade commented out, in backup files, and in disabled repositories. - Skip comment lines. - Only read the files that apt and apk read (*.list, *.sources). - Skip a file that disables a repository (enabled=0, Enabled: no). The file is not parsed to find out which one, so this errs towards the generic link. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Reviewed — No blocking findings · 🔵 1 minor point
🔁 Incremental · 4 files reviewed
🔵 Minor point
internal/install.go:178—repoDisabledonly recognises0|no|false. dnf/libdnf also acceptsoffforenabled=, and apt's deb822Enabled:field also acceptsoffanddisable. Take a repo file that containsbaseurl=https://repositories.upsun.com/...andenabled=off, or a .sources stanza withEnabled: off:enablesRepostill returns true.packageMethodthen returnsdnf/yum/aptinstead ofpackage, and the notice suggests an upgrade command that finds nothing to upgrade.
Verification
- The apt globs now take only
*.listand*.sources, so*.list.distUpgradebackups no longer count (tested byTestAnyFileEnablesRepo). enablesRepotrims each line before testing for#, so indented comment lines in /etc/apk/repositories are skipped.- The Upsun repo files written by installer.sh and docs/install.md have a single section with
enabled=1, so the 'any disabled section voids the file' rule does not misclassify them. - Removing the
bytesimport leaves nothing that still uses it;regexpis now imported and used.
New table-driven TestEnablesRepo and the rewritten TestAnyFileEnablesRepo in internal/install_test.go cover comments, disabled deb822/yum entries and backup-file exclusion; they run under make test-go. Nothing tests the other ways of writing 'disabled' (such as off) or files that hold several repos.
Review 3 of 10 for this pull request · View the full run
dnf also accepts "off" for enabled=, and apt's deb822 Enabled: field also accepts "off" and "disable". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 2 files reviewed
Verification
- The widened
repoDisabledregex is still anchored with^…$and(?i), soenabled=offandEnabled: disablematch only as whole lines, ignoring case. - The two new
TestEnablesRepocases both put a matching repository URL first and a disabling line after it. They show that a disabling line wins over an earlier mention.
TestEnablesRepo gets two new table cases in internal/install_test.go, covering enabled=off (yum) and Enabled: disable (deb822). CI runs them through make test-go. Nothing covers apt's without spelling.
Review 4 of 10 for this pull request · View the full run
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With DNF 5, "dnf config-manager" disables a repository in /etc/dnf/repos.override.d rather than in its file in /etc/yum.repos.d, so a disabled repository still got the dnf upgrade command. For dnf, the override files (also in /usr/share/dnf5/repos.override.d) are now read as DNF applies them: by file name, section names as glob patterns, and the last "enabled" setting wins. Also make TestUpgradeCommandFor independent of whether the host has sudo or doas, and update two comments on install-method detection. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 5 files reviewed
Verification
TestUpgradeCommandFornow stubslookPath, so its expectedsudostrings no longer depend on whether the test host has sudo or doas installed.- In
privilegeCommand, the parameter namedlookPathshadows the new package variable, and the caller passes the variable in explicitly, so behaviour is unchanged. repoSectionsresetssectionafter its first match, so each section ID appears once. Commented lines are skipped, matchingenablesRepo.anyFileEnablesRepokeeps the old behaviour when no override patterns are given, becauselen(overrides) == 0returns true straight away.
This increment adds TestAnyFileEnablesRepoWithOverrides, which runs table-driven cases against temporary directories: override files that disable or re-enable the repository, glob section names, ordering by file name across the two directories, and non-.repo files. It updates TestAnyFileEnablesRepo and TestUpgradeCommandFor. No test covers two override files with the same name.
Review 6 of 10 for this pull request · View the full run
DNF 5 reads only the /etc/dnf/repos.override.d file when a file of the same name exists in /usr/share/dnf5/repos.override.d. Both were read, so a repository disabled in a masked file counted as disabled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n files The update message code moves from commands/root.go to commands/update_message.go. The closure that showed the message becomes a type, updateNotifier, with tests for: the message before or after the command's output, showing it once, quiet mode, and recording a version whose message was not printed. The parsing of package repository configuration moves from internal/install.go to internal/package_repo.go, with its tests. No change in behavior. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Split owningPackageManager into packageOwner, which takes the command lookup and runner as arguments, and test its query order, the choice of dnf or yum for an RPM, and a timeout counting as owned. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Reviewed — No blocking findings · 🔵 1 minor point
🔍 Full review · 18 files reviewed
🔵 Minor point
internal/update.go:68— The doc comment onStartUpdateCheck, just above this hunk ("The result is cached in the state, for PendingNotification to read in a later invocation"), is now out of date.finishUpdateCheckcallsPendingNotificationin the same run onceWaitreports the check finished, so the result is no longer read only by a later invocation. The PR rewrote the matching comment incommands/root.gobut left this one unchanged.
Verification
updateNotifier.shownstops a second notice: when the start-of-run notice has printed, the exit notice infinishUpdateCheckdoes not print again, even thoughExecuteandexitWithErrorcan both call it.readOverrideskeys override files by base name, reading/usr/share/dnf5before/etc/dnf, so a same-named/etcfile masks the vendor file as DNF 5 does.packageMethodonly returns apt/dnf/yum/apk whenrepoInUsefinds the configured repository host, and otherwise returnspackage, whichupgradeCommandForturns into the generic link.newerThanNotifiedtreats an emptyNotifiedVersion(state saved by an older CLI) as not newer, so the weekly throttle still applies after an upgrade from an older version.
New unit tests cover the change: TestUpdateNotifier, TestUpgradeCommandFor, TestPrivilegeCommand, TestPackageOwner, TestRPMFrontend, TestAnyFileEnablesRepo(WithOverrides), TestEnablesRepo and new throttle cases in TestNotificationFromState. They run in the test job of .github/workflows/ci.yml. Nothing automated tests the real dpkg/rpm/apk queries or the real files under /etc; the PR describes only manual container testing for those.
Review details
- Commit: 7cb0a77
- Model: claude-opus-5-5
Review 10 of 10 for this pull request · View the full run
The cached result is now also read in the same run, once the check has finished, not only in a later invocation. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…he package Replace the scan of repository configuration files for the repository's host with the package manager's own queries, run without network access: - apt: `apt-cache policy` lists a source other than the dpkg status file - apk: `apk --no-network policy` lists a source other than the installed database - dnf: the installed package's `from_repo` is an enabled repository - yum: `yum info installed` has a `From repo` that is an enabled repository These use the package manager's parsing of its configuration, and dnf and yum record where the package came from. Any enabled repository that provides the package counts, so the `wrapper.package_repository` config key is removed. Without an index (apt lists, apk's cache), apt and apk do not list the repository, so the notice gets the generic link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ownership query only finds that some package owns the executable. If it was another package, and the configured package was available in a repository, `apt-cache policy` and `apk policy` listed the repository, and the notice suggested an upgrade command that does nothing. Also require the dpkg status file (apt) or the installed database (apk) as a source, as dnf and yum already query the installed package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dnf and yum check that the package was installed from a repository that is still enabled, not that an enabled repository provides it: a package installed with `rpm -i`, from a repository added later, gets the generic link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@upsun-dispatch review |
There was a problem hiding this comment.
Note
Reviewed — No blocking findings · 🔵 1 minor point
🔍 Full review · 18 files reviewed · cc06b6d
Verification
updateNotifier.showsetsshownbefore printing, so a notice shown at the start is not repeated by the exit-time call infinishUpdateCheck.- Each exit path (
Execute, theexitErrorbranch, bothexitWithErrorbranches,--version) callsfinishUpdateCheckexactly once beforeos.Exitor return. aptSourcedoes not match version rows such as5.16.0 500or*** 5.17.0 100, and theisNumberguard skips a version that is all digits, so only source rows setinstalled/repo.newerThanNotifiedtreats an emptyNotifiedVersionfrom older state files as not newer, so the old weekly throttle still applies after an upgrade.IsAutoUpdating,AutoUpdatingandpkgOwnedhave no remaining Go callers; only the historical sections of the design doc mention them.
New unit tests cover the new code: update_message_test.go (upgrade commands, privilege selection, notifier start and exit behaviour), install_test.go (packageOwner, rpmFrontend, override parsing), package_repo_test.go (apt/apk/dnf/yum output parsing, using captured output) and update_test.go (per-version throttle, Wait's return value), and they run under make test-go. No test runs the real package manager queries; the PR description reports manual checks in containers instead.
A notice shown at exit ran the install method detection (package manager queries of up to 3 seconds in total) after the command had finished, on top of the 1 second wait for the check. The background check now runs the detection itself when it finds a release to announce, while the command runs. The wait for the check is then the only delay at exit: if detection has not finished within it, the notice is left for a later run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
CLIs installed from the apt, yum/dnf or apk repositories did not check for or announce new releases, on the assumption that the OS updates them. Third-party repositories are not covered by unattended upgrades by default, so these users only got a release when they happened to upgrade.
Changes
Package installs are notified. The package manager is the one whose database owns the executable (
dpkg-query -S,rpm -qf,apk info --who-owns), asked only before printing a notice. For RPM it isdnfif onPATH, or elseyum. The install methods are nowapt,dnf,yumandapk;packageremains for an unknown package manager, which gets the generic link.Downloaded packages get the generic link. A package installed with
dpkg -i,rpm -iorapk add --allow-untrustedcannot be upgraded with the package manager. So the method ispackageunless the package manager reports, without network access, that the package is installed and comes from an enabled repository:apt-cache policylists/var/lib/dpkg/status(the package is installed) and another sourceapk --no-network policylistslib/apk/db/installed(the package is installed) and another sourcefrom_repois indnf -C repolist --enabledFrom repoofyum -C info installedis inyum -C repolist enabledFor dnf and yum, this is the repository the package was installed from, so a package installed with
rpm -i, from a repository added later, gets the generic link.Without an index (apt's package lists, apk's cache), apt and apk do not list the repository, so the generic link is shown.
New config key
wrapper.package_name. The suggested command refreshes the index and upgrades the package, withsudounless running as root (ordoas, if it is installed andsudois not):apt update && apt install --only-upgrade upsun-clidnf upgrade --refresh upsun-cliyum clean expire-cache && yum upgrade upsun-cliapk add --upgrade --update-cache upsun-cliPer-version throttle. A version newer than the one last announced (
notified_versionin the state) is announced without waiting for the weekly interval, which now only applies to reminders.Same-run notice. If the background check finishes before the command exits (it was already waited for, for up to 1 second), a release it found is announced at the end of that run, rather than on the next one.
The package repositories are updated by the release workflow straight after the GitHub release (for v5.17.0, all three within a minute), so the GitHub check is used as is. If that upload fails, the suggested command finds nothing to upgrade.
Behavior changes
<PREFIX>INSTALL_METHOD=apt(ordnf,yum,apk) now selects that command, instead of silencing the notice.<PREFIX>UPDATES_CHECK=0still disables checks.--versioncan be followed by a notice on stderr, in an interactive terminal.Verification
A build versioned 5.16.0, placed over a 5.16.0 package install in
debian:stable-slim,fedora:latest,amazonlinux:2andalpine:latestcontainers: each showed its command at the end of the first run, nothing on the second, and the command upgraded the CLI to 5.17.0. A downloaded.debwithout the repository got the generic link, and a non-root user on Alpine with onlydoasgot adoascommand.The repository check was tested with the 5.17.0 packages in
debian:stable-slim,fedora:latest(dnf 5),rockylinux:9(dnf 4),amazonlinux:2(yum),alpine:latest(apk 3) andalpine:3.20(apk 2): a repository install got the package manager's command, also afterdnf/yum clean all; a downloaded package (dpkg -i,rpm -i,apk add --allow-untrusted), a disabled dnf/yum repository, or removed apt lists or apk cache got the generic link.Timings there for
version, in a terminal:The ownership query alone took 6–36 ms.
🤖 Generated with Claude Code