Repository navigation
fix(cross): --tar and --deploy carry cross.package.files - #258
Merged
Merged
Conversation
The runnable bundle was the app bundle, the embedder binary and its linked libraries. Nothing read `spec.files`, so a config file or a systemd unit declared in `cross.package.files` reached a `.deb` but never a deployed board — silently, with no warning on either path. Part of #216, which calls this out as the impactful near-term fix; the two-package model in that issue is a separate change. Files stage under the bundle root: an absolute `to:` loses its leading separator (`/etc/app.conf` -> `<runnable>/etc/app.conf`), a relative one lands as-is. A bundle is not an install — `--deploy` copies it to `--deploy-dir`, so these sit under that directory rather than at `/etc`. Putting them at their real paths is what the package formats are for. Two cases the staging has to get right: - A source already inside the bundle is skipped. The documented `${runnable}/lib/libfoo.so` pattern names a file the bundle already carries, and a second copy only doubles what goes over the wire. `p.isWithin`, not a string prefix, so `runnable-drm` is not read as inside `runnable`. - `--flatpak` now runs before the staging. It applies `files:` itself, at their `/app` paths, and copies the bundle wholesale — so a bundle already carrying them at bundle-relative paths would ship every one twice. The copy loop moves out of `PackageStager.stagePayload` into a top-level `stageExtraFiles`, so both callers get one implementation of the containment rules hardened in #235 rather than a second copy of them: `..` refused outright, `p.isWithin` as the backstop, octal-only modes, batched chmod bounded by both path count and argv bytes. Two changes to that code, both forced by the new caller: - Destinations may now be relative, since a bundle path need not be rooted. - A source already at its destination is skipped. `copySync` onto itself truncates the file, and that was unreachable while the staging root was always a directory emb had just created. Mode validation stays in `stagePayload` before the binary is written, not only inside the shared function: #235's test asserts nothing is chmodded when a mode is bad, and moving the check past the binary copy broke it. Signed-off-by: Joel Winarske <joel.winarske@linux.com>
9 tasks
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.
Takes the near-term half of #216 — the silent drop — and leaves the two-package
model for a design pass. Design questions posted on the issue.
The bug
_runnableassembles the app bundle, installs the embedder binary, stages itslinked libraries, and stops. Nothing reads
spec.files. Every package format goesthrough
_extraFiles→extraFiles:;--tarand--deploynever did. So asystemd unit or a config file in
cross.package.filesreached a.deband nevera deployed board, with no warning on either path — you find out on the device.
Semantics
Files stage under the bundle root: an absolute
to:loses its leading separator,a relative one lands as-is. Worth being explicit, because it is not an install —
--deploycopies the bundle to--deploy-dir, so/etc/app.confends up at<deploy-dir>/etc/app.conf, not/etc/app.conf. Installing at real paths is what--deb/--ipk/--rpm/--targzare for. #216 describes exactly this layout asthe interim behavior.
Two things the staging has to get right
A source already inside the bundle is skipped. README documents
${runnable}/lib/libmymodule.so: { to: /usr/lib/libmymodule.so }. Staged naivelythat copies a library the bundle already carries to a second path inside the same
bundle, doubling what
--tarwrites and--deploypushes. Filtered withp.isWithinrather than a string prefix, so a multi-backend build'srunnable-drmis not read as insiderunnable— there is a test for that.--flatpakmoved ahead of the staging. It appliesfiles:itself at their/apppaths and copies the bundle wholesale, so a bundle already carrying themat bundle-relative paths would ship every file twice. Reordering is the whole fix;
the two outputs are independent.
The refactor, and why
The copy loop moves out of
PackageStager.stagePayloadinto a top-levelstageExtraFiles. I did not want a second copy of the containment rules hardenedin #235 —
..refused outright,p.isWithinas the backstop, octal-only modes,chmod batched under both a path-count and an argv-byte bound. One implementation,
both callers.
Two deliberate changes to that code, both forced by the new caller:
stagePayloadkeeps its own "must be absolute" check, so package formats are unchanged.
copySynconto itself truncatesthe file. Unreachable before, because the staging root was always a directory
emb had just created; reachable now that it can be one the source lives in.
A regression I introduced and backed out: folding mode validation into the
shared function moved it past the binary copy, and #235's test — "nothing may be
chmodded on a bad mode" — caught it.
stagePayloadvalidates the whole mode setbefore writing anything, as it did.
Tests
Five on
stageExtraFiles(absolute dest, relative dest, self-copy skipped ratherthan truncated,
..refused with the victim file verified intact, option-shapedmode refused before anything is written) and three on
filesNotAlreadyIn.The wiring inside
_runnableis not unit-tested: the command test harness stopsthe build before the bundle is assembled, and reaching it needs a real toolchain
and engine. CI does not cover it either —
validateruns--buildwithout--app, so_runnablenever executes there, and the one example manifest with afiles:block has it commented out. Worth knowing when reviewing the orderingchange.
1216 tests pass;
dart analyzeanddart formatclean; cspell clean.Behavior change
This changes what
--tarproduces and what--deploypushes for any manifestdeclaring
package.files. That is the point of the fix, but it is a change foranyone who had worked around the drop by hand. Called out in the CHANGELOG.