summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2019-01-04 14:26:32 +0100
committerKalev Lember <klember@redhat.com>2019-01-05 16:33:23 +0100
commitc7bb3b87e406400d3fda433784189756ac1d3081 (patch)
treefd66fb0d608ded976d14df3ffc4c64ed2a6f29a8
parente2bf14b590bf2df18497d20888c8062f06467075 (diff)
downloadappstream-glib-wip/kalev/rpmvercmp.tar.gz
Use rpmvercmp instead of internal vercmp when built with rpm supportwip/kalev/rpmvercmp
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 37d4747..393a023 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