File 0001-Support-allow_vendor_change-setting-in-dnf-context-A.patch of Package libdnf

From 690243af4f5113368ce905e750577926bfe94977 Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa13@gmail.com>
Date: Wed, 18 Nov 2020 08:03:28 -0500
Subject: [PATCH] Support allow_vendor_change setting in dnf context API

= changelog =
msg: Support allow_vendor_change setting in dnf context API
type: enhancement
---
 libdnf/dnf-context.cpp | 33 +++++++++++++++++++++++++++++++++
 libdnf/dnf-context.h   |  2 ++
 2 files changed, 35 insertions(+)

diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
index 33e7eb6d..06926711 100644
--- a/libdnf/dnf-context.cpp
+++ b/libdnf/dnf-context.cpp
@@ -932,6 +932,22 @@ dnf_context_get_install_weak_deps()
     return mainConf.install_weak_deps().getValue();
 }
 
+/**
+ * dnf_context_get_allow_vendor_change:
+ *
+ * Gets allow_vendor_change global configuration value.
+ *
+ * Returns: %TRUE if changing vendors in a transaction is allowed
+ *
+ * Since: 0.55.2
+ */
+gboolean
+dnf_context_get_allow_vendor_change()
+{
+    auto & mainConf = libdnf::getGlobalMainConfig();
+    return mainConf.allow_vendor_change().getValue();
+}
+
 /**
  * dnf_context_get_check_disk_space:
  * @context: a #DnfContext instance.
@@ -1409,6 +1425,20 @@ dnf_context_set_install_weak_deps(gboolean enabled)
     mainConf.install_weak_deps().set(libdnf::Option::Priority::RUNTIME, enabled);
 }
 
+/**
+ * dnf_context_set_allow_vendor_change:
+ *
+ * Sets allow_vendor_change global configuration value.
+ *
+ * Since: 0.55.2
+ */
+void
+dnf_context_set_allow_vendor_change(gboolean vendorchange)
+{
+    auto & mainConf = libdnf::getGlobalMainConfig();
+    mainConf.allow_vendor_change().set(libdnf::Option::Priority::RUNTIME, vendorchange);
+}
+
 /**
  * dnf_context_set_cache_only:
  * @context: a #DnfContext instance.
@@ -1725,12 +1755,15 @@ dnf_context_setup_sack_with_flags(DnfContext               *context,
     DnfContextPrivate *priv = GET_PRIVATE(context);
     gboolean ret;
     g_autofree gchar *solv_dir_real = nullptr;
+    gboolean vendorchange;
 
     /* create empty sack */
     solv_dir_real = dnf_realpath(priv->solv_dir);
+    vendorchange = dnf_context_get_allow_vendor_change();
     priv->sack = dnf_sack_new();
     dnf_sack_set_cachedir(priv->sack, solv_dir_real);
     dnf_sack_set_rootdir(priv->sack, priv->install_root);
+    dnf_sack_set_allow_vendor_change(priv->sack, vendorchange);
     if (priv->arch) {
         if(!dnf_sack_set_arch(priv->sack, priv->arch, error)) {
             return FALSE;
diff --git a/libdnf/dnf-context.h b/libdnf/dnf-context.h
index f5dfb0b3..71e12ebd 100644
--- a/libdnf/dnf-context.h
+++ b/libdnf/dnf-context.h
@@ -132,6 +132,7 @@ const gchar     **dnf_context_get_native_arches         (DnfContext     *context
 const gchar     **dnf_context_get_installonly_pkgs      (DnfContext     *context);
 gboolean         dnf_context_get_best                   (void);
 gboolean         dnf_context_get_install_weak_deps      (void);
+gboolean         dnf_context_get_allow_vendor_change    (void);
 gboolean         dnf_context_get_cache_only             (DnfContext     *context);
 gboolean         dnf_context_get_check_disk_space       (DnfContext     *context);
 gboolean         dnf_context_get_check_transaction      (DnfContext     *context);
@@ -185,6 +186,7 @@ void             dnf_context_set_source_root            (DnfContext     *context
                                                          const gchar    *source_root);
 void             dnf_context_set_best                   (gboolean        best);
 void             dnf_context_set_install_weak_deps      (gboolean        enabled);
+void             dnf_context_set_allow_vendor_change    (gboolean        vendorchange);
 void             dnf_context_set_cache_only             (DnfContext     *context,
                                                          gboolean        cache_only);
 void             dnf_context_set_check_disk_space       (DnfContext     *context,
-- 
2.28.0

openSUSE Build Service is sponsored by