Skip to content

Commit

Permalink
Merge pull request #3079 from cgwalters/sysroot-container-prep
Browse files Browse the repository at this point in the history
container: Accept an ostree::Repo directly
  • Loading branch information
Luca Bruno authored Aug 19, 2021
2 parents 53848c2 + a6c2f6e commit 960b917
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile.bindings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
binding_rust_sources = $(shell find rust/src/ -name '*.rs') Cargo.toml Cargo.lock

rust/cxx.h: Makefile.bindings
./target/cxxbridge/bin/cxxbridge --header >$@
./target/cxxbridge/bin/cxxbridge --header >$@.tmp && mv $@.tmp $@

rpmostree-cxxrs.h: $(binding_rust_sources)
$(AM_V_GEN) if ./target/cxxbridge/bin/cxxbridge rust/src/lib.rs --header > $@.tmp; then \
Expand Down
2 changes: 1 addition & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub mod ffi {
// sysroot_upgrade.rs
extern "Rust" {
fn import_container(
sysroot: Pin<&mut OstreeSysroot>,
repo: Pin<&mut OstreeRepo>,
imgref: String,
) -> Result<Box<ContainerImport>>;

Expand Down
5 changes: 2 additions & 3 deletions rust/src/sysroot_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ use std::pin::Pin;

/// Import ostree commit in container image using ostree-rs-ext's API.
pub(crate) fn import_container(
mut sysroot: Pin<&mut crate::FFIOstreeSysroot>,
mut repo: Pin<&mut crate::FFIOstreeRepo>,
imgref: String,
) -> CxxResult<Box<ContainerImport>> {
// TODO: take a GCancellable and monitor it, and drop the import task (which is how async cancellation works in Rust).
let sysroot = &sysroot.gobj_wrap();
let repo = &sysroot.repo().unwrap();
let repo = repo.gobj_wrap();
let imgref = imgref.as_str().try_into()?;
let imported = build_runtime()?
.block_on(async { ostree_ext::container::import(&repo, &imgref, None).await })?;
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/rpmostree-sysroot-upgrader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ rpmostree_sysroot_upgrader_pull_base (RpmOstreeSysrootUpgrader *self,
}

rpmostree_output_message ("Pulling: %s", refspec);
auto import = CXX_TRY_VAL(import_container(*self->sysroot, std::string(refspec)), error);
auto import = CXX_TRY_VAL(import_container(*self->repo, std::string(refspec)), error);

rpmostree_origin_set_container_image_reference_digest (self->original_origin, import->image_digest.c_str());
new_base_rev = strdup (import->ostree_commit.c_str());
Expand Down

0 comments on commit 960b917

Please sign in to comment.