1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-06 09:45:32 +01:00
Commit Graph

39 Commits

Author SHA1 Message Date
Colin Walters
f35358ebdb tests: Diff manifests if digest is different
To debug https://github.com/containers/bootc/issues/1172

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-10 15:04:37 -04:00
Colin Walters
06933ed3a2 ostree-ext: Update parser to honor composefs=verity
We have duplicate code to parse this between C and Rust
unfortunately; update the Rust side to honor what landed
in https://github.com/ostreedev/ostree/pull/3354

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-06 17:01:59 -05:00
Colin Walters
98995f662b store: Really remove empty /etc/resolv.conf and /etc/hostname
The previous change here was a no-op for two reasons:

- It's actually usr/etc at this point
- We were operating on the wrong rootfs

Fixes: 57bd0dc983
Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-05 14:52:56 -05:00
John Eckersberg
72edcb27fa ostree-ext: store: clear diff_ids when exporting to oci
Resolves: #1134

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
2025-02-24 18:19:58 -05:00
Colin Walters
b305a054eb lint: Add missing format!
This got missed when converting the errors.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-21 08:14:05 -05:00
Colin Walters
57bd0dc983 store: Clean up broken /etc/hostname and /etc/resolv.conf
We can pretty safely work around this here; zero sized
files for both are useless.

Closes: https://github.com/containers/bootc/issues/1064
Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-07 11:33:12 -05:00
Colin Walters
0b04cc488c tar/export: Fix error with zero-sized hardlinked files
In the case where we already emitted an object into the tar stream,
we wouldn't previously set the file type and size into the tar
header structure that we passed into the hardlink emission function.
This would cause an error when accessing the (logically) uninitialized `size()`.

Fix the writer function to always set the file type and size unconditionally,
and also rework the consumer side to make the logic even clearer.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-05 09:04:33 -05:00
Colin Walters
4c523b47b4 tar/export: Add error context
Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-05 08:51:14 -05:00
Colin Walters
a4e78a45b2 store: Fix semantic merge conflict
Not totally sure how this got through CI, but the most recent
two PRs semantically conflicted. Update the new code
to use the new glib prelude import.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-03 17:14:23 -05:00
Colin Walters
57829806de Merge pull request #1069 from cgwalters/update-ostree-rs
Update to ostree-rs 0.20
2025-02-03 13:35:10 -05:00
Colin Walters
ffc48c6a8f Update to ostree-rs 0.20
Notably this drops out several duplicate crates.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-03 12:37:37 -05:00
Colin Walters
71f83465ce ostree-ext: Add image clear-cached-update
This is effectively an internals command for us to aid
debugging.

At some point it may make sense to expose this
at the bootc level too.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-03 11:05:01 -05:00
Colin Walters
2b175add56 Improve parsing of ostree prepare-root config
Prep for further work.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-03 09:10:37 -05:00
Colin Walters
57111be351 ostree-ext: Add bootc feature
This is aiming to fix https://github.com/coreos/rpm-ostree/issues/5251
Basically we can't re-invoke the calling process if we aren't
actually bootc.

(There are solutions that make this work, but what we'll hopefully
 do shortly is propagate the logic to older streams to have
 bootc take over the handling anyways)

Signed-off-by: Colin Walters <walters@verbum.org>
2025-01-24 17:34:37 -05:00
Colin Walters
ded8a6ba25 ostree-ext/encapsulate: Add some error contexts
I was getting EPERM on creating the dir, and it was a pain
to track down.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-01-17 15:08:34 -05:00
Colin Walters
a192370d51 ostree-ext: Serialize xattrs into tar stream as well
We really want this for https://github.com/coreos/rpm-ostree/pull/5222
to be able to rebuild images from their container-synthesized rootfs.

Really, the only xattr we don't want to emit in to the tar stream
is security.selinux for now.

Eventually we should try to switch to putting that into the tar
stream too, but it needs more validation.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-01-16 15:39:14 -05:00
Colin Walters
85344509b4 ostree-ext: Rename helper for clarity
Prep for next patch.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-01-15 19:45:43 -05:00
Colin Walters
0767f7d462 Merge pull request #1025 from cgwalters/export-vartmp
ostree-ext/tar/export: Fix reexport of var/tmp
2025-01-14 20:17:37 -05:00
Jonathan Lebon
fdde8c60e6 ostree-ext: surface libostree signature verification text
Right now when using OSTree remote verification, there's no indication
that the OSTree commit was successfully verified.

