Blame SOURCES/fwupd-build-with-old-deps.patch

d3d05c
diff --git a/data/fwupd.service.in b/data/fwupd.service.in
d3d05c
index 0110ea8c..49d84153 100644
d3d05c
--- a/data/fwupd.service.in
d3d05c
+++ b/data/fwupd.service.in
d3d05c
@@ -10,11 +10,3 @@ BusName=org.freedesktop.fwupd
d3d05c
 ExecStart=@libexecdir@/fwupd/fwupd
d3d05c
 MemoryDenyWriteExecute=yes
d3d05c
 PrivateTmp=yes
d3d05c
-ProtectControlGroups=yes
d3d05c
-ProtectHome=yes
d3d05c
-ProtectKernelModules=yes
d3d05c
-ProtectSystem=full
d3d05c
-RestrictAddressFamilies=AF_NETLINK AF_UNIX
d3d05c
-RestrictRealtime=yes
d3d05c
-ReadWritePaths=@localstatedir@/lib/fwupd @sysconfdir@/fwupd/remotes.d -@bootdir@
d3d05c
-SystemCallFilter=~@mount
d3d05c
diff --git a/meson.build b/meson.build
d3d05c
index 7cc6fe85..8d58bd45 100644
d3d05c
--- a/meson.build
d3d05c
+++ b/meson.build
d3d05c
@@ -145,7 +145,11 @@ gudev = dependency('gudev-1.0')
d3d05c
 if gudev.version().version_compare('>= 232')
d3d05c
   conf.set('HAVE_GUDEV_232', '1')
d3d05c
 endif
d3d05c
-appstream_glib = dependency('appstream-glib', version : '>= 0.6.13')
d3d05c
+appstream_glib = dependency('appstream-glib', version : '>= 0.6.10')
d3d05c
+
d3d05c
+# only for appstream <= 0.6.13
d3d05c
+uuid = dependency('uuid')
d3d05c
+
d3d05c
 gusb = dependency('gusb', version : '>= 0.2.9')
d3d05c
 sqlite = dependency('sqlite3')
d3d05c
 libarchive = dependency('libarchive')
d3d05c
@@ -215,7 +219,7 @@ if get_option('enable-thunderbolt')
d3d05c
 endif
d3d05c
 
d3d05c
 if get_option('enable-systemd')
d3d05c
-  systemd = dependency('systemd', version : '>= 231')
d3d05c
+  systemd = dependency('systemd')
d3d05c
   conf.set('HAVE_SYSTEMD' , '1')
d3d05c
 endif
d3d05c
 
d3d05c
diff --git a/src/fu-engine.c b/src/fu-engine.c
d3d05c
index 79b0a147..bcc18350 100644
d3d05c
--- a/src/fu-engine.c
d3d05c
+++ b/src/fu-engine.c
d3d05c
@@ -54,6 +54,131 @@
d3d05c
 #include "fu-keyring-pkcs7.h"
d3d05c
 #endif
d3d05c
 
