daemon: Move a bit more deployment-variant code to Rust

These are "base ostree" things we can move into the Rust
function.
This commit is contained in:
Colin Walters 2021-03-08 13:50:43 +00:00 committed by OpenShift Merge Robot
parent fbe01b403f
commit 01b59f20ba
2 changed files with 8 additions and 5 deletions

View File

@ -1,4 +1,6 @@
//! Rust portion of rpmostreed-deployment-utils.cxx //! Rust portion of rpmostreed-deployment-utils.cxx
//! The code here is mainly involved in converting on-disk state (i.e. ostree commits/deployments)
//! into GVariant which will be serialized via DBus.
// SPDX-License-Identifier: Apache-2.0 OR MIT // SPDX-License-Identifier: Apache-2.0 OR MIT
@ -21,6 +23,8 @@ pub(crate) fn deployment_generate_id(
) )
} }
/// Serialize information about the given deployment into the `dict`;
/// this will be exposed via DBus and is hence public API.
pub(crate) fn deployment_populate_variant( pub(crate) fn deployment_populate_variant(
mut sysroot: Pin<&mut crate::FFIOstreeSysroot>, mut sysroot: Pin<&mut crate::FFIOstreeSysroot>,
mut deployment: Pin<&mut crate::FFIOstreeDeployment>, mut deployment: Pin<&mut crate::FFIOstreeDeployment>,
@ -64,5 +68,9 @@ pub(crate) fn deployment_populate_variant(
} }
} }
dict.insert("pinned", &deployment.is_pinned());
let unlocked = deployment.get_unlocked();
dict.insert("unlocked", &unlocked.to_string());
Ok(()) Ok(())
} }

View File

@ -360,11 +360,6 @@ rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot,
g_variant_dict_insert_value (dict, "base-removals", removed_base_pkgs); g_variant_dict_insert_value (dict, "base-removals", removed_base_pkgs);
g_variant_dict_insert_value (dict, "base-local-replacements", replaced_base_pkgs); g_variant_dict_insert_value (dict, "base-local-replacements", replaced_base_pkgs);
g_variant_dict_insert (dict, "pinned", "b",
ostree_deployment_is_pinned (deployment));
g_variant_dict_insert (dict, "unlocked", "s",
ostree_deployment_unlocked_state_to_string (ostree_deployment_get_unlocked (deployment)));
g_variant_dict_insert (dict, "regenerate-initramfs", "b", g_variant_dict_insert (dict, "regenerate-initramfs", "b",
rpmostree_origin_get_regenerate_initramfs (origin)); rpmostree_origin_get_regenerate_initramfs (origin));
{ const char *const* args = rpmostree_origin_get_initramfs_args (origin); { const char *const* args = rpmostree_origin_get_initramfs_args (origin);