Skip to content

Commit

Permalink
container: Add progress spinners to compose container-encapsulate
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cgwalters committed Aug 27, 2022
1 parent ea5e9b6 commit 3d2dc7c
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions rust/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -214,16 +215,16 @@ pub fn container_encapsulate(args: Vec<String>) -> 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(),
rev.as_str(),
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())?;
Expand Down Expand Up @@ -318,7 +319,10 @@ pub fn container_encapsulate(args: Vec<String>) -> 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
Expand Down Expand Up @@ -387,16 +391,18 @@ pub fn container_encapsulate(args: Vec<String>) -> 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(())
Expand Down

0 comments on commit 3d2dc7c

Please sign in to comment.