d3d05c
+#if !AS_CHECK_VERSION(0,6,12)
d3d05c
+#include <fnmatch.h>
d3d05c
+#endif
d3d05c
+
d3d05c
+#if AS_CHECK_VERSION(0,6,13)
d3d05c
+static gint
d3d05c
+as_utils_vercmp_SAFE (const gchar *version_a, const gchar *version_b)
d3d05c
+{
d3d05c
+	return as_utils_vercmp (version_a, version_b);
d3d05c
+}
d3d05c
+#else
d3d05c
+
d3d05c
+static gchar *
d3d05c
+as_utils_version_parse_SAFE (const gchar *version)
d3d05c
+{
d3d05c
+	const gchar *version_noprefix = version;
d3d05c
+	gchar *endptr = NULL;
d3d05c
+	guint64 tmp;
d3d05c
+	guint base;
d3d05c
+	guint i;
d3d05c
+
d3d05c
+	/* already dotted decimal */
d3d05c
+	if (g_strstr_len (version, -1, ".") != NULL)
d3d05c
+		return g_strdup (version);
d3d05c
+
d3d05c
+	/* is a date */
d3d05c
+	if (g_str_has_prefix (version, "20") &&
d3d05c
+	    strlen (version) == 8)
d3d05c
+		return g_strdup (version);
d3d05c
+
d3d05c
+	/* convert 0x prefixed strings to dotted decimal */
d3d05c
+	if (g_str_has_prefix (version, "0x")) {
d3d05c
+		version_noprefix += 2;
d3d05c
+		base = 16;
d3d05c
+	} else {
d3d05c
+		/* for non-numeric content, just return the string */
d3d05c
+		for (i = 0; version[i] != '\0'; i++) {
d3d05c
+			if (!g_ascii_isdigit (version[i]))
d3d05c
+				return g_strdup (version);
d3d05c
+		}
d3d05c
+		base = 10;
d3d05c
+	}
d3d05c
+
d3d05c
+	/* convert */
d3d05c
+	tmp = g_ascii_strtoull (version_noprefix, &endptr, base);
d3d05c
+	if (endptr != NULL && endptr[0] != '\0')
d3d05c
+		return g_strdup (version);
d3d05c
+	if (tmp == 0)
d3d05c
+		return g_strdup (version);
d3d05c
+	return as_utils_version_from_uint32 ((guint32) tmp, AS_VERSION_PARSE_FLAG_USE_TRIPLET);
d3d05c
+}
d3d05c
+
d3d05c
+static gint
d3d05c
+as_utils_vercmp_SAFE (const gchar *version_a, const gchar *version_b)
d3d05c
+{
d3d05c
+	gchar *endptr;
d3d05c
+	gint64 ver_a;
d3d05c
+	gint64 ver_b;
d3d05c
+	guint i;
d3d05c
+	guint longest_split;
d3d05c
+	g_autofree gchar *str_a = NULL;
d3d05c
+	g_autofree gchar *str_b = NULL;
d3d05c
+	g_auto(GStrv) split_a = NULL;
d3d05c
+	g_auto(GStrv) split_b = NULL;
d3d05c
+
d3d05c
+	/* sanity check */
d3d05c
+	if (version_a == NULL || version_b == NULL)
d3d05c
+		return G_MAXINT;
d3d05c
+
d3d05c
+	/* optimisation */
d3d05c
+	if (g_strcmp0 (version_a, version_b) == 0)
d3d05c
+		return 0;
d3d05c
+
d3d05c
+	/* split into sections, and try to parse */
d3d05c
+	str_a = as_utils_version_parse_SAFE (version_a);
d3d05c
+	str_b = as_utils_version_parse_SAFE (version_b);
d3d05c
+	split_a = g_strsplit (str_a, ".", -1);
d3d05c
+	split_b = g_strsplit (str_b, ".", -1);
d3d05c
+	longest_split = MAX (g_strv_length (split_a), g_strv_length (split_b));
d3d05c
+	for (i = 0; i < longest_split; i++) {
d3d05c
+		gboolean isnum_a = TRUE;
d3d05c
+		gboolean isnum_b = TRUE;
d3d05c
+
d3d05c
+		/* we lost or gained a dot */
d3d05c
+		if (split_a[i] == NULL)
d3d05c
+			return -1;
d3d05c
+		if (split_b[i] == NULL)
d3d05c
+			return 1;
d3d05c
+
d3d05c
+		/* compare integers */
d3d05c
+		ver_a = g_ascii_strtoll (split_a[i], &endptr, 10);
d3d05c
+		if (endptr != NULL && endptr[0] != '\0')
d3d05c
+			isnum_a = FALSE;
d3d05c
+		if (ver_a < 0)
d3d05c
+			isnum_a = FALSE;
d3d05c
+		ver_b = g_ascii_strtoll (split_b[i], &endptr, 10);
d3d05c
+		if (endptr != NULL && endptr[0] != '\0')
d3d05c
+			isnum_b = FALSE;
d3d05c
+		if (ver_b < 0)
d3d05c
+			isnum_b = FALSE;
d3d05c
+
d3d05c
+		/* can't compare integer with string */
d3d05c
+		if (isnum_a != isnum_b)
d3d05c
+			return G_MAXINT;
d3d05c
+
d3d05c
+		/* compare strings */
d3d05c
+		if (!isnum_a) {
d3d05c
+			gint rc = g_strcmp0 (split_a[i], split_b[i]);
d3d05c
+			if (rc != 0)
d3d05c
+				return rc;
d3d05c
+
d3d05c
+		/* compare integers */
d3d05c
+		} else {
d3d05c
+			if (ver_a < ver_b)
d3d05c
+				return -1;
d3d05c
+			if (ver_a > ver_b)
d3d05c
+				return 1;
d3d05c
+		}
d3d05c
+	}
d3d05c
+
d3d05c
+	/* we really shouldn't get here */
d3d05c
+	return 0;
d3d05c
+}
d3d05c
+#endif
d3d05c
+
d3d05c
 static void fu_engine_finalize	 (GObject *obj);
d3d05c
 
d3d05c
 struct _FuEngine
