[Libosinfo] libosinfo on RHEL/EPEL
Christophe Fergeau
cfergeau at redhat.com
Thu Apr 25 09:01:20 UTC 2013
Hi,
On Wed, Apr 24, 2013 at 01:13:13PM -0400, Dennis Kliban wrote:
> I would like to be able to use libosinfo on RHEL6.4. I don't see a build for that. I attempted to install from the source RPM, but received the following errors: http://dpaste.org/RVnmu/
>
> I then downloaded the source and ran ./configure. When I ran make and I got the following errors: http://dpaste.org/nQmkx/
>
> Can someone help me build this package for RHEL6/EPEL6?
Ah, the errors you are getting are because we are trying to use
macros/functions that are not available in glib 2.22 (which is what RHEL6
has). The attached patch is a step in the right direction, but the build
still fails because of the use of GWeakRef. The fix for that would be a bit
more involved... (though g_object_add_weak_pointer() might do the trick).
Christophe
-------------- next part --------------
From e5da88d281feb1e4afd768bfbe085e5afd569972 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau at redhat.com>
Date: Thu, 25 Apr 2013 10:36:19 +0200
Subject: [PATCH] Add glib compatibility code for older glibs
libosinfo is using G_DEPRECATED_FOR which was only added in glib
2.32
---
osinfo/Makefile.am | 1 +
osinfo/osinfo.h | 1 +
osinfo/osinfo_glib_compat.c | 40 +++++++++++++++++++++++++++
osinfo/osinfo_glib_compat.h | 62 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 0 deletions(-)
create mode 100644 osinfo/osinfo_glib_compat.c
create mode 100644 osinfo/osinfo_glib_compat.h
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index 496ee34..d946b7e 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -69,6 +69,7 @@ OSINFO_HEADER_FILES = \
osinfo_device_driverlist.h \
osinfo_entity.h \
osinfo_filter.h \
+ osinfo_glib_compat.h \
osinfo_install_config.h \
osinfo_install_config_param.h \
osinfo_install_config_paramlist.h \
diff --git a/osinfo/osinfo.h b/osinfo/osinfo.h
index 0d0f3d2..f7f0442 100644
--- a/osinfo/osinfo.h
+++ b/osinfo/osinfo.h
@@ -27,6 +27,7 @@
#include <glib-object.h>
+#include <osinfo/osinfo_glib_compat.h>
#include <osinfo/osinfo_datamap.h>
#include <osinfo/osinfo_datamaplist.h>
#include <osinfo/osinfo_enum_types.h>
diff --git a/osinfo/osinfo_glib_compat.c b/osinfo/osinfo_glib_compat.c
new file mode 100644
index 0000000..5959059
--- /dev/null
+++ b/osinfo/osinfo_glib_compat.c
@@ -0,0 +1,40 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "osinfo_glib_compat.h"
+
+#if !GLIB_CHECK_VERSION(2,28,0)
+/**
+ * spice_simple_async_result_take_error: (skip)
+ * @simple: a #GSimpleAsyncResult
+ * @error: a #GError
+ *
+ * Sets the result from @error, and takes over the caller's ownership
+ * of @error, so the caller does not need to free it any more.
+ *
+ * Since: 2.28
+ **/
+G_GNUC_INTERNAL void
+g_simple_async_result_take_error (GSimpleAsyncResult *simple,
+ GError *error)
+{
+ /* this code is different from upstream */
+ /* we can't avoid extra copy/free, since the simple struct is
+ opaque */
+ g_simple_async_result_set_from_error (simple, error);
+ g_error_free (error);
+}
+#endif
diff --git a/osinfo/osinfo_glib_compat.h b/osinfo/osinfo_glib_compat.h
new file mode 100644
index 0000000..0eabe2c
--- /dev/null
+++ b/osinfo/osinfo_glib_compat.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef OSINFO_GLIB_COMPAT_H
+#define OSINFO_GLIB_COMPAT_H
+
+#include <gio/gio.h>
+
+#if !GLIB_CHECK_VERSION(2,28,0)
+#define g_clear_object(object_ptr) \
+ G_STMT_START { \
+ /* Only one access, please */ \
+ gpointer *_p = (gpointer) (object_ptr); \
+ gpointer _o; \
+ \
+ do \
+ _o = g_atomic_pointer_get (_p); \
+ while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (_p, _o, NULL));\
+ \
+ if (_o) \
+ g_object_unref (_o); \
+ } G_STMT_END
+
+void
+g_simple_async_result_take_error(GSimpleAsyncResult *simple,
+ GError *error);
+#endif
+
+
+#if !GLIB_CHECK_VERSION(2,32,0)
+
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+#define G_DEPRECATED __attribute__((__deprecated__))
+#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
+#define G_DEPRECATED __declspec(deprecated)
+#else
+#define G_DEPRECATED
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
+#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
+#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
+#define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
+#else
+#define G_DEPRECATED_FOR(f) G_DEPRECATED
+#endif
+
+#endif
+
+#endif /* OSINFO_GLIB_COMPAT_H */
--
1.7.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libosinfo/attachments/20130425/951c3d14/attachment.sig>
More information about the Libosinfo
mailing list