From 460da675862af4f5428580e38c6f6b7d80c83f29 Mon Sep 17 00:00:00 2001 From: RishabhSaini Date: Tue, 30 Aug 2022 10:58:23 -0400 Subject: [PATCH] libdnf: checks out a newer commit supporting network wait rpmostree-pkg-builtins.cxx: Adds a command line flag for --network-wait rpmostree-sysroot-upgrader.cxx: Adds network_wait to struct SysrootUpgrader and support for setting it rpmostree-transaction-types.cxx: Addresses a call to network wait by adding to struct sysroot_upgrader For each configured ostree remote and each enabled yum repository, wait until we can reach those over the network. This requires modifications in libdnf and librepo --- libdnf | 2 +- src/app/rpmostree-pkg-builtins.cxx | 5 +++++ src/daemon/rpmostree-sysroot-upgrader.cxx | 8 ++++++++ src/daemon/rpmostree-sysroot-upgrader.h | 2 ++ src/daemon/rpmostreed-transaction-types.cxx | 6 ++++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libdnf b/libdnf index 67440807f4..f26d5da500 160000 --- a/libdnf +++ b/libdnf @@ -1 +1 @@ -Subproject commit 67440807f4cb7eb0887f3e08de6ea589a2e2c823 +Subproject commit f26d5da50071a525c34ed57b16d847bee434946f diff --git a/src/app/rpmostree-pkg-builtins.cxx b/src/app/rpmostree-pkg-builtins.cxx index c2c55247bd..7114037360 100644 --- a/src/app/rpmostree-pkg-builtins.cxx +++ b/src/app/rpmostree-pkg-builtins.cxx @@ -46,6 +46,7 @@ static gboolean opt_uninstall_all; static gboolean opt_unchanged_exit_77; static gboolean opt_lock_finalization; static gboolean opt_force_replacefiles; +static guint opt_network_wait; static GOptionEntry option_entries[] = { { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Operate on provided OSNAME", "OSNAME" }, @@ -83,6 +84,8 @@ static GOptionEntry install_option_entry[] "Apply changes to both pending deployment and running filesystem tree", NULL }, { "force-replacefiles", 0, 0, G_OPTION_ARG_NONE, &opt_force_replacefiles, "Allow package to replace files from other packages", NULL }, + { "network-wait", 'N', 0, G_OPTION_ARG_INT, &opt_network_wait, + "Wait to reach into remote repository till network setup", "seconds" }, { NULL } }; static gboolean @@ -125,6 +128,8 @@ pkg_change (RpmOstreeCommandInvocation *invocation, RPMOSTreeSysroot *sysroot_pr g_variant_dict_insert (&dict, "lock-finalization", "b", opt_lock_finalization); if (opt_apply_live) g_variant_dict_insert (&dict, "apply-live", "b", opt_apply_live); + if (opt_network_wait) + g_variant_dict_insert (&dict, "network-wait", "u", opt_network_wait); g_autoptr (GVariant) options = g_variant_ref_sink (g_variant_dict_end (&dict)); gboolean met_local_pkg = FALSE; diff --git a/src/daemon/rpmostree-sysroot-upgrader.cxx b/src/daemon/rpmostree-sysroot-upgrader.cxx index d84e4f7de5..2796c90691 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.cxx +++ b/src/daemon/rpmostree-sysroot-upgrader.cxx @@ -90,6 +90,7 @@ struct RpmOstreeSysrootUpgrader char *command_line; char *agent; char *sd_unit; + guint network_wait_timeout_secs; OstreeDeployment *cfg_merge_deployment; OstreeDeployment *origin_merge_deployment; @@ -905,6 +906,11 @@ prepare_context_for_assembly (RpmOstreeSysrootUpgrader *self, const char *tmproo return TRUE; } +void +rpmostree_sysroot_upgrader_set_network_wait (RpmOstreeSysrootUpgrader *self, int network_wait_sec) { + self->network_wait_timeout_secs = network_wait_sec; +} + /* Initialize libdnf context from our configuration */ static gboolean prep_local_assembly (RpmOstreeSysrootUpgrader *self, GCancellable *cancellable, GError **error) @@ -942,6 +948,8 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self, GCancellable *cancellable, error)) return FALSE; + dnf_context_set_network_timeout_seconds(rpmostree_context_get_dnf(self->ctx), self->network_wait_timeout_secs); + if (rpmostree_origin_has_any_packages (self->computed_origin)) { if (!rpmostree_context_prepare (self->ctx, cancellable, error)) diff --git a/src/daemon/rpmostree-sysroot-upgrader.h b/src/daemon/rpmostree-sysroot-upgrader.h index 7a90dfe32a..2d8b0baa11 100644 --- a/src/daemon/rpmostree-sysroot-upgrader.h +++ b/src/daemon/rpmostree-sysroot-upgrader.h @@ -121,4 +121,6 @@ gboolean rpmostree_sysroot_upgrader_deploy (RpmOstreeSysrootUpgrader *self, GCancellable *cancellable, GError **error); void rpmostree_sysroot_upgrader_set_kargs (RpmOstreeSysrootUpgrader *self, char **kernel_args); + +void rpmostree_sysroot_upgrader_set_network_wait (RpmOstreeSysrootUpgrader *self, int network_wait_sec); G_END_DECLS diff --git a/src/daemon/rpmostreed-transaction-types.cxx b/src/daemon/rpmostreed-transaction-types.cxx index 66f603bc06..c11c8a1023 100644 --- a/src/daemon/rpmostreed-transaction-types.cxx +++ b/src/daemon/rpmostreed-transaction-types.cxx @@ -1557,6 +1557,12 @@ deploy_transaction_execute (RpmostreedTransaction *transaction, GCancellable *ca return TRUE; } + int network_wait_sec; + if(g_variant_dict_lookup(self->options, "network-wait", "u", &network_wait_sec)) + { + rpmostree_sysroot_upgrader_set_network_wait(upgrader, network_wait_sec); + } + RpmOstreeSysrootUpgraderLayeringType layering_type; gboolean layering_changed = FALSE; if (!rpmostree_sysroot_upgrader_prep_layering (upgrader, &layering_type, &layering_changed,