From bdd436683efa1dd5505beac3377cce289652677f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 24 Mar 2017 17:58:50 -0400 Subject: [PATCH 1/2] app: Add a helper to get a proxy for OSExperimental too Prep work for livefs. Also port the function to new style. --- src/app/rpmostree-dbus-helpers.c | 75 ++++++++++++++++++++------------ src/app/rpmostree-dbus-helpers.h | 9 ++++ 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/src/app/rpmostree-dbus-helpers.c b/src/app/rpmostree-dbus-helpers.c index 9100c3e7a4..c1a1ec953f 100644 --- a/src/app/rpmostree-dbus-helpers.c +++ b/src/app/rpmostree-dbus-helpers.c @@ -165,24 +165,16 @@ rpmostree_load_sysroot (gchar *sysroot, } gboolean -rpmostree_load_os_proxy (RPMOSTreeSysroot *sysroot_proxy, - gchar *opt_osname, - GCancellable *cancellable, - RPMOSTreeOS **out_os_proxy, - GError **error) +rpmostree_load_os_proxies (RPMOSTreeSysroot *sysroot_proxy, + gchar *opt_osname, + GCancellable *cancellable, + RPMOSTreeOS **out_os_proxy, + RPMOSTreeOSExperimental **out_osexperimental_proxy, + GError **error) { - gboolean ret = FALSE; - const char *bus_name; g_autofree char *os_object_path = NULL; - glnx_unref_object RPMOSTreeOS *os_proxy = NULL; - - GDBusConnection *connection = NULL; /* owned by sysroot_proxy */ - if (opt_osname == NULL) - { - os_object_path = rpmostree_sysroot_dup_booted (sysroot_proxy); - } - + os_object_path = rpmostree_sysroot_dup_booted (sysroot_proxy); if (os_object_path == NULL) { /* Usually if opt_osname is null and the property isn't @@ -197,29 +189,54 @@ rpmostree_load_os_proxy (RPMOSTreeSysroot *sysroot_proxy, &os_object_path, cancellable, error)) - goto out; + return FALSE; } - connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (sysroot_proxy)); - + /* owned by sysroot_proxy */ + GDBusConnection *connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (sysroot_proxy)); + const char *bus_name; if (g_dbus_connection_get_unique_name (connection) != NULL) bus_name = BUS_NAME; - os_proxy = rpmostree_os_proxy_new_sync (connection, - G_DBUS_PROXY_FLAGS_NONE, - bus_name, - os_object_path, - cancellable, - error); - + glnx_unref_object RPMOSTreeOS *os_proxy = + rpmostree_os_proxy_new_sync (connection, + G_DBUS_PROXY_FLAGS_NONE, + bus_name, + os_object_path, + cancellable, + error); if (os_proxy == NULL) - goto out; + return FALSE; + + glnx_unref_object RPMOSTreeOSExperimental *ret_osexperimental_proxy = NULL; + if (out_osexperimental_proxy) + { + ret_osexperimental_proxy = + rpmostree_osexperimental_proxy_new_sync (connection, + G_DBUS_PROXY_FLAGS_NONE, + bus_name, + os_object_path, + cancellable, + error); + if (!ret_osexperimental_proxy) + return FALSE; + } *out_os_proxy = g_steal_pointer (&os_proxy); - ret = TRUE; + if (out_osexperimental_proxy) + *out_osexperimental_proxy = g_steal_pointer (&ret_osexperimental_proxy); + return TRUE; +} -out: - return ret; +gboolean +rpmostree_load_os_proxy (RPMOSTreeSysroot *sysroot_proxy, + gchar *opt_osname, + GCancellable *cancellable, + RPMOSTreeOS **out_os_proxy, + GError **error) +{ + return rpmostree_load_os_proxies (sysroot_proxy, opt_osname, cancellable, + out_os_proxy, NULL, error); } diff --git a/src/app/rpmostree-dbus-helpers.h b/src/app/rpmostree-dbus-helpers.h index 3dbc90e3d8..e1d338cf63 100644 --- a/src/app/rpmostree-dbus-helpers.h +++ b/src/app/rpmostree-dbus-helpers.h @@ -50,6 +50,15 @@ rpmostree_load_os_proxy (RPMOSTreeSysroot *sysroot_proxy, RPMOSTreeOS **out_os_proxy, GError **error); +gboolean +rpmostree_load_os_proxies (RPMOSTreeSysroot *sysroot_proxy, + gchar *opt_osname, + GCancellable *cancellable, + RPMOSTreeOS **out_os_proxy, + RPMOSTreeOSExperimental **out_osexperimental_proxy, + GError **error); + + gboolean rpmostree_transaction_get_response_sync (RPMOSTreeSysroot *sysroot_proxy, const char *transaction_address, From afe359a57c3dc0f8e96fffecf66753945c4f7895 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 25 Mar 2017 10:34:24 -0400 Subject: [PATCH 2/2] =?UTF-8?q?daemon:=20Add=20a=20sysroot=20argument=20to?= =?UTF-8?q?=20state=20=E2=86=92=20GVariant=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prep for livefs; there we're storing live update state as xattrs on the deployment root, and hence we need access to the sysroot to query it. --- src/daemon/rpmostreed-deployment-utils.c | 3 ++- src/daemon/rpmostreed-deployment-utils.h | 15 ++++++++------- src/daemon/rpmostreed-os.c | 15 +++++++++------ src/daemon/rpmostreed-sysroot.c | 7 ++++--- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/daemon/rpmostreed-deployment-utils.c b/src/daemon/rpmostreed-deployment-utils.c index 53c179f737..f05ea3d429 100644 --- a/src/daemon/rpmostreed-deployment-utils.c +++ b/src/daemon/rpmostreed-deployment-utils.c @@ -157,7 +157,8 @@ variant_add_commit_details (GVariantDict *dict, } GVariant * -rpmostreed_deployment_generate_variant (OstreeDeployment *deployment, +rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot, + OstreeDeployment *deployment, const char *booted_id, OstreeRepo *repo, GError **error) diff --git a/src/daemon/rpmostreed-deployment-utils.h b/src/daemon/rpmostreed-deployment-utils.h index da004650f3..68f31238bf 100644 --- a/src/daemon/rpmostreed-deployment-utils.h +++ b/src/daemon/rpmostreed-deployment-utils.h @@ -30,15 +30,16 @@ OstreeDeployment * GVariant * rpmostreed_deployment_generate_blank_variant (void); -GVariant * rpmostreed_deployment_generate_variant (OstreeDeployment *deployment, - const char *booted_id, - OstreeRepo *repo, - GError **error); +GVariant * rpmostreed_deployment_generate_variant (OstreeSysroot *sysroot, + OstreeDeployment *deployment, + const char *booted_id, + OstreeRepo *repo, + GError **error); GVariant * rpmostreed_commit_generate_cached_details_variant (OstreeDeployment *deployment, - OstreeRepo *repo, - const gchar *refspec, - GError **error); + OstreeRepo *repo, + const gchar *refspec, + GError **error); gint rpmostreed_rollback_deployment_index (const gchar *name, OstreeSysroot *ot_sysroot, diff --git a/src/daemon/rpmostreed-os.c b/src/daemon/rpmostreed-os.c index 23cf7941cf..279919c94c 100644 --- a/src/daemon/rpmostreed-os.c +++ b/src/daemon/rpmostreed-os.c @@ -1198,7 +1198,8 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error) booted = ostree_sysroot_get_booted_deployment (ot_sysroot); if (booted && g_strcmp0 (ostree_deployment_get_osname (booted), name) == 0) { - booted_variant = rpmostreed_deployment_generate_variant (booted, booted_id, ot_repo, error); + booted_variant = rpmostreed_deployment_generate_variant (ot_sysroot, booted, booted_id, + ot_repo, error); if (!booted_variant) return FALSE; booted_id = rpmostreed_deployment_generate_id (booted); @@ -1209,11 +1210,12 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error) { if (g_strcmp0 (ostree_deployment_get_osname (deployments->pdata[i]), name) == 0) { - default_variant = rpmostreed_deployment_generate_variant (deployments->pdata[i], + default_variant = rpmostreed_deployment_generate_variant (ot_sysroot, + deployments->pdata[i], booted_id, ot_repo, error); - if (default_variant == NULL) - return FALSE; + if (default_variant == NULL) + return FALSE; break; } } @@ -1223,8 +1225,9 @@ rpmostreed_os_load_internals (RpmostreedOS *self, GError **error) rollback_index = rpmostreed_rollback_deployment_index (name, ot_sysroot, NULL); if (rollback_index >= 0) { - rollback_variant = rpmostreed_deployment_generate_variant (deployments->pdata[rollback_index], booted_id, - ot_repo, error); + rollback_variant = rpmostreed_deployment_generate_variant (ot_sysroot, + deployments->pdata[rollback_index], booted_id, + ot_repo, error); if (!rollback_variant) return FALSE; } diff --git a/src/daemon/rpmostreed-sysroot.c b/src/daemon/rpmostreed-sysroot.c index 3435f7991c..d205171633 100644 --- a/src/daemon/rpmostreed-sysroot.c +++ b/src/daemon/rpmostreed-sysroot.c @@ -494,10 +494,11 @@ sysroot_populate_deployments_unlocked (RpmostreedSysroot *self, GVariant *variant; OstreeDeployment *deployment = deployments->pdata[i]; const char *deployment_os; - - variant = rpmostreed_deployment_generate_variant (deployment, booted_id, self->repo, error); + + variant = rpmostreed_deployment_generate_variant (self->ot_sysroot, deployment, + booted_id, self->repo, error); if (!variant) - goto out; + goto out; g_variant_builder_add_value (&builder, variant); deployment_os = ostree_deployment_get_osname (deployment);