345ed6c98e
Resolves #1413637, #1413451 Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
210 lines
5.5 KiB
Diff
210 lines
5.5 KiB
Diff
From f4aec46ee3c6889d6a020721078cfab44f156708 Mon Sep 17 00:00:00 2001
|
|
From: Wes Lindauer <wesley.lindauer@gmail.com>
|
|
Date: Wed, 14 Dec 2016 15:02:56 -0500
|
|
Subject: [PATCH] daemon: Allow rpm to be optional at build time
|
|
|
|
---
|
|
configure.ac | 11 ++++++++++-
|
|
src/daemon/Makefile.am | 1 +
|
|
src/daemon/rpm.c | 31 +++++++++++++++++++++++++++++++
|
|
src/daemon/rpm.h | 5 -----
|
|
4 files changed, 42 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/configure.ac b/configure.ac
|
|
index f6597eb..4b05040 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -185,7 +185,6 @@ PKG_CHECK_MODULES([GTK], [gtk+-3.0])
|
|
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.43])
|
|
PKG_CHECK_MODULES([DBUS], [dbus-1])
|
|
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
|
|
-PKG_CHECK_MODULES([RPM], [rpm])
|
|
PKG_CHECK_MODULES([LIBNOTIFY], [libnotify >= 0.7.0])
|
|
PKG_CHECK_MODULES([NSS], [nss])
|
|
PKG_CHECK_MODULES([LIBREPORT], [libreport])
|
|
@@ -425,6 +424,16 @@ ABRT_PARSE_WITH([selinux]))
|
|
AM_CONDITIONAL(HAVE_SELINUX, false)
|
|
[fi]
|
|
|
|
+AC_ARG_WITH(rpm,
|
|
+AS_HELP_STRING([--with-rpm],[build rpm support (default is YES)]),
|
|
+ABRT_PARSE_WITH([rpm]))
|
|
+
|
|
+[if test -z "$NO_RPM"]
|
|
+[then]
|
|
+ PKG_CHECK_MODULES([RPM], [rpm])
|
|
+ AC_DEFINE(HAVE_LIBRPM, [], [Have rpm support.])
|
|
+[fi]
|
|
+
|
|
# Initialize the test suite.
|
|
AC_CONFIG_TESTDIR(tests)
|
|
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
|
|
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
|
|
index 563923a..9a41d5f 100644
|
|
--- a/src/daemon/Makefile.am
|
|
+++ b/src/daemon/Makefile.am
|
|
@@ -95,6 +95,7 @@ abrt_action_save_package_data_CPPFLAGS = \
|
|
-I$(srcdir)/../lib \
|
|
-DCONF_DIR=\"$(CONF_DIR)\" \
|
|
$(GLIB_CFLAGS) \
|
|
+ $(RPM_CFLAGS) \
|
|
$(LIBREPORT_CFLAGS) \
|
|
-D_GNU_SOURCE
|
|
abrt_action_save_package_data_LDADD = \
|
|
diff --git a/src/daemon/rpm.c b/src/daemon/rpm.c
|
|
index e99b960..36b36a9 100644
|
|
--- a/src/daemon/rpm.c
|
|
+++ b/src/daemon/rpm.c
|
|
@@ -19,6 +19,13 @@
|
|
#include "libabrt.h"
|
|
#include "rpm.h"
|
|
|
|
+#ifdef HAVE_LIBRPM
|
|
+#include <rpm/rpmts.h>
|
|
+#include <rpm/rpmcli.h>
|
|
+#include <rpm/rpmdb.h>
|
|
+#include <rpm/rpmpgp.h>
|
|
+#endif
|
|
+
|
|
/**
|
|
* A set, which contains finger prints.
|
|
*/
|
|
@@ -51,8 +58,10 @@ char* get_package_name_from_NVR_or_NULL(const char* packageNVR)
|
|
|
|
void rpm_init()
|
|
{
|
|
+#ifdef HAVE_LIBRPM
|
|
if (rpmReadConfigFiles(NULL, NULL) != 0)
|
|
error_msg("Can't read RPM rc files");
|
|
+#endif
|
|
|
|
list_free_with_free(list_fingerprints); /* paranoia */
|
|
/* Huh? Why do we start the list with an element with NULL string? */
|
|
@@ -61,6 +70,7 @@ void rpm_init()
|
|
|
|
void rpm_destroy()
|
|
{
|
|
+#ifdef HAVE_LIBRPM
|
|
/* Mirroring the order of deinit calls in rpm-4.11.1/lib/poptALL.c::rpmcliFini() */
|
|
rpmFreeCrypto();
|
|
rpmFreeMacros(NULL);
|
|
@@ -71,6 +81,7 @@ void rpm_destroy()
|
|
* "BDB2053 Freeing read locks for locker 0x1e0: 28718/139661746636736"
|
|
*/
|
|
rpmdbCheckTerminate(1);
|
|
+#endif
|
|
|
|
list_free_with_free(list_fingerprints);
|
|
list_fingerprints = NULL;
|
|
@@ -78,6 +89,7 @@ void rpm_destroy()
|
|
|
|
void rpm_load_gpgkey(const char* filename)
|
|
{
|
|
+#ifdef HAVE_LIBRPM
|
|
uint8_t *pkt = NULL;
|
|
size_t pklen;
|
|
if (pgpReadPkts(filename, &pkt, &pklen) != PGPARMOR_PUBKEY)
|
|
@@ -95,6 +107,9 @@ void rpm_load_gpgkey(const char* filename)
|
|
list_fingerprints = g_list_append(list_fingerprints, fingerprint);
|
|
}
|
|
free(pkt);
|
|
+#else
|
|
+ return;
|
|
+#endif
|
|
}
|
|
|
|
int rpm_chk_fingerprint(const char* pkg)
|
|
@@ -114,6 +129,7 @@ int rpm_fingerprint_is_imported(const char* fingerprint)
|
|
|
|
char *rpm_get_fingerprint(const char *pkg)
|
|
{
|
|
+#ifdef HAVE_LIBRPM
|
|
char *fingerprint = NULL;
|
|
char *pgpsig = NULL;
|
|
const char *errmsg = NULL;
|
|
@@ -141,6 +157,9 @@ error:
|
|
rpmdbFreeIterator(iter);
|
|
rpmtsFree(ts);
|
|
return fingerprint;
|
|
+#else
|
|
+ return NULL;
|
|
+#endif
|
|
}
|
|
|
|
/*
|
|
@@ -183,6 +202,7 @@ error:
|
|
}
|
|
*/
|
|
|
|
+#ifdef HAVE_LIBRPM
|
|
static int rpm_query_file(rpmts *ts, rpmdbMatchIterator *iter, Header *header,
|
|
const char *filename, const char *rootdir_or_NULL)
|
|
{
|
|
@@ -216,9 +236,11 @@ static int rpm_query_file(rpmts *ts, rpmdbMatchIterator *iter, Header *header,
|
|
|
|
return 0;
|
|
}
|
|
+#endif
|
|
|
|
char* rpm_get_component(const char *filename, const char *rootdir_or_NULL)
|
|
{
|
|
+#ifdef HAVE_LIBRPM
|
|
char *ret = NULL;
|
|
char *srpm = NULL;
|
|
rpmts ts;
|
|
@@ -246,8 +268,12 @@ char* rpm_get_component(const char *filename, const char *rootdir_or_NULL)
|
|
rpmdbFreeIterator(iter);
|
|
rpmtsFree(ts);
|
|
return ret;
|
|
+#else
|
|
+ return NULL;
|
|
+#endif
|
|
}
|
|
|
|
+#ifdef HAVE_LIBRPM
|
|
#define pkg_add_id(name) \
|
|
static inline int pkg_add_##name(Header header, struct pkg_envra *p) \
|
|
{ \
|
|
@@ -267,10 +293,12 @@ pkg_add_id(version);
|
|
pkg_add_id(release);
|
|
pkg_add_id(arch);
|
|
pkg_add_id(vendor);
|
|
+#endif
|
|
|
|
// caller is responsible to free returned value
|
|
struct pkg_envra *rpm_get_package_nvr(const char *filename, const char *rootdir_or_NULL)
|
|
{
|
|
+#ifdef HAVE_LIBRPM
|
|
rpmts ts;
|
|
rpmdbMatchIterator iter;
|
|
Header header;
|
|
@@ -330,6 +358,9 @@ struct pkg_envra *rpm_get_package_nvr(const char *filename, const char *rootdir_
|
|
rpmdbFreeIterator(iter);
|
|
rpmtsFree(ts);
|
|
return NULL;
|
|
+#else
|
|
+ return NULL;
|
|
+#endif
|
|
}
|
|
|
|
void free_pkg_envra(struct pkg_envra *p)
|
|
diff --git a/src/daemon/rpm.h b/src/daemon/rpm.h
|
|
index 89aa088..1fd56e8 100644
|
|
--- a/src/daemon/rpm.h
|
|
+++ b/src/daemon/rpm.h
|
|
@@ -22,11 +22,6 @@
|
|
#ifndef RPM_H_
|
|
#define RPM_H_
|
|
|
|
-#include <rpm/rpmts.h>
|
|
-#include <rpm/rpmcli.h>
|
|
-#include <rpm/rpmdb.h>
|
|
-#include <rpm/rpmpgp.h>
|
|
-
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
--
|
|
2.9.3
|
|
|