d3d05c
@@ -811,6 +936,77 @@ _as_app_get_screenshot_default (AsApp *app)
d3d05c
 #endif
d3d05c
 }
d3d05c
 
d3d05c
+#if !AS_CHECK_VERSION(0,6,12)
d3d05c
+static gboolean
d3d05c
+as_require_version_compare_SAFE (AsRequire *require,
d3d05c
+			    const gchar *version,
d3d05c
+			    GError **error)
d3d05c
+{
d3d05c
+	const gchar *priv__version = as_require_get_version (require);
d3d05c
+	AsRequireCompare priv__compare = as_require_get_compare (require);
d3d05c
+	gboolean ret = FALSE;
d3d05c
+	gint rc = 0;
d3d05c
+
d3d05c
+	switch (priv__compare) {
d3d05c
+	case AS_REQUIRE_COMPARE_EQ:
d3d05c
+		rc = as_utils_vercmp_SAFE (version, priv__version);
d3d05c
+		ret = rc == 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_NE:
d3d05c
+		rc = as_utils_vercmp_SAFE (version, priv__version);
d3d05c
+		ret = rc != 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_LT:
d3d05c
+		rc = as_utils_vercmp_SAFE (version, priv__version);
d3d05c
+		ret = rc < 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_GT:
d3d05c
+		rc = as_utils_vercmp_SAFE (version, priv__version);
d3d05c
+		ret = rc > 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_LE:
d3d05c
+		rc = as_utils_vercmp_SAFE (version, priv__version);
d3d05c
+		ret = rc <= 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_GE:
d3d05c
+		rc = as_utils_vercmp_SAFE (version, priv__version);
d3d05c
+		ret = rc >= 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_GLOB:
d3d05c
+		ret = fnmatch (priv__version, version, 0) == 0;
d3d05c
+		break;
d3d05c
+	case AS_REQUIRE_COMPARE_REGEX:
d3d05c
+		ret = g_regex_match_simple (priv__version, version, 0, 0);
d3d05c
+		break;
d3d05c
+	default:
d3d05c
+		break;
d3d05c
+	}
d3d05c
+
d3d05c
+	/* could not compare */
d3d05c
+	if (rc == G_MAXINT) {
d3d05c
+		g_set_error (error,
d3d05c
+			     AS_UTILS_ERROR,
d3d05c
+			     AS_UTILS_ERROR_FAILED,
d3d05c
+			     "failed to compare [%s] and [%s]",
d3d05c
+			     priv__version,
d3d05c
+			     version);
d3d05c
+		return FALSE;
d3d05c
+	}
d3d05c
+
d3d05c
+	/* set error */
d3d05c
+	if (!ret && error != NULL) {
d3d05c
+		g_set_error (error,
d3d05c
+			     AS_UTILS_ERROR,
d3d05c
+			     AS_UTILS_ERROR_FAILED,
d3d05c
+			     "failed predicate [%s %s %s]",
d3d05c
+			     priv__version,
d3d05c
+			     as_require_compare_to_string (priv__compare),
d3d05c
+			     version);
d3d05c
+	}
d3d05c
+	return ret;
d3d05c
+}
d3d05c
+#endif
d3d05c
+
d3d05c
 static gboolean