Capture the return string from `OstreeRepo.signature_verify_commit_data`
and return it as part of the public `LayeredImageState` object.

We could return a more structured signature object here, but this is
sufficient for our purposes for now and saves clients from having to
regenerate similar looking text.

In the `ostree container` CLI, print this verification text.

Signed-off-by: Jonathan Lebon <jonathan@jlebon.com>
2025-01-14 17:03:39 -05:00
Jonathan Lebon
f229c2011c ostree-ext/store: drop unnecessary mut
We don't actually mutate anything in `self` in this function.

Signed-off-by: Jonathan Lebon <jonathan@jlebon.com>
2025-01-14 17:03:39 -05:00
Jonathan Lebon
671aff22b6 ostree-ext/store: fix comment typo
Signed-off-by: Jonathan Lebon <jonathan@jlebon.com>
2025-01-14 17:03:39 -05:00
Colin Walters
f1872085d1 ostree-ext/tar/export: Fix reexport of var/tmp
A lot of technical debt here. A long time ago I added this hacky bit
to inject var/tmp is the container stream even if it wasn't in the
ostree commit.

Today things shipped by `rpm-ostree compose image` like FCOS
don't have `var/tmp` in the commit.

But then more recently we started shipping `/var/tmp`
in base images directly.

Now I'm working on https://github.com/coreos/rpm-ostree/issues/5221
where we're rechunking from a rootfs that does have var/tmp
and that ends up in the ostree commit.

The path comparison here was wrong because the tar stream we
generate has the paths start with `./` and a literal comparison
doesn't match `./var/tmp` != `var/tmp`.

Add a canonicalization helper and use it for this.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-01-14 09:24:01 -05:00
Colin Walters
203a4fc20c tree-wide: Move everything else under #[cfg(test)]
Followup to 40af5a67b1
now that some other PRs have merged this one would be less
conflict-fest.

This is a general best practice; specifically motivated by
handling test-specific imports.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-20 10:49:53 -05:00
Colin Walters
5013d45eff tree-wide: Use cap-std-ext is_mountpoint() API
I moved it there a while ago, now we can drop the copy of it
here.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-20 09:27:55 -05:00
Antheas Kapenekakis
518435fb3e pull: Add --json-fd
This adds a generic "progress" infrastructure for granular
incremental notifications of downloading in particular, but
we may extend this to other generic tasks in the future too.

Signed-off-by: Antheas Kapenekakis <git@antheas.dev>
Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-13 20:14:48 +00:00
Colin Walters
f34e5dd22c Merge pull request #943 from cgwalters/cmd-pdeathsig
Cmd pdeathsig
2024-12-10 09:49:41 -05:00
Omer Tuchfeld
c60a1fc326 ostree-ext: test: Add a comment to clarify test code
The test code in the fixture module is a bit confusing, as it
arbitrarily gives some files in /etc a label and others another.

Add a comment to clarify this is on purpose.

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2024-12-09 18:19:26 +01:00
Omer Tuchfeld
ac16dbb9ea ostree-ext: test: fix clippy warning
My clippy is complaining about `len()` being disallowed method. No harm
in changing this.

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2024-12-09 18:19:19 +01:00
Colin Walters
af207a0d5c utils: Add a lifecycle_bind helper for Command
In almost all children we fork, we want the child to reliably
exit if we do (e.g. especially if we panic). The Linux
PR_SET_PDEATHSIG is just great for this.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-06 16:31:44 -05:00
Colin Walters
32af54de13 ext: Replace terminal_size with comfy-table
I was looking at our vendoring set and while it's not actually
relevant I found myself wondering why we had *three* versions
of `windows-sys`. Having that many crate versions is often a signal
that there's an unmaintained dependency.

And indeed, `terminal_size` is no longer cool. The "in" crowd
has moved on to newer, hipper things. Life moves fast, we need
to keep up.

(OK but yes also this drops some manual column printing code
 we had which is also a win)

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-06 14:26:33 -05:00
Colin Walters
7f94a7a177 Merge pull request #939 from cgwalters/use-path-booted
Use a shared const and helpers for run/ostree-booted
2024-12-06 10:46:46 -05:00
Colin Walters
d5e0d61397 Use a shared const and helpers for run/ostree-booted
Just a code cleanup.

