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