From 9adbc165e705bcefed8da0470b325e8b39d5edc4 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 23 Dec 2013 11:40:57 -0500 Subject: [PATCH] repo: Introspect _sign_commit() and _verify_commit() We can't use #ifdef in the headers, since then g-ir-scanner won't pick up the functions (unless we included config.h). Let's instead always have the symbols, but just set an error if we were built without support for it, just like how pull works. --- src/libostree/ostree-repo.c | 15 ++++++++++++--- src/libostree/ostree-repo.h | 2 -- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index 20b4d098..372becd8 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -1478,7 +1478,6 @@ ostree_repo_pull (OstreeRepo *self, } #endif -#ifdef HAVE_GPGME gboolean ostree_repo_sign_commit (OstreeRepo *self, const gchar *commit_checksum, @@ -1487,6 +1486,7 @@ ostree_repo_sign_commit (OstreeRepo *self, GCancellable *cancellable, GError **error) { +#ifdef HAVE_GPGME gboolean ret = FALSE; gs_unref_object GFile *commit_path = NULL; gs_unref_variant GVariant *metadata = NULL; @@ -1648,6 +1648,11 @@ out: if (signature_file) g_mapped_file_unref (signature_file); return ret; +#else + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + "This version of ostree was compiled without GPG support"); + return FALSE; +#endif } /** @@ -1670,6 +1675,7 @@ ostree_repo_verify_commit (OstreeRepo *self, GCancellable *cancellable, GError **error) { +#ifdef HAVE_GPGME gboolean ret = FALSE; gs_unref_object OstreeGpgVerifier *verifier = NULL; gs_unref_variant GVariant *commit_variant = NULL; @@ -1778,6 +1784,9 @@ out: if (commit_tmp_path) (void) gs_file_unlink (commit_tmp_path, NULL, NULL); return ret; -} - +#else + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + "This version of ostree was compiled without GPG support"); + return FALSE; #endif +} diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h index 6a97f6b8..2186389d 100644 --- a/src/libostree/ostree-repo.h +++ b/src/libostree/ostree-repo.h @@ -466,7 +466,6 @@ gboolean ostree_repo_pull (OstreeRepo *self, GCancellable *cancellable, GError **error); -#ifdef HAVE_GPGME gboolean ostree_repo_sign_commit (OstreeRepo *self, const gchar *commit_checksum, const gchar *key_id, @@ -480,7 +479,6 @@ gboolean ostree_repo_verify_commit (OstreeRepo *self, GFile *extra_keyring, GCancellable *cancellable, GError **error); -#endif G_END_DECLS