Skip to content

system/nxpkg: Make the storage root configurable and crash-safe. - #3642

Merged
acassis merged 1 commit into
apache:masterfrom
aviralgarg05:gsoc/nxpkg-sync-lifecycle-hardening-pr5
Aug 17, 2026
Merged

system/nxpkg: Make the storage root configurable and crash-safe.#3642
acassis merged 1 commit into
apache:masterfrom
aviralgarg05:gsoc/nxpkg-sync-lifecycle-hardening-pr5

Conversation

@aviralgarg05

@aviralgarg05 aviralgarg05 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

This PR has been reduced to the storage layer. The rest of what it used to
contain is now in #3718, #3719 and #3720, in that order.

The package store, the catalog and the temporary download area were fixed
paths spread across /etc, /var/lib and /var/cache. A board rarely has
all three, and nothing let it put them somewhere it does have, such as a
removable card. They are now derived from CONFIG_SYSTEM_NXPKG_ROOT.

Every file the package manager owns was also written in place, so a reset
partway through a write left a truncated catalog or database behind. Writes
now go to a temporary file that is renamed into place.

Locking used only the file modification time. A card whose clock does not
follow CLOCK_REALTIME reports a file created a moment ago as decades old,
so a live lock looked stale to the next caller and was taken away from its
owner. Each lock now records a per-boot token and the owning task, so a
contender can tell a live owner from an abandoned one, and reclaims the
lock only in the second case.

Diagnostics go to syslog, since a package operation started by a supervisor
has no console to print to. pkg_runtime_compat() also falls back to
CONFIG_ARCH_BOARD_CUSTOM_NAME, because a board with a custom board
directory defines no CONFIG_ARCH_BOARD at all, which does not build.

Impact

  • New feature: NO, this is the foundation the other three parts build on.
  • User adaptation: YES. The storage root moves to
    CONFIG_SYSTEM_NXPKG_ROOT, default /var/lib/nxpkg. A board that mounts
    writable storage elsewhere sets that symbol.
  • Build: NO.
  • Hardware: NO.
  • Documentation: The companion documentation is Documentation: Update nxpkg and add nxstore guide. nuttx#18875.
  • Security: NO new boundary.
  • Compatibility: A store created under the old fixed paths is not migrated;
    point CONFIG_SYSTEM_NXPKG_ROOT at the old location to keep it.

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, codespell and git diff --check on
    every changed file
  • all system/nxpkg sources compiled for the target
  • this part builds on master on its own; the three that follow declare it
    with Depends-On

On the target: a lock held by a running task was kept while a second caller
asked for it, and locks left by an exited task and by an earlier boot were
both reclaimed.

PR verification Self-Check

  • This PR introduces one focused change.
  • I have updated all required description fields above.
  • I have reviewed and signed every commit.
  • This PR adheres to the current contribution and coding guidelines.
  • My PR is still work in progress.
  • My PR is ready for review and can be safely merged.

Comment thread system/nxpkg/Kconfig Outdated
Comment thread system/nxpkg/README.txt Outdated
Comment thread system/nxpkg/pkg_install.c Outdated
Comment thread system/nxpkg/pkg_repo.c Outdated
Comment thread system/nxpkg/pkg_repo.c Outdated
Comment thread system/nxpkg/pkg_store.c Outdated
Comment thread system/nxpkg/pkg_store.c Outdated
@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch from c4f639c to f363a8f Compare July 24, 2026 10:01
@aviralgarg05 aviralgarg05 changed the title system/nxpkg: network sync, install hardening, and CLI completion system/nxpkg: Add network sync and harden package lifecycle. Jul 24, 2026
@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch from f363a8f to 45a9292 Compare August 6, 2026 16:35
@aviralgarg05

Copy link
Copy Markdown
Contributor Author

Rebased onto current master (2aebae740) and squashed to a single commit.

The squash also removes an artefact of the previous history: the first commit added system/nxpkg/README.txt and a later commit removed it again after review, which made tools/checkpatch.sh fail on the intermediate commit while trying to resolve a path that no longer exists. All checks pass on the squashed commit.

The diff is limited to system/nxpkg/. Keeping this as a draft until I attach the full HTTP lifecycle transcript (sync, install, update, rollback, remove, and checksum rejection) from the ESP32-S3 target.

@aviralgarg05
aviralgarg05 marked this pull request as ready for review August 7, 2026 14:35
Comment thread system/nxpkg/Makefile Outdated
@linguini1

Copy link
Copy Markdown
Contributor

This is a 2.5k LoC patch with 1 commit. Your PR lists a bunch of functionally different features in this PR (i.e adding an icon, adding SHA checks). Please split this into multiple commits, and ideally open a few PRs.

@acassis

acassis commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This is a 2.5k LoC patch with 1 commit. Your PR lists a bunch of functionally different features in this PR (i.e adding an icon, adding SHA checks). Please split this into multiple commits, and ideally open a few PRs.

I suggest dividing in more commit inside this PR, because he has already many PRs opened and the final evaluation date is arriving

@linguini1

Copy link
Copy Markdown
Contributor

It won't make much difference except that the patches will be easier to review if split into many.

@aviralgarg05

Copy link
Copy Markdown
Contributor Author

It won't make much difference except that the patches will be easier to review if split into many.

I will split and stack the PRs, it will be easy for review then

@linguini1

Copy link
Copy Markdown
Contributor

Thank you Aviral!

halyssonJr

This comment was marked as off-topic.

@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch 2 times, most recently from 7641371 to 84d3bd3 Compare August 11, 2026 19:08
@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch from 84d3bd3 to ca37b4d Compare August 11, 2026 19:12
@github-actions github-actions Bot added Size: L and removed Size: XL labels Aug 11, 2026
@aviralgarg05 aviralgarg05 changed the title system/nxpkg: Add network sync and harden package lifecycle. system/nxpkg: Make the storage root configurable and crash-safe. Aug 11, 2026
@aviralgarg05

Copy link
Copy Markdown
Contributor Author

Split as asked. This PR now carries only the storage layer, and the rest went into three follow-ups:

Each declares the one before it with Depends-On, so CI applies them in order. Only this one builds on master by itself, which is why it is first.

The content is unchanged from what you already reviewed; it is the same tree, cut into six commits across four PRs.

Comment thread system/nxpkg/pkg_store.c Outdated
Comment thread system/nxpkg/pkg.h Outdated
Comment thread system/nxpkg/pkg.h Outdated
Comment thread system/nxpkg/pkg_compat.c Outdated
Comment thread system/nxpkg/pkg_log.c Outdated
Comment thread system/nxpkg/pkg_store.c Outdated
Comment thread system/nxpkg/pkg_store.c Outdated
Comment thread system/nxpkg/pkg_store.c Outdated
@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch 2 times, most recently from 3d0d50e to 9088350 Compare August 15, 2026 10:02
@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@aviralgarg05 sqaush your temp change into patch.

@halyssonJr

Copy link
Copy Markdown
Contributor

@aviralgarg05,

Use this way:

git rebase -i HEAD~ N
git push origin your-branch -f

@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch from cfa7cdf to 15e9fb6 Compare August 16, 2026 12:15
Make the nxpkg storage root configurable and write owned files through temporary paths before renaming them. Record lock ownership so processes can recover abandoned locks safely.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
@aviralgarg05
aviralgarg05 force-pushed the gsoc/nxpkg-sync-lifecycle-hardening-pr5 branch from 15e9fb6 to 260fe9f Compare August 16, 2026 15:33
@acassis
acassis merged commit d0c15c8 into apache:master Aug 17, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants