system/nxpkg: Complete the package lifecycle and command line. - #3720
Open
aviralgarg05 wants to merge 2 commits into
Open
system/nxpkg: Complete the package lifecycle and command line.#3720aviralgarg05 wants to merge 2 commits into
aviralgarg05 wants to merge 2 commits into
Conversation
…disk. Install wrote the pointer files and removed payloads around the database save rather than after it, so a failure in between could leave the database naming a version whose files were already gone. Reinstalling a version that was already present treated its directory as newly created, so a failed reinstall deleted a working install. Uninstall and rollback took only the database lock, leaving another install free to work on the same package. Commit the database first and only then refresh the pointers or delete files, so a crash can strand files that are reclaimable but never lose a payload the database still points at. Take the per-package lock in uninstall and rollback as well, and pick up state left by an install that was interrupted earlier. Assisted-by: OpenAI Codex:gpt-5.6-sol Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
Only install, list and available were reachable from the shell, so a package could be put on a device but never updated, rolled back or taken off again. Wire up sync, update, remove and rollback, and report the errno the library returns rather than a plain failure. Assisted-by: OpenAI Codex:gpt-5.6-sol Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
6 tasks
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): CI run: https://github.com/apache/nuttx-apps/actions/runs/31526679208 |
xiaoxiang781216
approved these changes
Aug 12, 2026
| for (i = victim; i + 1 < entry->version_count; i++) | ||
| { | ||
| memcpy(entry->versions[i], entry->versions[i + 1], | ||
| sizeof(entry->versions[i])); |
| pkg_free(payload); | ||
| pkg_free(manifest_path); | ||
| pkg_free(lock); | ||
| pkg_free(installed_lock); |
Contributor
There was a problem hiding this comment.
could we goto the end to avoid the code dup
| pkg_free(lock); | ||
| pkg_free(installed_lock); | ||
| pkg_error("unable to allocate package metadata buffers"); | ||
| return EXIT_FAILURE; |
Contributor
There was a problem hiding this comment.
goto errout to avoid the code dup
| pkg_free(payload); | ||
| pkg_free(manifest_path); | ||
| pkg_free(lock); | ||
| pkg_free(installed_lock); |
| pkg_free(payload); | ||
| pkg_free(manifest_path); | ||
| pkg_free(lock); | ||
| pkg_free(installed_lock); |
| pkg_free(manifest_path); | ||
| pkg_free(lock); | ||
| pkg_free(installed_lock); | ||
| pkg_error("unable to resolve artifact source for '%s': %d", name, ret); |
| pkg_free(payload); | ||
| pkg_free(manifest_path); | ||
| pkg_free(lock); | ||
| pkg_free(installed_lock); |
| { | ||
| pkg_store_remove_file(installed_lock); | ||
| pkg_store_remove_file(package_lock); | ||
| pkg_free(db); |
Contributor
There was a problem hiding this comment.
could we use goto to avoid the code duplication too
| { | ||
| pkg_store_remove_file(installed_lock); | ||
| pkg_store_remove_file(package_lock); | ||
| pkg_free(db); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Please adhere to Contributing Guidelines.
Depends-On: /pull/3719
Summary
Install wrote the current and previous pointer files, and removed the
payload of a pruned version, around the database save rather than after it.
A failure in between left the database naming a version whose files were
already gone. Reinstalling a version that was already present treated its
directory as newly created, so a failed reinstall deleted a working
install. Uninstall and rollback took only the database lock, which left
another install free to work on the same package at the same time.
The database is now committed first, and only then are pointers refreshed
or files deleted. A crash can therefore strand files that are reclaimable,
but never leaves the database pointing at a payload that is gone. Uninstall
and rollback take the per-package lock as well, and install picks up state
left behind by an earlier attempt that was interrupted.
Only
install,listandavailablewere reachable from the shell, so apackage could be put on a device but never updated, rolled back or removed.
sync,update,removeandrollbackare now wired up, and the CLIreports the errno the library returns rather than a plain failure.
This is the last of four parts of #3642, which was one commit covering
several unrelated changes.
Impact
payload the database still refers to.
Testing
Build host: macOS 26.5, arm64,
xtensa-esp-elf-gcc 14.2.0(
esp-14.2.0_20251107).Target: Xtensa / ESP32-S3, Waveshare ESP32-S3-Touch-LCD-7.
nxstyle,tools/checkpatch.sh,codespellandgit diff --checkonevery changed file
system/nxpkgsources compiled for the target with this commitapplied on top of system/nxpkg: Fetch the catalog and artifacts over the network. #3719
On the target, against a repository on the SD card, the following were
exercised: install, update to a second version, rollback to the first,
remove, a package lock held against a second install returning
-EBUSY, alock reclaimed from an exited owner and from an earlier boot, and an
artifact whose SHA-256 did not match, which left no database entry, version
directory, lock or transaction file behind.
This commit does not build on
masteralone because it uses declarationsand helpers added by the three parts before it; the
Depends-Online abovelets CI apply those first.
PR verification Self-Check