Blame SOURCES/0005-github-rpm-libdnf-pr1274.patch

575665
From 27a8e7be662b9fca6badc8925d5991d5d7abfcfc Mon Sep 17 00:00:00 2001
575665
From: Jonathan Lebon <jonathan@jlebon.com>
575665
Date: Wed, 16 Jun 2021 09:11:43 -0400
575665
Subject: [PATCH] os-release.cpp: make initLibRpm call dnf_context_globals_init
575665
575665
We shouldn't have our separate static var here. Otherwise clients will
575665
incur `rpmReadConfigFiles` twice which breaks their ability to
575665
consistently override macros.
575665
575665
Reported-by: Luca Bruno <lbruno@redhat.com>
575665
Reported-by: Christian Kellner <ckellner@redhat.com>
575665
575665
Fixes: #1273
575665
---
575665
 libdnf/utils/os-release.cpp | 10 ++++------
575665
 1 file changed, 4 insertions(+), 6 deletions(-)
575665
575665
diff --git a/libdnf/libdnf/utils/os-release.cpp b/libdnf/libdnf/utils/os-release.cpp
575665
index 1d8a95be65..e2f3d06dd0 100644
575665
--- a/libdnf/libdnf/utils/os-release.cpp
575665
+++ b/libdnf/libdnf/utils/os-release.cpp
575665
@@ -80,12 +80,10 @@ std::map<std::string, std::string> getOsReleaseData()
575665
 
575665
 static void initLibRpm()
575665
 {
575665
-    static bool libRpmInitiated{false};
575665
-    if (libRpmInitiated) return;
575665
-    if (rpmReadConfigFiles(NULL, NULL) != 0) {
575665
-        throw std::runtime_error("failed to read rpm config files\n");
575665
-    }
575665
-    libRpmInitiated = true;
575665
+    // call dnf_context_globals_init to ensure this only happens once
575665
+    g_autoptr(GError) local_error = NULL;
575665
+    if (!dnf_context_globals_init(&local_error))
575665
+        throw std::runtime_error(local_error->message);
575665
 }
575665
 
575665
 static std::string getBaseArch()