live: Pass options GVariant down
I have no idea why I didn't do this originally, it's much cleaner than parsing the options in C.
This commit is contained in:
parent
01b59f20ba
commit
b0eccadb22
@ -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 {
|
||||
|
@ -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<bool>;
|
||||
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
|
||||
|
@ -350,14 +350,13 @@ fn get_required_booted_deployment(sysroot: &ostree::Sysroot) -> Result<ostree::D
|
||||
/// Implementation of `rpm-ostree ex apply-live`.
|
||||
pub(crate) fn transaction_apply_live(
|
||||
mut sysroot: Pin<&mut crate::ffi::OstreeSysroot>,
|
||||
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)?;
|
||||
|
@ -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;
|
||||
|
@ -31,6 +31,7 @@ namespace rpmostreecxx {
|
||||
typedef ::GObject GObject;
|
||||
typedef ::GCancellable GCancellable;
|
||||
typedef ::GDBusConnection GDBusConnection;
|
||||
typedef ::GVariant GVariant;
|
||||
typedef ::GVariantDict GVariantDict;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user