-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rpm-ostree ex rebuild
command
#3340
Conversation
Skipping CI for Draft Pull Request. |
ff113ca
to
0ee1377
Compare
Sample output:
|
0ee1377
to
04b5b1c
Compare
I find calling this Maybe... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prep patches seem sane, let's split them to a separate PR and get them in.
src/libpriv/rpmostree-core-private.h
Outdated
gboolean is_system; | ||
/* Whether we were created with new_container() */ | ||
gboolean is_container; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK as is but I think we should switch to an enum at some point.
src/libpriv/rpmostree-core.cxx
Outdated
@@ -154,10 +154,8 @@ set_rpm_macro_define (const char *key, const char *value) | |||
RpmOstreeContext * | |||
rpmostree_context_new_base (OstreeRepo *repo) | |||
{ | |||
g_assert (repo != NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is going to be...interesting. Heavy intersection with ostreedev/ostree-rs-ext#159
@@ -1661,3 +1661,93 @@ rpmostree_compose_builtin_extensions (int argc, | |||
|
|||
return TRUE; | |||
} | |||
|
|||
static void | |||
state_action_changed_cb (DnfState *state, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...I think we could actually just do this by default in rpmostree-core.cxx
right? I believe we bypass this section of libdnf in the ostree-native case. That way it'd work out of the box in other code paths too.
Prep patches split out in #3341. |
Did you see #3330 btw? That was a much hackier version of this that avoids |
I was thinking about this more, and I realized even though we've been working on the same project for years now, we may view things differently here. Today, To me, But I realized perhaps you've seen it more this whole time as being the declarative frontend, and today it just happens to only support cross builds. Is that the case? |
I've tried a couple of different places for this command, but wasn't comfortable defining the UX for #2326 in the process, because I think there's still some fleshing out to do there. And the semantics are not exactly the same as what we're doing here. The reason I ended up under Of course, once we do have #2326 I think it makes sense to revisit and possibly unify the UX (or decide to leave it a separate command that just uses the same backend). Anyway, I'm OK also adding an experimental Currently working on factoring out the container bits to share with |
But see above - I was talking about It's worth noting here of course that quite commonly today To state this a different way, the fact that we're mutating the current root is what I'm keying in on. Now, I don't want to block this! But I think this discussion isn't just bikeshedding - it's important to have a shared consensus and understanding of what these different CLI verbs mean, because it has a large impact on the system architecture. |
04b5b1c
to
688efa0
Compare
Right yup. I do agree that fact is more pertinent than the server/client distinction. I wouldn't read too much into the Anyway, I've moved this to OK, got carried away a bit and also added support for reading dropins and completely ripping out microdnf. Can split some of this into separate PRs if preferred. |
Split out the first four into #3350. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks sane, a few comments.
Cargo.toml
Outdated
@@ -78,6 +78,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } | |||
tokio = { version = "1.15.0", features = ["full"] } | |||
xmlrpc = "0.15.1" | |||
termcolor = "1.1.2" | |||
glob = "0.3.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, glancing at the reverse dependencies this is at least a somewhat widely used crate. Notably, cargo uses it.
That said it was also last updated 3 years ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, coreos-installer uses it too, which is where I learned it from.
rust/src/treefile.rs
Outdated
@@ -46,6 +47,9 @@ const INCLUDE_MAXDEPTH: u32 = 50; | |||
/// it's intended to be informative. | |||
const COMPOSE_JSON_PATH: &str = "usr/share/rpm-ostree/treefile.json"; | |||
|
|||
/// Globby path to client-side treefiles. | |||
const CLIENT_TREEFILES_GLOB: &str = "/etc/rpm-ostree/origin.d/*.yaml"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in this case, it's not really clear to me that we're gaining very much with this crate glob versus just looping over the directory contents ourselves with if !name.ends_with(".yaml") { continue; }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially wanted to use the **
bit, but agreed it's a bit overkill as is.
@@ -2260,3 +2272,20 @@ pub(crate) fn treefile_new_client(filename: &str, basearch: &str) -> CxxResult<B | |||
r.error_if_base()?; | |||
Ok(r) | |||
} | |||
|
|||
/// Create a new client treefile using the treefile dropins in /etc/rpm-ostree/origin.d/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool.
{ | ||
// XXX: awkward: add a e.g. `treefile_new_client_from_fields()` | ||
g_autofree char *joined = g_strjoinv ("\",\"", packages); | ||
g_autofree char *treefile_s = g_strdup_printf ("{\"packages\": [\"%s\"]}", joined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eeek. I think today we can do treefile_new_empty()
and then let's add a set_packages()
API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep that in a follow-up? I'd like to consider something more generic than per-field methods.
Add support for creating a client treefile based on the dropins in `/etc/rpm-ostree/origin.d`. This will currently be used only by the container flow, but could eventually also end up being used client-side as discussed in coreos#2326.
688efa0
to
0ae9972
Compare
rpm-ostree compose container
commandrpm-ostree ex rebuild
command
This command reads treefile dropins in `/etc` and applies it to the system. Only the OSTree container flow is supported for now. For the client-side flow, see coreos#2326. In the container flow, only `packages` is currently supported. But this paves the way for supporting more derivation fields as well as making currently "base" fields only become valid derivation fields too (by promoting it from the `BaseComposeConfigFields` struct to `TreeComposeConfig`). What we're doing here is providing a "container" backend for derivation treefiles, but coreos#2326 will provide a "client" backend which uses the core more fully. But the inputs themselves are the exact same, hence providing symmetry between the two flows. (See also discussions about this in coreos/fedora-coreos-tracker#1054). This will also allow us to drop the `microdnf` dependency which will be done in a following patch.
We know how to natively do package installs in containers now, so use that instead of relying on microdnf.
0ae9972
to
0e1a2ad
Compare
OK, added a test for this now. Currently fighting issues with cosa locally so I didn't actually verify that it passes, but we'll see what CI says. |
The only thing we use it for is clearing the cache. But now that we use the core, which uses a different cache directory, that command doesn't delete the right thing. And at that point, it's just simpler to directly delete it ourselves in the container flow. Though I think it could also make sense to add a `--no-cache` switch directly to `rebuild` so that container builders can just apply the config and clear the cache in one shot.
0e1a2ad
to
8202134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work here!
let mut tfs = iter_etc_treefiles()?.collect::<Result<Vec<PathBuf>>>()?; | ||
tfs.sort(); // sort because order matters; later treefiles override earlier ones |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, that's a trap. Hmm. Also an argument for having the API for loading config files return a Vec<>
directly. But that can be a followup.
Or...I dunno actually, the more I think about this the more I think we shouldn't allow overrides at all? Allowing it just seems like it's most likely to be a footgun for users.
At least this isn't a problem yet right because we're only supporting packages which are always unionioned?
This command reads treefile dropins in
/etc
and applies it to thesystem. Only the OSTree container flow is supported for now. For the
client-side flow, see #2326.
In the container flow, only
packages
is currently supported. But thispaves the way for supporting more derivation fields as well as making
currently "base" fields only become valid derivation fields too (by
promoting it from the
BaseComposeConfigFields
struct toTreeComposeConfig
).What we're doing here is providing a "container" backend for derivation
treefiles, but #2326 will provide a "client" backend which uses the core
more fully. But the inputs themselves are the exact same, hence
providing symmetry between the two flows. (See also discussions about
this in coreos/fedora-coreos-tracker#1054).
This will also allow us to drop the
microdnf
dependency which will bedone in a following patch.