[pacman-dev] [PATCH] Fix build with --disable-gpgme

Allan McRae allan at archlinux.org
Sat Dec 21 04:25:03 EST 2013


The alpm_decode_signature function was made available for frontends to
display signature information, but this required libalpm to be build with
gpgme support.  As that function did not require anything from gpgme,
have it build unconditionally.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/Makefile.am |  6 +----
 lib/libalpm/signing.c   | 60 ++++++++++++++++++++++++-------------------------
 2 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 171bc46..16a46ef 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -30,6 +30,7 @@ libalpm_la_SOURCES = \
 	alpm.h alpm.c \
 	alpm_list.h alpm_list.c \
 	backup.h backup.c \
+	base64.h base64.c \
 	be_local.c \
 	be_package.c \
 	be_sync.c \
@@ -63,11 +64,6 @@ libalpm_la_SOURCES += \
 	sha2.h sha2.c
 endif
 
-if HAVE_LIBGPGME
-libalpm_la_SOURCES += \
-	base64.h base64.c
-endif
-
 libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO)
 
 libalpm_la_CFLAGS = \
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index b594a9b..6043a8e 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -24,17 +24,46 @@
 #if HAVE_LIBGPGME
 #include <locale.h> /* setlocale() */
 #include <gpgme.h>
-#include "base64.h"
 #endif
 
 /* libalpm */
 #include "signing.h"
 #include "package.h"
+#include "base64.h"
 #include "util.h"
 #include "log.h"
 #include "alpm.h"
 #include "handle.h"
 
+/**
+ * Decode a loaded signature in base64 form.
+ * @param base64_data the signature to attempt to decode
+ * @param data the decoded data; must be freed by the caller
+ * @param data_len the length of the returned data
+ * @return 0 on success, -1 on failure to properly decode
+ */
+
+int SYMEXPORT alpm_decode_signature(const char *base64_data,
+		unsigned char **data, size_t *data_len)
+{
+	size_t len = strlen(base64_data);
+	unsigned char *usline = (unsigned char *)base64_data;
+	/* reasonable allocation of expected length is 3/4 of encoded length */
+	size_t destlen = len * 3 / 4;
+	MALLOC(*data, destlen, goto error);
+	if(base64_decode(*data, &destlen, usline, len)) {
+		free(*data);
+		goto error;
+	}
+	*data_len = destlen;
+	return 0;
+
+error:
+	*data = NULL;
+	*data_len = 0;
+	return -1;
+}
+
 #if HAVE_LIBGPGME
 #define CHECK_ERR(void) do { \
 		if(gpg_err_code(gpg_err) != GPG_ERR_NO_ERROR) { goto gpg_error; } \
@@ -418,35 +447,6 @@ int _alpm_key_import(alpm_handle_t *handle, const char *fpr)
 }
 
 /**
- * Decode a loaded signature in base64 form.
- * @param base64_data the signature to attempt to decode
- * @param data the decoded data; must be freed by the caller
- * @param data_len the length of the returned data
- * @return 0 on success, -1 on failure to properly decode
- */
-
-int SYMEXPORT alpm_decode_signature(const char *base64_data,
-		unsigned char **data, size_t *data_len)
-{
-	size_t len = strlen(base64_data);
-	unsigned char *usline = (unsigned char *)base64_data;
-	/* reasonable allocation of expected length is 3/4 of encoded length */
-	size_t destlen = len * 3 / 4;
-	MALLOC(*data, destlen, goto error);
-	if(base64_decode(*data, &destlen, usline, len)) {
-		free(*data);
-		goto error;
-	}
-	*data_len = destlen;
-	return 0;
-
-error:
-	*data = NULL;
-	*data_len = 0;
-	return -1;
-}
-
-/**
  * Check the PGP signature for the given file path.
  * If base64_sig is provided, it will be used as the signature data after
  * decoding. If base64_sig is NULL, expect a signature file next to path
-- 
1.8.5.2



More information about the pacman-dev mailing list