chantra / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

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

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