Closes: https://github.com/containers/bootc/issues/934
Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-06 09:52:37 -05:00
Colin Walters
a3731457a2 tree-wide: Run cargo clippy --fix
Nothing important here but eh, let's quiet it.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-06 08:34:49 -05:00
Colin Walters
c5852ad405 install: Add ensure-completion verb, wire up ostree-deploy → bootc
When bootc was created, it started to become a superset of ostree;
in particular things like `/usr/lib/bootc/kargs.d` and logically
bound images.

However...Anaconda today is still invoking `ostree container image deploy`.

Main fix
--------

When bootc takes over the `/usr/libexec/ostree/ext/ostree-container`
entrypoint, make the existing `ostree container image deploy` CLI actually
just call back into bootc to fix things up. No additional work required other
than getting an updated bootc in the Anaconda ISO.

Old Anaconda ISOs
-----------------

But, a further problem here is that Anaconda is only updated once
per OS major+minor - e.g. there won't be an update to it for the lifetime
of RHEL 9.5 or Fedora 41. We want the ability to ship new
features and bugfixes in those OSes (especially RHEL9.5).

So given that we have a newer bootc in the target container, we can
do this:

```
%post --erroronfail
bootc install ensure-completion
%end
```

And will fix things up. Of course there's fun $details here...the
way Anaconda implements `%post` is via a hand-augmented `chroot`
i.e. a degenerate container, and we need to escape that and
fix some things up (such as a missing cgroupfs mount).

Summmary
--------

- With a newer bootc in the ISO, everything just works
- For older ISOs, one can add the `%post` above as a workaround.

Implementation details: Cross-linking bootc and ostree-rs-ext
-------------------------------------------------------------

This whole thing is very confusing because now, the linkage
between bootc and ostree-rs-ext is bidirectional. In the case
of `bootc install to-filesystem`, we end up calling into ostree-rs-ext,
and we *must not* recurse back into bootc, because at least for
kernel arguments we might end up applying them *twice*. We do
this by passing a CLI argument.

The second problem is the crate-level dependency; right now they're
independent crates so we can't have ostree-rs-ext actually
call into bootc directly, as convenient as that would be. So we
end up forking ourselves as a subprocess. But that's not too bad
because we need to carry a subprocess-based entrypoint *anyways*
for the Anaconda `%post` case.

Implementation details: /etc/resolv.conf
----------------------------------------

There's some surprising stuff going on in how Anaconda handles
`/etc/resolv.conf` in the target root that I got burned by. In
Fedora it's trying to query if systemd-resolved is enabled in
the target or something?

I ended up writing some code to just try to paper over this
to ensure we have networking in the `%post` where we need
it to fetch LBIs.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-12-05 11:17:05 -05:00
Colin Walters
dfa2c796d7 clippy: Deny str::len
When I was working on some column printing code
with Unicode I got bit by using `str::len`...and
digging in I found that clippy actually just
merged a lint to go the *other* way; more in
the link in the code.

Turning on a lint showed one place that should
have been using `chars().count()` and one that
should have been validating ASCII. Fix those.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-11-19 21:31:30 +00:00
Colin Walters
0adf1d44d2 Fix various minor lints
- Fix an unused variable in ostree-ext
- Fix other clippy lints

Signed-off-by: Colin Walters <walters@verbum.org>
2024-11-18 22:18:33 +00:00
Colin Walters
e0c627e3f4 ext: Fix a few lints
- Wire up to workspace lint standards
- Fix a few remaining clippy lints

Signed-off-by: Colin Walters <walters@verbum.org>
2024-11-11 16:53:46 +00:00
Colin Walters
1770055f2b store: Support importing images without /ostree
A sticking point keeping ostree in the picture here for
containers was SELinux handling. When we started this
effort I'd feared rewriting.

But recently we changed things such that we label derived images
using the policy from the final root.

This is a relatively small change in code size and complexity,
that allows us to import images that don't have "ostree stuff"
in them at all, i.e. there's no `/ostree/repo/objects`.

The advantage here is that this significantly simplifies
constructing base images.

The main disadvantage today for people who build images
this way is that we end up re-labeling and re-checksumming all objects.

But, the real fix for that in the future will be for us to
rework things such that we support `security.selinux` for example
as native xattrs in the tar stream.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-11-08 13:29:02 -05:00
Colin Walters
23a54d9668 Merge remote-tracking branch 'ostree-rs-ext/main' into merge-ostree-rs-ext
Signed-off-by: Colin Walters <walters@verbum.org>
2024-11-06 18:26:35 -05:00