1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 15:45:53 +01:00
Commit Graph

31 Commits

Author SHA1 Message Date
Colin Walters
f6a4bada34 Rework utils and blockdev crates as -internals in prep for publishing
See https://github.com/coreos/bootupd/pull/963

Basically I just want a way to keep these in sync with bootupd;
we're not attempting to make a truly public library.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-07-01 08:25:26 -04:00
kilavvy
83ef365b72 Update iterators.rs 2025-06-12 15:48:09 +02:00
Etienne Champetier
9698500302 Move try_deserialize_timestamp to bootc_utils
Signed-off-by: Etienne Champetier <e.champetier@ateme.com>
2025-05-29 08:06:58 -04:00
Colin Walters
51123abdf0 Merge pull request #1324 from cgwalters/lint-truncate
lints: Add --no-truncate flag to bootc container lint
2025-05-27 13:30:52 -04:00
John Eckersberg
ca7b38f699 Rewrite containers org links to bootc-dev org
Literally just find and replace github.com/containers/bootc with
github.com/bootc-dev/bootc

We have the redirect in place so none of this is really important, but
I figure removing as many instances of the old repo and replacing them
with the current can't hurt for things like search engine
optimization.  Plus some non-zero number of people might assume one is
a fork of the other or something.

Signed-off-by: John Eckersberg <jeckersb@redhat.com>
2025-05-22 09:07:36 -04:00
Colin Walters
ee78dbc553 Tweak iterator filtering
Prep for lint truncation improvement.

- Kill the handling of the "max 0" case, it's pathological; this
  requires passing NonZeroUsize
- Drop the requirement for the iterator to be clonable as it
  improves ergonomics, and return a vector of the collected elements
  instead

Signed-off-by: Colin Walters <walters@verbum.org>
2025-05-17 14:26:02 -04:00
Colin Walters
7732fe6d7b utils: Strengthen quoted testing
Verify we see exactly one token.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-05-09 13:46:02 -04:00
Colin Walters
25c12b8ebc utils: PathQuotedDisplay: Avoid quoting more characters
This makes the output of command rendering much nicer.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-05-09 13:46:02 -04:00
ckyrouac
4ab90d1721 reinstall: Cleaner formatting of podman bootc install message
This makes it easier to copy/paste (and read) the `podman ... bootc
install ...` command from the CLI output.

Signed-off-by: ckyrouac <ckyrouac@redhat.com>
2025-05-05 15:09:33 -04:00
Colin Walters
c11c817f3c utils/path: Handle non-UTF8 filenames
We need this on general principle.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-04-01 18:57:24 +00:00
Colin Walters
8d97dddb14 Update to rustix 1.0
No major changes required; we get to drop one `unsafe` call
which is nice!

Looks like the ecosystem overall will need a fair bit of porting
before we can drop the 0.38 version though.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-03-30 16:57:50 +00:00
ckyrouac
d3959e5532 tracing: Fix RUST_LOG parsing
This used to work and I'm not exactly sure what changed. For some reason
`with_env_filter` needs to be at the end of the chain for the RUST_LOG
env var parsing to work.

Signed-off-by: ckyrouac <ckyrouac@redhat.com>
2025-02-25 10:22:09 -05:00
Joseph Marrero Corchado
5309d5b31b Merge pull request #1111 from cgwalters/tmpfiles-sysusers 2025-02-19 21:51:15 -05:00
Omer Tuchfeld
6c40145e1f utils: missing format! in context macro
The formatting directives are shown to the user:

```
Error: unknown flag: --user root:root
See 'podman run --help'
ERROR running reinstall command: Failed to run command: {self:#?}
```

This is due to a lack of `format!` directive

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2025-02-17 15:37:15 +01:00
Colin Walters
47abf414bf utils: Add PathQuotedDisplay
There's probably an equivalent of this somewhere in a crate, but
basically dealing with `&Path` and printing it is annoying because
we always end up with quotes around a path, even if it's UTF-8
without any spaces.

This takes a Path and displays it in a way that will be parsable
by a shell, and takes care not to emit quotes in the simple case
where a path has no shell metacharacters, just `/`, `.` and
alphanumerics.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-14 10:49:23 -05:00
Colin Walters
82c5ec67c8 utils: Move iterator helpers to their own module
In the interest of cleanliness.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-14 10:49:23 -05:00
Colin Walters
c34b5e5e83 Merge pull request #1108 from cgwalters/misc-prep
A few misc prep patches
2025-02-12 15:01:18 -05:00
Colin Walters
30e31f220b utils: Add a method to split an iterator
Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-12 08:55:20 -05:00
Colin Walters
4b17ac0dbb utils: Fix compliation standalone
We use `tokio::test` so need the macros feature.