d3d05c
 fu_engine_check_version_requirement (AsApp *app,
d3d05c
 				   AsRequireKind kind,
d3d05c
@@ -836,7 +1032,11 @@ fu_engine_check_version_requirement (AsApp *app,
d3d05c
 	}
d3d05c
 
d3d05c
 	/* check version */
d3d05c
+#if AS_CHECK_VERSION(0,6,12)
d3d05c
 	if (!as_require_version_compare (req, version, error)) {
d3d05c
+#else
d3d05c
+	if (!as_require_version_compare_SAFE (req, version, error)) {
d3d05c
+#endif
d3d05c
 		g_prefix_error (error, "Value of %s incorrect: ", id);
d3d05c
 		return FALSE;
d3d05c
 	}
d3d05c
@@ -1221,7 +1421,7 @@ fu_engine_install (FuEngine *self,
d3d05c
 
d3d05c
 	/* compare to the lowest supported version, if it exists */
d3d05c
 	tmp = fu_device_get_version_lowest (item->device);
d3d05c
-	if (tmp != NULL && as_utils_vercmp (tmp, version) > 0) {
d3d05c
+	if (tmp != NULL && as_utils_vercmp_SAFE (tmp, version) > 0) {
d3d05c
 		g_set_error (error,
d3d05c
 			     FWUPD_ERROR,
d3d05c
 			     FWUPD_ERROR_VERSION_NEWER,
d3d05c
@@ -1240,7 +1440,7 @@ fu_engine_install (FuEngine *self,
d3d05c
 			     device_id);
d3d05c
 		return FALSE;
d3d05c
 	}
d3d05c
-	vercmp = as_utils_vercmp (tmp, version);
d3d05c
+	vercmp = as_utils_vercmp_SAFE (tmp, version);
d3d05c
 	if (vercmp == 0 && (flags & FWUPD_INSTALL_FLAG_ALLOW_REINSTALL) == 0) {
d3d05c
 		g_set_error (error,
d3d05c
 			     FWUPD_ERROR,
d3d05c
@@ -1476,7 +1676,7 @@ fu_engine_get_action_id_for_device (FuEngine *self,
d3d05c
 				     "Release has no firmware version");
d3d05c
 		return NULL;
d3d05c
 	}
d3d05c
-	vercmp = as_utils_vercmp (version, version_release);
d3d05c
+	vercmp = as_utils_vercmp_SAFE (version, version_release);
d3d05c
 	if (vercmp == 0 && (flags & FWUPD_INSTALL_FLAG_ALLOW_REINSTALL) == 0) {
d3d05c
 		g_set_error (error,
d3d05c
 			     FWUPD_ERROR,
d3d05c
@@ -2099,7 +2299,7 @@ fu_engine_sort_releases_cb (gconstpointer a, gconstpointer b)
d3d05c
 {
d3d05c
 	FwupdRelease *rel_a = FWUPD_RELEASE (*((FwupdRelease **) a));
d3d05c
 	FwupdRelease *rel_b = FWUPD_RELEASE (*((FwupdRelease **) b));
d3d05c
-	return as_utils_vercmp (fwupd_release_get_version (rel_a),
d3d05c
+	return as_utils_vercmp_SAFE (fwupd_release_get_version (rel_a),
d3d05c
 				fwupd_release_get_version (rel_b));
d3d05c
 }
d3d05c
 
d3d05c
@@ -2246,7 +2446,7 @@ fu_engine_get_downgrades (FuEngine *self, const gchar *device_id, GError **error
d3d05c
 		gint vercmp;
d3d05c
 
d3d05c
 		/* only include older firmware */
d3d05c
-		vercmp = as_utils_vercmp (fwupd_release_get_version (rel_tmp),
d3d05c
+		vercmp = as_utils_vercmp_SAFE (fwupd_release_get_version (rel_tmp),
d3d05c
 					  fu_device_get_version (item->device));
d3d05c
 		if (vercmp == 0) {
d3d05c
 			g_string_append_printf (error_str, "%s=same, ",
d3d05c
@@ -2267,7 +2467,7 @@ fu_engine_get_downgrades (FuEngine *self, const gchar *device_id, GError **error
d3d05c
 
d3d05c
 		/* don't show releases we are not allowed to dowgrade to */
d3d05c
 		if (fu_device_get_version_lowest (item->device) != NULL) {
d3d05c
-			if (as_utils_vercmp (fwupd_release_get_version (rel_tmp),
d3d05c
+			if (as_utils_vercmp_SAFE (fwupd_release_get_version (rel_tmp),
d3d05c
 					     fu_device_get_version_lowest (item->device)) <= 0) {
d3d05c
 				g_string_append_printf (error_str, "%s=lowest, ",
d3d05c
 							fwupd_release_get_version (rel_tmp));
d3d05c
@@ -2339,7 +2539,7 @@ fu_engine_get_upgrades (FuEngine *self, const gchar *device_id, GError **error)
d3d05c
 		gint vercmp;
d3d05c
 
d3d05c
 		/* only include older firmware */
d3d05c
-		vercmp = as_utils_vercmp (fwupd_release_get_version (rel_tmp),
d3d05c
+		vercmp = as_utils_vercmp_SAFE (fwupd_release_get_version (rel_tmp),
d3d05c
 					  fu_device_get_version (item->device));
d3d05c
 		if (vercmp == 0) {
d3d05c
 			g_string_append_printf (error_str, "%s=same, ",
d3d05c
diff --git a/src/fu-hwids.c b/src/fu-hwids.c
d3d05c
index 5e7aa923..92d0afdf 100644
d3d05c
--- a/src/fu-hwids.c
d3d05c
+++ b/src/fu-hwids.c
d3d05c
@@ -69,6 +69,56 @@ fu_hwids_has_guid (FuHwids *self, const gchar *guid)
d3d05c
 	return g_hash_table_lookup (self->hash_guid, guid) != NULL;
d3d05c
 }
d3d05c
 
d3d05c
+#if !AS_CHECK_VERSION(0,6,13)
d3d05c
+#include <uuid.h>
d3d05c
+static gchar *
d3d05c
+as_utils_guid_from_data (const gchar *namespace_id,
d3d05c
+			 const guint8 *data,
d3d05c
+			 gsize data_len,
d3d05c
+			 GError **error)
d3d05c
+{
d3d05c
+	gchar guid_new[37]; /* 36 plus NUL */
d3d05c
+	gsize digestlen = 20;
d3d05c
+	guint8 hash[20];
d3d05c
+	gint rc;
d3d05c
+	uuid_t uu_namespace;
d3d05c
+	uuid_t uu_new;
d3d05c
+	g_autoptr(GChecksum) csum = NULL;
d3d05c
+
d3d05c
+	g_return_val_if_fail (namespace_id != NULL, FALSE);
d3d05c
+	g_return_val_if_fail (data != NULL, FALSE);
d3d05c
+	g_return_val_if_fail (data_len != 0, FALSE);
d3d05c
+
d3d05c
+	/* convert the namespace to binary */
d3d05c
+	rc = uuid_parse (namespace_id, uu_namespace);
d3d05c
+	if (rc != 0) {
d3d05c
+		g_set_error (error,
d3d05c
+			     AS_UTILS_ERROR,
d3d05c
+			     AS_UTILS_ERROR_FAILED,
d3d05c
+			     "namespace '%s' is invalid",
d3d05c
+			     namespace_id);
d3d05c
+		return FALSE;
d3d05c
+	}
d3d05c
+
d3d05c
+	/* hash the namespace and then the string */
d3d05c
+	csum = g_checksum_new (G_CHECKSUM_SHA1);
d3d05c
+	g_checksum_update (csum, (guchar *) uu_namespace, 16);
d3d05c
+	g_checksum_update (csum, (guchar *) data, (gssize) data_len);
d3d05c
+	g_checksum_get_digest (csum, hash, &digestlen);
d3d05c
+
d3d05c
+	/* copy most parts of the hash 1:1 */
d3d05c
+	memcpy (uu_new, hash, 16);
d3d05c
+
d3d05c
+	/* set specific bits according to Section 4.1.3 */
d3d05c
+	uu_new[6] = (guint8) ((uu_new[6] & 0x0f) | (5 << 4));
d3d05c
+	uu_new[8] = (guint8) ((uu_new[8] & 0x3f) | 0x80);
d3d05c
+
d3d05c
+	/* return as a string */
d3d05c
+	uuid_unparse (uu_new, guid_new);
d3d05c
+	return g_strdup (guid_new);
d3d05c
+}
d3d05c
+#endif
d3d05c
+
d3d05c
 static gchar *
d3d05c
 fu_hwids_get_guid_for_str (const gchar *str, GError **error)
d3d05c
 {
d3d05c
diff --git a/src/meson.build b/src/meson.build
d3d05c
index 3d35dd87..9788f529 100644
d3d05c
--- a/src/meson.build
d3d05c
+++ b/src/meson.build
d3d05c
@@ -38,6 +38,7 @@ libfwupdprivate = static_library(
d3d05c
   ],
d3d05c
   dependencies : [
d3d05c
     appstream_glib,
d3d05c
+    uuid,
d3d05c
     giounix,
d3d05c
     gudev,
d3d05c
     gusb,
d3d05c
@@ -67,6 +68,7 @@ fwupdmgr = executable(
d3d05c
   ],
d3d05c
   dependencies : [
d3d05c
     appstream_glib,
d3d05c
+    uuid,
d3d05c
     giounix,
d3d05c
     gudev,
d3d05c
     gusb,
d3d05c
@@ -141,6 +143,7 @@ executable(
d3d05c
   dependencies : [
d3d05c
     keyring_deps,
d3d05c
     appstream_glib,
d3d05c
+    uuid,
d3d05c
     giounix,
d3d05c
     gmodule,
d3d05c
     gudev,
d3d05c
@@ -203,6 +206,7 @@ if get_option('enable-tests')
d3d05c
     dependencies : [
d3d05c
       keyring_deps,
d3d05c
       appstream_glib,
d3d05c
+      uuid,
d3d05c
       giounix,
d3d05c
       gmodule,
d3d05c
       gudev,
d3d05c
@@ -260,6 +264,7 @@ if get_option('enable-introspection')
d3d05c
     ],
d3d05c
     dependencies : [
d3d05c
       appstream_glib,
d3d05c
+      uuid,
d3d05c
       gir_dep,
d3d05c
       giounix,
d3d05c
       gusb,