Skip to content

Commit

Permalink
compose: Stabilize compose rootfs
Browse files Browse the repository at this point in the history
Expose this as `rpm-ostree compose rootfs`.

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Feb 22, 2025
1 parent e1d43ae commit 08e49b9
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 1 deletion.
14 changes: 14 additions & 0 deletions rpmostree-cxxrs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,9 @@ extern "C"
::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$compose_image (::rust::Vec< ::rust::String> *args) noexcept;

::rust::repr::PtrLen
rpmostreecxx$cxxbridge1$compose_rootfs_entrypoint (::rust::Vec< ::rust::String> *args) noexcept;

::rust::repr::PtrLen rpmostreecxx$cxxbridge1$configure_build_repo_from_target (
::rpmostreecxx::OstreeRepo const &build_repo,
::rpmostreecxx::OstreeRepo const &target_repo) noexcept;
Expand Down Expand Up @@ -3980,6 +3983,17 @@ compose_image (::rust::Vec< ::rust::String> args)
}
}

void
compose_rootfs_entrypoint (::rust::Vec< ::rust::String> args)
{
::rust::ManuallyDrop< ::rust::Vec< ::rust::String> > args$ (::std::move (args));
::rust::repr::PtrLen error$ = rpmostreecxx$cxxbridge1$compose_rootfs_entrypoint (&args$.value);
if (error$.ptr)
{
throw ::rust::impl< ::rust::Error>::error (error$);
}
}

void
configure_build_repo_from_target (::rpmostreecxx::OstreeRepo const &build_repo,
::rpmostreecxx::OstreeRepo const &target_repo)
Expand Down
2 changes: 2 additions & 0 deletions rpmostree-cxxrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,8 @@ ::rpmostreecxx::GVariant *get_header_variant (::rpmostreecxx::OstreeRepo const &

void compose_image (::rust::Vec< ::rust::String> args);

void compose_rootfs_entrypoint (::rust::Vec< ::rust::String> args);

void configure_build_repo_from_target (::rpmostreecxx::OstreeRepo const &build_repo,
::rpmostreecxx::OstreeRepo const &target_repo);

Expand Down
6 changes: 6 additions & 0 deletions rust/src/compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,12 @@ impl RootfsOpts {
}
}

pub(crate) fn compose_rootfs_entrypoint(args: Vec<String>) -> CxxResult<()> {
let args = args.iter().map(|v| v.as_str());
RootfsOpts::parse_from(["rootfs"].into_iter().chain(args)).run()?;
Ok(())
}

impl CommitToContainerRootfsOpts {
/// Execute `compose commit-to-container-rootfs`. This just:
/// - Opens up the target ostree repo
Expand Down
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ pub mod ffi {
// compose.rs
extern "Rust" {
fn compose_image(args: Vec<String>) -> Result<()>;
fn compose_rootfs_entrypoint(args: Vec<String>) -> Result<()>;

fn configure_build_repo_from_target(
build_repo: &OstreeRepo,
Expand Down
14 changes: 14 additions & 0 deletions src/app/rpmostree-builtin-compose.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ static RpmOstreeCommand compose_subcommands[] = {
{ "image", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD,
"Generate a reproducible \"chunked\" container image (using RPM data) from a treefile",
rpmostree_compose_builtin_image },
{ "rootfs", RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD, "Generate a root filesystem tree from a treefile",
rpmostree_compose_builtin_rootfs },
{ NULL, (RpmOstreeBuiltinFlags)0, NULL, NULL }
};

Expand All @@ -76,4 +78,16 @@ rpmostree_compose_builtin_image (int argc, char **argv, RpmOstreeCommandInvocati
rustargv.push_back (std::string (argv[i]));
CXX_TRY (rpmostreecxx::compose_image (rustargv), error);
return TRUE;
}

gboolean
rpmostree_compose_builtin_rootfs (int argc, char **argv, RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable, GError **error)
{
rust::Vec<rust::String> rustargv;
g_assert_cmpint (argc, >, 0);
for (int i = 0; i < argc; i++)
rustargv.push_back (std::string (argv[i]));
CXX_TRY (rpmostreecxx::compose_rootfs_entrypoint (rustargv), error);
return TRUE;
}
3 changes: 3 additions & 0 deletions src/app/rpmostree-compose-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ gboolean rpmostree_compose_builtin_container_encapsulate (int argc, char **argv,
gboolean rpmostree_compose_builtin_image (int argc, char **argv,
RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable, GError **error);
gboolean rpmostree_compose_builtin_rootfs (int argc, char **argv,
RpmOstreeCommandInvocation *invocation,
GCancellable *cancellable, GError **error);

G_END_DECLS
2 changes: 1 addition & 1 deletion tests/compose-rootfs/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY . /src
WORKDIR /src
RUN --mount=type=bind,from=repos,src=/,dst=/repos,rw <<EORUN
set -xeuo pipefail
exec rpm-ostree experimental compose rootfs --source-root-rw=/repos manifest.yaml /target-rootfs
exec rpm-ostree compose rootfs --source-root-rw=/repos manifest.yaml /target-rootfs
EORUN

# This pulls in the rootfs generated in the previous step
Expand Down

0 comments on commit 08e49b9

Please sign in to comment.