Signed-off-by: Colin Walters <walters@verbum.org>
2025-02-12 08:55:20 -05:00
Omer Tuchfeld
52b8a928b1 utils: Don't use run in run_with_cmd_context
`run` hides stderr until the command fails, which is not what we want
for all current users of `run_with_cmd_context` - it's currently used
by long running processes where we want the users to see all the output
live.

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2025-02-12 13:50:55 +01:00
Omer Tuchfeld
4ac494a50e logging: initialize_tracing should max WARN
Warnings should always appear, so we should set the max level to WARN.

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2025-02-12 13:50:55 +01:00
Omer Tuchfeld
0460c4df1d cli: add system-reinstall-bootc binary
# Background

The current usage instructions for bootc involve a long podman
invocation.

# Issue

It's hard to remember and type the long podman invocation, making the
usage of bootc difficult for users.

See https://issues.redhat.com/browse/BIFROST-610 and https://issues.redhat.com/browse/BIFROST-611

(Epic https://issues.redhat.com/browse/BIFROST-594)

# Solution

We want to make the usage of bootc easier by providing a new Fedora/RHEL
subpackage that includes a new binary `system-reinstall-bootc`. This binary
will simplify the usage of bootc by providing a simple command line
interface (configured either through CLI flags or a configuration file)
with an interactive prompt that allows users to reinstall the current
system using bootc.

The commandline will handle helping the user choose SSH keys / users,
warn the user about the destructive nature of the operation, and
eventually report issues they might run into in the various clouds (e.g.
missing cloud agent on the target image)

# Implementation

Added new system-reinstall-bootc crate that outputs the new
system-reinstall-bootc binary. This new crate depends on the existing utils crate.

Refactored the tracing initialization from the bootc binary into the
utils crate so that it can be reused by the new crate.

The new CLI can either be configured through commandline flags or
through a configuration file in a path set by the environment variable
`BOOTC_REINSTALL_CONFIG`.

The configuration file is a YAML file.

# Limitations

Only root SSH keys are supported. The multi user selection TUI is
implemented, but if you choose anything other than root you will get an
error.

# TODO

Missing docs, missing functionality. Everything is in alpha stage. User
choice / SSH keys / prompt disabling should also eventually be supported
to be configured through commandline arguments or the configuration
file.

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2025-02-06 01:50:04 +01:00
Omer Tuchfeld
3425e9bdb2 cli: add a utility function for initializing tracing
Refactor the tracing initialization code into a utility function, so
that it can be shared with future CLIs that we'll add.

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
2025-02-06 01:49:09 +01:00
Colin Walters
b23777fb01 install/blockdev: Break cyclic build dependency
The install code and the blockdev code call each other.
Clean up blockdev to only use `bootc-utils`.
Prep for splitting out the blockdev stuff into at least a
separate internal crate; ref
https://github.com/coreos/bootupd/pull/820

Signed-off-by: Colin Walters <walters@verbum.org>
2025-01-20 17:48:59 -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
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
5025faa4d3 utils: Add a helper to run command + capture output
Factor out a helper that runs and captures output *and*
checks exit status out of what we have existing in `run_and_parse_json`,
so we can use it for things that output not-JSON.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-11-07 13:03:31 -05:00
Colin Walters
96fe0a9a93 utils: Add a log_debug() helper, use it in a few places
ref https://github.com/containers/bootc/discussions/793
And add a log at trace level unconditionally.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-09-19 16:10:09 -04:00
Colin Walters
97692bd1c2 Make lints stricter, apply crate wide
Add `dead_code = "deny"` to our default lints; we had
a compiler warning for this in main.

Fix the warning by moving the human readable test code into
`#[cfg(test)]`.

While we're here, move the other lib.rs lints into the crate;
enforcing docs for *everything* at first I thought might be heavy
handed but actually is fine as it only applies to things that
are `pub`, of which we don't actually have that much so it
mainly forced me to add some stub docs for the modules, which
is probably a good idea.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-09-18 13:10:49 -04:00
Colin Walters
c3bff5ee9f build-sys: Move a few dev-deps to workspace deps
Just to increase sharing.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-08-15 14:46:55 -04:00
Colin Walters
d7c3f9f4aa Split off an internal "bootc-utils" crate
In general the codebase is starting to get to the size
where some internal crates make sense. Let's start
with the inevitable catchall "utils" crate which
starts off just holding our helper traits for
subprocesses.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-08-14 12:06:19 -04:00