libmport: update local package on offline install when file is newer#173
Conversation
For offline/local-file installs, if the same package is already installed on the current OS release and the local .mport file carries a newer version, remove the installed copy and install the file (an in-place update), preserving the previous automatic flag. Without --force, a same-or-older file still reports "already installed" as before. Adds lookup_current_os_installed(), which only matches an installed package whose os_release equals the running system's, so packages from a different OS release are not treated as version bumps. Deletes the actually-installed meta (not the bundle stub) before the conflict and installed prechecks. Documents the behavior in mport.1. AI-Assisted-By: Claude Opus 4.8 (1M context) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Claude finished @laffer1's task in 3m 40s —— View job Claude finished reviewing this PR
SummaryThe core logic is sound: Finding: delete-then-reinstall is not atomic, and now happens without
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new logic only ever looks at
already_installed[0]frommport_pkgmeta_search_master, which assumes there is at most one installed package per name; if multiple entries are possible (e.g., legacy data), consider either constraining the query to a unique row or explicitly handling/reporting the multi-match case instead of silently ignoring it. - By moving the
--force-reinstall handling intolookup_current_os_installedand gating on matchingos_release, the behavior for a locally installed package from a different OS release may have changed (e.g.,--forceno longer deleting/reinstalling that case); it would be good to double-check and, if needed, explicitly codify the intended cross-release--forcebehavior in this path.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new logic only ever looks at `already_installed[0]` from `mport_pkgmeta_search_master`, which assumes there is at most one installed package per name; if multiple entries are possible (e.g., legacy data), consider either constraining the query to a unique row or explicitly handling/reporting the multi-match case instead of silently ignoring it.
- By moving the `--force`-reinstall handling into `lookup_current_os_installed` and gating on matching `os_release`, the behavior for a locally installed package from a different OS release may have changed (e.g., `--force` no longer deleting/reinstalling that case); it would be good to double-check and, if needed, explicitly codify the intended cross-release `--force` behavior in this path.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
packages.pkg is not unique in the master DB (the same name may be installed under different os_release values) and the search has no ORDER BY, so the current-OS entry is not necessarily row 0. Iterate the returned vector in lookup_current_os_installed() and return the matching entry via an out-parameter instead of only inspecting [0]. Document that cross-OS-release copies are intentionally left to the normal install path, where MPORT_PRECHECK_INSTALLED treats a differing os_release as a distinct package — this preserves the pre-existing --force behavior for that case (unchanged by this feature). AI-Assisted-By: Claude Opus 4.8 (1M context) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @laffer1's task in 3m 36s —— View job Claude finished re-reviewing this PR update
SummaryCommit Sourcery comment 1 (multi-row assumption) — addressed
Sourcery comment 2 (cross-release
|
Summary
For offline / local-file installs (
mport install <file.mport>), if the same package is already installed on the current OS release and the local file carries a newer version, mport now removes the installed copy and installs the file — an in-place update — instead of refusing with "already installed". The previousautomaticflag is preserved.--force, a same-or-older local file still reportsalready installed(unchanged behavior).--force, it reinstalls regardless of version (unchanged behavior).lookup_current_os_installed()only matches an installed package whoseos_releaseequals the running system's, so a package from a different OS release is not treated as a version bump.mport.1documents the new behavior.Verification
-Werror(cd libmport && make).already_installedis freed on the success path and incleanup, NULL'd after each free (no leak / no double-free).mport_delete_primativedoes not free itspackarg, so freeing the array afterward is safe.mport_version_cmpcontract (-1when first < second) and the existingcheck_if_older_installedusage.check_if_installed;--forcecross-release installs are unaffected.install_primative.c:251is pre-existing; splint out-of-bounds notes are the same false-positive class this file already emits).Not covered
No automated test exercises the new offline update-on-newer path — the ATF suite is registry-gated, so this path is verified by code tracing and a clean
-Werrorbuild rather than at runtime.🤖 Generated with Claude Code
Summary by Sourcery
Allow offline installs from local package files to replace an already-installed package on the current OS release when the local file is newer, and document the behavior.
New Features:
Enhancements:
Documentation: