From 485ff7335faf8afb9b4a47eca71cbae10ccd75aa Mon Sep 17 00:00:00 2001 From: Denis Pynkin Date: Tue, 19 Nov 2019 02:44:16 +0300 Subject: [PATCH] lib/sign: allow to build with glib version less than 2.44 Ubuntu 14.04 uses glib-2.40 which have no some shiny macroses for interface declaration. Signed-off-by: Denis Pynkin --- src/libostree/ostree-autocleanups.h | 1 + src/libostree/ostree-sign-dummy.c | 5 +++++ src/libostree/ostree-sign-dummy.h | 14 ++++++++++++++ src/libostree/ostree-sign-ed25519.c | 5 +++++ src/libostree/ostree-sign-ed25519.h | 15 ++++++++++++++- src/libostree/ostree-sign.c | 2 ++ src/libostree/ostree-sign.h | 18 ++++++++++++++---- src/libostree/ostree.h | 1 + 8 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/libostree/ostree-autocleanups.h b/src/libostree/ostree-autocleanups.h index c9692ebe..14017012 100644 --- a/src/libostree/ostree-autocleanups.h +++ b/src/libostree/ostree-autocleanups.h @@ -73,6 +73,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderOverride, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeRepoFinderResult, ostree_repo_finder_result_free) G_DEFINE_AUTO_CLEANUP_FREE_FUNC (OstreeRepoFinderResultv, ostree_repo_finder_result_freev, NULL) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeSign, g_object_unref) #endif G_END_DECLS diff --git a/src/libostree/ostree-sign-dummy.c b/src/libostree/ostree-sign-dummy.c index e2d1fe56..48190149 100644 --- a/src/libostree/ostree-sign-dummy.c +++ b/src/libostree/ostree-sign-dummy.c @@ -24,6 +24,7 @@ #include "config.h" +#include #include "ostree-sign-dummy.h" #include @@ -43,6 +44,10 @@ struct _OstreeSignDummy gchar *signature_ascii; }; +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeSignDummy, g_object_unref) +#endif + static void ostree_sign_dummy_iface_init (OstreeSignInterface *self); diff --git a/src/libostree/ostree-sign-dummy.h b/src/libostree/ostree-sign-dummy.h index a0d10e1d..f80f8682 100644 --- a/src/libostree/ostree-sign-dummy.h +++ b/src/libostree/ostree-sign-dummy.h @@ -32,12 +32,26 @@ G_BEGIN_DECLS #define OSTREE_TYPE_SIGN_DUMMY (ostree_sign_dummy_get_type ()) +_OSTREE_PUBLIC +GType ostree_sign_dummy_get_type (void); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +typedef struct _OstreeSignDummy OstreeSignDummy; +typedef struct { GObjectClass parent_class; } OstreeSignDummyClass; + +static inline OstreeSignDummy *OSTREE_SIGN_DUMMY (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_sign_dummy_get_type (), OstreeSignDummy); } +static inline gboolean OSTREE_IS_SIGN_DUMMY (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_sign_dummy_get_type ()); } + +G_GNUC_END_IGNORE_DEPRECATIONS + +/* Have to use glib-2.44 for this _OSTREE_PUBLIC G_DECLARE_FINAL_TYPE (OstreeSignDummy, ostree_sign_dummy, OSTREE, SIGN_DUMMY, GObject) +*/ const gchar * ostree_sign_dummy_get_name (OstreeSign *self); diff --git a/src/libostree/ostree-sign-ed25519.c b/src/libostree/ostree-sign-ed25519.c index 0c7cd951..2d5bdb16 100644 --- a/src/libostree/ostree-sign-ed25519.c +++ b/src/libostree/ostree-sign-ed25519.c @@ -25,6 +25,7 @@ #include "config.h" +#include #include "ostree-sign-ed25519.h" #ifdef HAVE_LIBSODIUM #include @@ -47,6 +48,10 @@ struct _OstreeSignEd25519 GList *revoked_keys; }; +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeSignEd25519, g_object_unref) +#endif + static void ostree_sign_ed25519_iface_init (OstreeSignInterface *self); diff --git a/src/libostree/ostree-sign-ed25519.h b/src/libostree/ostree-sign-ed25519.h index bced1cdf..6e5dd665 100644 --- a/src/libostree/ostree-sign-ed25519.h +++ b/src/libostree/ostree-sign-ed25519.h @@ -32,13 +32,26 @@ G_BEGIN_DECLS #define OSTREE_TYPE_SIGN_ED25519 (ostree_sign_ed25519_get_type ()) +_OSTREE_PUBLIC +GType ostree_sign_ed25519_get_type (void); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +typedef struct _OstreeSignEd25519 OstreeSignEd25519; +typedef struct { GObjectClass parent_class; } OstreeSignEd25519Class; + +static inline OstreeSignEd25519 *OSTREE_SIGN_ED25519 (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_sign_ed25519_get_type (), OstreeSignEd25519); } +static inline gboolean OSTREE_IS_SIGN_ED25519 (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_sign_ed25519_get_type ()); } + +G_GNUC_END_IGNORE_DEPRECATIONS + +/* Have to use glib-2.44 for this _OSTREE_PUBLIC G_DECLARE_FINAL_TYPE (OstreeSignEd25519, ostree_sign_ed25519, OSTREE, SIGN_ED25519, GObject) - +*/ gboolean ostree_sign_ed25519_data (OstreeSign *self, GBytes *data, diff --git a/src/libostree/ostree-sign.c b/src/libostree/ostree-sign.c index 95319f67..75db0b26 100644 --- a/src/libostree/ostree-sign.c +++ b/src/libostree/ostree-sign.c @@ -47,6 +47,8 @@ #include "ostree-sign-ed25519.h" #endif +#include "ostree-autocleanups.h" + #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "OSTreeSign" diff --git a/src/libostree/ostree-sign.h b/src/libostree/ostree-sign.h index 87ed25ce..1415becb 100644 --- a/src/libostree/ostree-sign.h +++ b/src/libostree/ostree-sign.h @@ -33,16 +33,26 @@ #include "ostree-remote.h" #include "ostree-types.h" -/* Special remote */ -#define OSTREE_SIGN_ALL_REMOTES "__OSTREE_ALL_REMOTES__" - - G_BEGIN_DECLS #define OSTREE_TYPE_SIGN (ostree_sign_get_type ()) +_OSTREE_PUBLIC +GType ostree_sign_get_type (void); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +typedef struct _OstreeSign OstreeSign; +typedef struct _OstreeSignInterface OstreeSignInterface; + +static inline OstreeSign *OSTREE_SIGN (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_CAST (ptr, ostree_sign_get_type (), OstreeSign); } +static inline gboolean OSTREE_IS_SIGN (gpointer ptr) { return G_TYPE_CHECK_INSTANCE_TYPE (ptr, ostree_sign_get_type ()); } +static inline OstreeSignInterface *OSTREE_SIGN_GET_IFACE (gpointer ptr) { return G_TYPE_INSTANCE_GET_INTERFACE (ptr, ostree_sign_get_type (), OstreeSignInterface); } +G_GNUC_END_IGNORE_DEPRECATIONS + +/* Have to use glib-2.44 for this _OSTREE_PUBLIC G_DECLARE_INTERFACE (OstreeSign, ostree_sign, OSTREE, SIGN, GObject) +*/ struct _OstreeSignInterface { diff --git a/src/libostree/ostree.h b/src/libostree/ostree.h index 49ca919c..0308d0ed 100644 --- a/src/libostree/ostree.h +++ b/src/libostree/ostree.h @@ -40,5 +40,6 @@ #include #include #include +#include #include #include