summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2019-01-04 14:26:32 +0100
committerRichard Hughes <richard@hughsie.com>2019-02-06 12:16:48 +0000
commit2d8182a2d3213e67be087d60002bb36826f38e4c (patch)
tree44abd810987fe9087c7e830249450e2d94fc3e9d
parenta2edcbe958fa6de2e7c325e70ed8e58f478f1719 (diff)
downloadappstream-glib-2d8182a2d3213e67be087d60002bb36826f38e4c.tar.gz
Use rpmvercmp instead of internal vercmp when built with rpm support
This should help make sure that the version comparison algorithm matches exactly with Fedora's when built on Fedora and supports caret, tilde, and plus characters that all have special semantics in Fedora packages. https://github.com/hughsie/appstream-glib/issues/270
-rw-r--r--libappstream-glib/as-utils.c8
-rw-r--r--libappstream-glib/meson.build4
2 files changed, 12 insertions, 0 deletions
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index e475c65..6f46e52 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -40,6 +40,10 @@
#include <stdlib.h>
#include <uuid.h>
+#ifdef HAVE_RPM
+#include <rpm/rpmlib.h>
+#endif
+
#include "as-app-private.h"
#include "as-enums.h"
#include "as-node.h"
@@ -1465,7 +1469,11 @@ as_utils_vercmp_full (const gchar *version_a,
g_autofree gchar *str_b = as_utils_version_parse (version_b);
return as_utils_vercmp_internal (str_a, str_b);
} else {
+#ifdef HAVE_RPM
+ return rpmvercmp (version_a, version_b);
+#else
return as_utils_vercmp_internal (version_a, version_b);
+#endif
}
}
diff --git a/libappstream-glib/meson.build b/libappstream-glib/meson.build
index 3de5881..5f726b0 100644
--- a/libappstream-glib/meson.build
+++ b/libappstream-glib/meson.build
@@ -17,6 +17,10 @@ if get_option('dep11')
deps += yaml
endif
+if get_option('rpm')
+ deps += rpm
+endif
+
if get_option('stemmer')
deps += stemmer
endif