From 3d2dc7cdd02cf3fb4bce864bbb4991c9cc5f8423 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 27 Aug 2022 09:20:52 -0400 Subject: [PATCH] container: Add progress spinners to `compose container-encapsulate` It turns out the part that's really slow right now is that RPM apparently walks the entire database to implement "find the package owning /usr/bin/foo". What we need to do is build up this mapping as part of the build process, and dump it out to a lookaside file (e.g. `rpm-ostree compose tree --write-owners-file=foo.db`) and then have the encapsulation code pick it up. Alternatively, we could change the encapsulation code to walk all RPMs, but eh. --- rust/src/container.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/rust/src/container.rs b/rust/src/container.rs index 69bcf22949..9e20a669d3 100644 --- a/rust/src/container.rs +++ b/rust/src/container.rs @@ -24,6 +24,7 @@ use ostree_ext::prelude::*; use ostree_ext::{gio, ostree}; use crate::cxxrsutil::FFIGObjectReWrap; +use crate::progress::progress_task; use crate::CxxResult; /// Main entrypoint for container @@ -214,7 +215,7 @@ pub fn container_encapsulate(args: Vec) -> Result<()> { let opt = ContainerEncapsulateOpts::parse_from(args); let repo = &ostree_ext::cli::parse_repo(opt.repo.as_str())?; let (root, rev) = repo.read_commit(opt.ostree_ref.as_str(), gio::NONE_CANCELLABLE)?; - let pkglist = { + let pkglist = progress_task("Reading packages", || -> Result<_> { let cancellable = gio::Cancellable::new(); let r = crate::ffi::package_variant_list_for_commit( repo.reborrow_cxx(), @@ -222,8 +223,8 @@ pub fn container_encapsulate(args: Vec) -> Result<()> { cancellable.reborrow_cxx(), )?; let r: glib::Variant = unsafe { glib::translate::from_glib_full(r as *mut _) }; - r - }; + Ok(r) + })?; // Open the RPM database for this commit. let q = crate::ffi::rpmts_for_commit(repo.reborrow_cxx(), rev.as_str())?; @@ -318,7 +319,10 @@ pub fn container_encapsulate(args: Vec) -> Result<()> { } // Walk the filesystem - build_mapping_recurse(&mut Utf8PathBuf::from("/"), &root, &q, &mut state)?; + progress_task("Building package mapping", || { + build_mapping_recurse(&mut Utf8PathBuf::from("/"), &root, &q, &mut state) + })?; + let src_pkgs: HashSet<_> = state.packagemeta.iter().map(|p| &p.srcid).collect(); // Print out information about what we found @@ -387,16 +391,18 @@ pub fn container_encapsulate(args: Vec) -> Result<()> { ..Default::default() }; let handle = tokio::runtime::Handle::current(); - let digest = handle.block_on(async { - ostree_ext::container::encapsulate( - repo, - rev.as_str(), - &config, - Some(opts), - Some(meta), - &opt.imgref, - ) - .await + let digest = progress_task("Generating container image", || { + handle.block_on(async { + ostree_ext::container::encapsulate( + repo, + rev.as_str(), + &config, + Some(opts), + Some(meta), + &opt.imgref, + ) + .await + }) })?; println!("Pushed digest: {}", digest); Ok(())