diff --git a/rust/src/cxxrsutil.rs b/rust/src/cxxrsutil.rs index 4daddfbe..fb9fa984 100644 --- a/rust/src/cxxrsutil.rs +++ b/rust/src/cxxrsutil.rs @@ -97,7 +97,7 @@ macro_rules! cxxrs_bind { cxxrs_bind!(Ostree, ostree, ostree_sys, [Sysroot, Repo, Deployment]); cxxrs_bind!(G, glib, gobject_sys, [Object]); cxxrs_bind!(G, gio, gio_sys, [Cancellable, DBusConnection]); -cxxrs_bind!(G, glib, glib_sys, [VariantDict]); +cxxrs_bind!(G, glib, glib_sys, [Variant, VariantDict]); // An error type helper; separate from the GObject bridging mod err { diff --git a/rust/src/lib.rs b/rust/src/lib.rs index d04407a4..ebf2fbc2 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -38,6 +38,7 @@ pub mod ffi { type GObject = crate::FFIGObject; type GCancellable = crate::FFIGCancellable; type GDBusConnection = crate::FFIGDBusConnection; + type GVariant = crate::FFIGVariant; type GVariantDict = crate::FFIGVariantDict; #[namespace = "dnfcxx"] @@ -216,8 +217,10 @@ pub mod ffi { deployment: Pin<&mut OstreeDeployment>, ) -> Result; fn applylive_sync_ref(sysroot: Pin<&mut OstreeSysroot>) -> Result<()>; - // FIXME/cxx make this Option<&str> - fn transaction_apply_live(sysroot: Pin<&mut OstreeSysroot>, target: &str) -> Result<()>; + fn transaction_apply_live( + sysroot: Pin<&mut OstreeSysroot>, + target: Pin<&mut GVariant>, + ) -> Result<()>; } // passwd.rs diff --git a/rust/src/live.rs b/rust/src/live.rs index 4f39c9a7..b78585d1 100644 --- a/rust/src/live.rs +++ b/rust/src/live.rs @@ -350,14 +350,13 @@ fn get_required_booted_deployment(sysroot: &ostree::Sysroot) -> Result, - target: &str, + mut options: Pin<&mut crate::ffi::GVariant>, ) -> CxxResult<()> { let sysroot = &sysroot.gobj_wrap(); - let target = if !target.is_empty() { - Some(target) - } else { - None - }; + let options = &options.gobj_wrap(); + let options = glib::VariantDict::new(Some(options)); + let target = options.lookup_value("target", Some(glib::VariantTy::new("s").unwrap())); + let target = target.as_ref().map(|v| v.get_str()).flatten(); let repo = &sysroot.repo().expect("repo"); let booted = get_required_booted_deployment(sysroot)?; diff --git a/src/daemon/rpmostreed-transaction-applylive.cxx b/src/daemon/rpmostreed-transaction-applylive.cxx index 251c83ae..a44eae98 100644 --- a/src/daemon/rpmostreed-transaction-applylive.cxx +++ b/src/daemon/rpmostreed-transaction-applylive.cxx @@ -69,14 +69,9 @@ livefs_transaction_execute (RpmostreedTransaction *transaction, LiveFsTransaction *self = (LiveFsTransaction *) transaction; OstreeSysroot *sysroot = rpmostreed_transaction_get_sysroot (transaction); - g_auto(GVariantDict) options_dict; - g_variant_dict_init (&options_dict, self->options); - const char *target = NULL; - (void) g_variant_dict_lookup (&options_dict, "target", "&s", &target); - /* Run the transaction */ try { - rpmostreecxx::transaction_apply_live(*sysroot, target ?: ""); + rpmostreecxx::transaction_apply_live(*sysroot, *self->options); } catch (std::exception& e) { (void) rpmostree_syscore_bump_mtime (sysroot, NULL); throw; diff --git a/src/libpriv/rpmostree-cxxrs-prelude.h b/src/libpriv/rpmostree-cxxrs-prelude.h index 8436d163..ae83391a 100644 --- a/src/libpriv/rpmostree-cxxrs-prelude.h +++ b/src/libpriv/rpmostree-cxxrs-prelude.h @@ -31,6 +31,7 @@ namespace rpmostreecxx { typedef ::GObject GObject; typedef ::GCancellable GCancellable; typedef ::GDBusConnection GDBusConnection; + typedef ::GVariant GVariant; typedef ::GVariantDict GVariantDict; }