chantra / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

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

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