system/nxpkg: network sync, install hardening, and CLI completion#3642
Draft
aviralgarg05 wants to merge 1 commit into
Draft
system/nxpkg: network sync, install hardening, and CLI completion#3642aviralgarg05 wants to merge 1 commit into
aviralgarg05 wants to merge 1 commit into
Conversation
This was referenced Jul 16, 2026
Fill in most of what the initial nxpkg slice deferred: network sync and artifact acquisition over plain HTTP (verified via SHA-256), an install rewrite that supports network sources and reclaims state left by an interrupted previous install, and wiring update/remove/rollback/ available into the CLI. Harden the package path against untrusted input along the way: bounded memory-safety helpers and explicit size limits throughout, storage read/write hardened against partially-written files, path-traversal rejection in manifest name/version before they reach the filesystem, and a fix for a lost-update race on the shared installed-packages database (two concurrent installs of different packages could otherwise silently clobber each other's recorded state). Add an optional manifest icon field for the nxstore GUI frontend to consume, raise PKG_INDEX_MAX now that the in-memory index is heap-allocated, and document the repository layout and local server setup in system/nxpkg/README.txt. Also fixes a real build break: pkg_runtime_compat() unconditionally referenced CONFIG_ARCH_BOARD, a Kconfig string symbol with no default clause under ARCH_BOARD_CUSTOM, so it is left entirely undefined rather than defined-but-empty on a custom board - falls back to CONFIG_ARCH_BOARD_CUSTOM_NAME instead. Routes pkg_error()/pkg_info() through syslog rather than stdio, since neither is visible to a supervisor with no attached console. Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
59fd472 to
d33ae3b
Compare
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.
Summary
This is another slice of the ongoing GSoC 2026 Dynamic ELF loading and
nxpkgwork for NuttX, following on from the initial package lifecyclehelper merged in #3474.
An earlier draft PR (#3474) carries the initial
nxpkgpackagelifecycle helper — local metadata parsing, a local
install/listflow, compatibility checks, transaction-state handling, and integrity
verification. That initial slice was intentionally local-only: no
network sync, no update/rollback execution, no remove.
Series order for this PR:
This PR fills in most of what #3474 explicitly deferred, plus hardening
found while getting the package path solid enough to build a GUI
frontend on top of it (a separate follow-on PR).
Concretely, it:
pkg_zalloc/pkg_malloc/pkg_free)and explicit size limits used throughout the rest of the package path
written input, rather than assuming every file it reads back was
written by a well-behaved prior run
name/versionbeforethey are spliced into an on-device path — a manifest's
name/versionultimately comes from a repository index, which should not be
implicitly trusted to be well-formed
single hardcoded location
verified via SHA-256 rather than requiring TLS or any auth — the
intent is that any static file host works, no special server needed)
installto support network sources and to reclaim stateleft behind by an interrupted previous install/download, instead of
getting stuck on stale partial state
sync/remove/rollback/availableinto the CLI —previously stub error paths
PKG_INDEX_MAXnow that the in-memory index is heap-allocatedrather than a fixed-size stack/static array
iconfield and the source-resolution logicfor it (consumed by the nxstore GUI frontend)
two independent installs of different packages could each read the
on-disk installed-state file, mutate their own in-memory copy, and
write back — the second writer's write would silently discard the
first writer's already-applied change. Fixed with a global installed-
state lock so concurrent installs serialize around that shared file
instead of clobbering each other
server (
system/nxpkg/README.txt)pkg_runtime_compat()unconditionallyreferenced
CONFIG_ARCH_BOARD, a Kconfig string symbol with nodefaultclause underARCH_BOARD_CUSTOM— on a custom board it isleft completely undefined rather than defined-but-empty, so the
previous code failed to compile the moment
CONFIG_SYSTEM_NXPKGwasenabled on a custom-board config. Fixed by falling back to
CONFIG_ARCH_BOARD_CUSTOM_NAME(only#define'd whenARCH_BOARD_CUSTOMis selected), and routedpkg_error()/pkg_info()through
sysloginstead of stdio, since neither is visible to asupervisor process with no attached console
Impact
User impact:
nxpkgnow supports the full lifecycle the initial slice deferred:sync,install(local or network source),update,remove,rollback,list,availableARCH_BOARD_CUSTOM(a custom board directory, as opposed to one ofthe named boards
ARCH_BOARDhas adefaultclause for) withCONFIG_SYSTEM_NXPKGenabledBuild impact:
(
NETUTILS_CJSON); network sync additionally needsNETUTILS_WEBCLIENTRuntime impact:
local-only installs are otherwise unaffected in behavior
pkg_error()/pkg_info()now log viasysloginstead of directly tostdio
Compatibility impact:
CONFIG_SYSTEM_NXPKGis enabledlock file); already-installed state from system/nxpkg: add a basic package lifecycle helper #3474's format is not
migrated, since system/nxpkg: add a basic package lifecycle helper #3474 itself is not yet in a released version
Testing
Host used for build:
xtensa-esp-elf-gcc (crosstool-NG esp-14.2.0_20241119) 14.2.0Target used for verification:
xtensaesp32s3-touch-lcd-7:nshyet upstream)
This series was developed and continuously exercised on real hardware
over the course of building the
nxstoreGUI frontend on top of it (aseparate follow-on PR) — every
nxpkgcode path this PR touches iswhat that frontend calls into for every install/launch/close cycle
across dozens of manual test passes on the physical board, including:
character (this specifically exercises a since-fixed FAT 8.3
short-filename issue in a related, already-shipped part of the
storage path — not part of this diff, but this PR's install/sync
rewrite is what exercises that path end-to-end)
triggering installs of two different packages back to back and
confirming both ended up correctly recorded in the installed
database afterward, rather than one silently overwriting the other
Focused verification for the final commit in this PR (the
ARCH_BOARD_CUSTOMbuild fix):compiles clean against this project's own generated
include/nuttx/config.hforesp32s3-touch-lcd-7:nsh, whereCONFIG_ARCH_BOARDis confirmed absent and onlyCONFIG_ARCH_BOARD_CUSTOM_NAMEis defined — reproducing the exactbuild-break condition and confirming the fallback resolves it.
This is a draft PR — opening now to get the series in front of
reviewers; happy to split further if any single commit above should be
its own PR.
Update: the
nxstoreGUI frontend built on top of this is now open as #3643 (stacked on this PR — see that PR's series-order note). Thegames/NXDoombring-up/crash fixes referenced above as a follow-on are open as #3644 (independent of this PR).