From 01b59f20ba8b0c33ff5b9224d64f5a8434f39e0e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 8 Mar 2021 13:50:43 +0000 Subject: [PATCH] daemon: Move a bit more deployment-variant code to Rust These are "base ostree" things we can move into the Rust function. --- rust/src/daemon.rs | 8 ++++++++ src/daemon/rpmostreed-deployment-utils.cxx | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rust/src/daemon.rs b/rust/src/daemon.rs index 54958682..dd9fe088 100644 --- a/rust/src/daemon.rs +++ b/rust/src/daemon.rs @@ -1,4 +1,6 @@ //! 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 @@ -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( mut sysroot: Pin<&mut crate::FFIOstreeSysroot>, 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(()) } diff --git a/src/daemon/rpmostreed-deployment-utils.cxx b/src/daemon/rpmostreed-deployment-utils.cxx index df3c866e..3e388700 100644 --- a/src/daemon/rpmostreed-deployment-utils.cxx +++ b/src/daemon/rpmostreed-deployment-utils.cxx @@ -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-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", rpmostree_origin_get_regenerate_initramfs (origin)); { const char *const* args = rpmostree_origin_get_initramfs_args (origin);