richardphibel / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0003-Avoid-multilib-file-conflict-in-config.h-RhBug-1918818.patch

2acfc6
From 3f6adc99506f065d0858e4d9d46055be9d070634 Mon Sep 17 00:00:00 2001
2acfc6
From: Nicola Sella <nsella@redhat.com>
2acfc6
Date: Fri, 22 Jan 2021 16:07:37 +0100
2acfc6
Subject: [PATCH] Avoid multilib file conflict in config.h (RhBug:1918818)
2acfc6
2acfc6
=changelog=
2acfc6
msg: Avoid multilib file conflicts in config.h
2acfc6
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1918818
2acfc6
---
2acfc6
 .gitignore                             |  2 +-
2acfc6
 libdnf/CMakeLists.txt                  |  8 ++++++-
2acfc6
 libdnf/{config.h.in => config-64.h.in} |  6 +++---
2acfc6
 libdnf/config.h                        | 29 ++++++++++++++++++++++++++
2acfc6
 4 files changed, 40 insertions(+), 5 deletions(-)
2acfc6
 rename libdnf/{config.h.in => config-64.h.in} (87%)
2acfc6
 create mode 100644 libdnf/config.h
2acfc6
2acfc6
diff --git a/.gitignore b/.gitignore
2acfc6
index e17a9b9bb..0a63bdae7 100644
2acfc6
--- a/.gitignore
2acfc6
+++ b/.gitignore
2acfc6
@@ -5,4 +5,4 @@
2acfc6
 build
2acfc6
 *.pyc
2acfc6
 data/tests/modules/yum.repos.d/test.repo
2acfc6
-libdnf/config.h
2acfc6
+libdnf/config-64.h
2acfc6
diff --git a/libdnf/CMakeLists.txt b/libdnf/CMakeLists.txt
2acfc6
index e82aac11e..25f33d7b0 100644
2acfc6
--- a/libdnf/CMakeLists.txt
2acfc6
+++ b/libdnf/CMakeLists.txt
2acfc6
@@ -35,7 +35,13 @@ set(LIBDNF_SRCS
2acfc6
 include_directories(transaction)
2acfc6
 add_subdirectory("transaction")
2acfc6
 
2acfc6
-configure_file("config.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config.h)
2acfc6
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
2acfc6
+    set(MULTILIB_ARCH "64")
2acfc6
+    configure_file("config-64.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config-64.h)
2acfc6
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
2acfc6
+    set(MULTILIB_ARCH "32")
2acfc6
+    configure_file("config-64.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/config-32.h)
2acfc6
+endif()
2acfc6
 configure_file("dnf-version.h.in"  ${CMAKE_CURRENT_SOURCE_DIR}/dnf-version.h)
2acfc6
 configure_file("libdnf.pc.in" ${CMAKE_CURRENT_BINARY_DIR}/libdnf.pc @ONLY)
2acfc6
 
2acfc6
diff --git a/libdnf/config.h.in b/libdnf/config-64.h.in
2acfc6
similarity index 87%
2acfc6
rename from libdnf/config.h.in
2acfc6
rename to libdnf/config-64.h.in
2acfc6
index 77974f757..e2329fe71 100644
2acfc6
--- a/libdnf/config.h.in
2acfc6
+++ b/libdnf/config-64.h.in
2acfc6
@@ -18,9 +18,9 @@
2acfc6
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2acfc6
  */
2acfc6
 
2acfc6
-#ifndef _LIBDNF_CONFIG_H_
2acfc6
-#define _LIBDNF_CONFIG_H_
2acfc6
+#ifndef _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
2acfc6
+#define _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
2acfc6
 
2acfc6
 #define DEFAULT_PLUGINS_DIRECTORY "@CMAKE_INSTALL_FULL_LIBDIR@/libdnf/plugins/"
2acfc6
 
2acfc6
-#endif // _LIBDNF_CONFIG_H_
2acfc6
+#endif // _LIBDNF_CONFIG_@MULTILIB_ARCH@_H_
2acfc6
diff --git a/libdnf/config.h b/libdnf/config.h
2acfc6
new file mode 100644
2acfc6
index 000000000..16121f6f5
2acfc6
--- /dev/null
2acfc6
+++ b/libdnf/config.h
2acfc6
@@ -0,0 +1,29 @@
2acfc6
+/*
2acfc6
+ * Copyright (C) 2018 Red Hat, Inc.
2acfc6
+ *
2acfc6
+ * Licensed under the GNU Lesser General Public License Version 2.1
2acfc6
+ *
2acfc6
+ * This library is free software; you can redistribute it and/or
2acfc6
+ * modify it under the terms of the GNU Lesser General Public
2acfc6
+ * License as published by the Free Software Foundation; either
2acfc6
+ * version 2.1 of the License, or (at your option) any later version.
2acfc6
+ *
2acfc6
+ * This library is distributed in the hope that it will be useful,
2acfc6
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2acfc6
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2acfc6
+ * Lesser General Public License for more details.
2acfc6
+ *
2acfc6
+ * You should have received a copy of the GNU Lesser General Public
2acfc6
+ * License along with this library; if not, write to the Free Software
2acfc6
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2acfc6
+ */
2acfc6
+
2acfc6
+#include <bits/wordsize.h>
2acfc6
+
2acfc6
+#if __WORDSIZE == 32
2acfc6
+#include "config-32.h"
2acfc6
+#elif __WORDSIZE == 64
2acfc6
+#include "config-64.h"
2acfc6
+#else
2acfc6
+#error "Unknown word size"
2acfc6
+#endif