Skip to content

install: Add --output-{json,pairs}-{path,fd} for the install result - #38

Closed
cgwalters-bot wants to merge 1 commit into
mainfrom
bot/install-output
Closed

cgwalters-bot wants to merge 1 commit into
mainfrom
bot/install-output

Conversation

@cgwalters-bot

Copy link
Copy Markdown
Collaborator

Adds options to bootc install to-filesystem (and to-disk, to-existing-root, which share the code) to write a machine-readable result once the install succeeded, as sketched in bootc-dev#542 (comment):

--output-json-path PATH    --output-json-fd FD
--output-pairs-path PATH   --output-pairs-fd FD

At most one may be given. Pairs are KEY="value" lines as lsblk --pairs --shell (one per line; ", \, $ and backtick are backslash-escaped as in os-release, so eval round-trips). Keys: backend, stateroot, deployment/etc/var paths relative to the target, bootloader, image, image transport and digest; JSON uses camelCase (etcPath), pairs upper snake case (ETC_PATH). A path is replaced atomically; an fd must be inherited (not close-on-exec) and writable, checked before anything is installed. The path's directory is opened up front and carried across bootc's re-execs, so /tmp/... doesn't silently land in the tmpfs bootc mounts there.

pairs=$(bootc install to-filesystem --output-pairs-fd 3 /mnt 3>&1 >&2)
eval "$pairs"
cp my.service "/mnt/$ETC_PATH/systemd/system/"

Not covered: install reset, which has its own flow.

Testing, on a 16-core RHEL 10 devspace (AMD EPYC 7763; no fork CI):

  • just unit-tests passed (bootc-lib: 290, including 7 new ones covering pairs quoting with a real sh eval round-trip, key names, rendering, and fd/path validation), and so did just validate.
  • tmt plan-23-install-outside-container, extended to install with --output-json-path and check the reported deployment, /etc (a file written via bootc install mount is found under etcPath), /var, image and digest, plus that an fd the caller didn't pass is rejected before installing: passed for the ostree variant and for composefs (grub, ext4, BLS).
  • By hand, in a bcvk ephemeral VM: podman run --privileged --preserve-fds 1 localhost/bootc bootc install to-disk --output-pairs-fd 3 ... 3>&1 >&2 into pairs=$(...), then eval "$pairs"; the reported $ETC_PATH, $VAR_PATH and $DEPLOYMENT_PATH/usr existed on the installed disk.

xref bootc-dev#542

Generated-by: https://github.com/cgwalters/#llms


Review draft in cgwalters-forge, not upstream yet. This section is removed when the PR is opened upstream.

  • Upstream: bootc-dev/bootc, base main
  • Board item: PVTI_lADOE9oHIs4BlJLczg-Ke4c
  • Fork CI: off; the devspace testing described above is this PR's CI, and upstream CI runs once it is opened there

To review:

  • Approve, or comment /promote on a line of its own, to open it upstream, ready for review. Either covers only the commits pushed so far.
  • If upstream requires DCO, approving also signs off: promote adds Signed-off-by: Colin Walters <[email protected]> to the commits lacking it (the bot's and yours; anyone else's only if you ask), with you as committer.
  • Add a /draft line (in the same comment or before) to open it upstream as a draft (/ready undoes that).
  • Close to drop it.
  • Edit the title and description freely: they become the upstream PR's. Review comments are squashed into the commits they concern, with a reply here.

Installers wrapping `bootc install to-filesystem` need to know where the
new deployment landed, typically to drop configuration into its /etc
before the first boot, and today have to dig through the ostree or
composefs layout for it. bootc already knows all of that at the end of
the install, so let it write a small summary: backend, stateroot, the
deployment, /etc and /var paths relative to the target, bootloader, and
the target image with its digest.

The format is JSON or "pairs" in the style of `lsblk --pairs --shell`,
so that scripts without jq can just eval it; the destination is a path
(replaced atomically) or an fd inherited from the caller. These are
four flags rather than a format plus a destination option because each
one reads unambiguously on its own; at most one may be given.

Both destinations are validated before anything is installed. An fd
must not be close-on-exec, which rules out a number the caller never
passed but that happens to be open internally. A path's directory is
opened up front and its fd carried across bootc's re-execs, since
prepare_install may mount a tmpfs over /tmp and a path there would
otherwise silently land in that.

The options apply to to-disk and to-existing-root too, since they share
the same install code.

Ref: bootc-dev#542
Generated-by: AI
Signed-off-by: Colin Walters <[email protected]>
@cgwalters-bot

Copy link
Copy Markdown
Collaborator Author

Signed off 1 commit(s) with Signed-off-by: Colin Walters <[email protected]> for bootc-dev/bootc's DCO check, on cgwalters's approval #38 (review) of 18a31b8894ba. Same trees; the head is now 12a26b3d63a5.

@cgwalters-bot

Copy link
Copy Markdown
Collaborator Author

Opened upstream as bootc-dev#2531. Closing this review draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants