diff --git a/src/builder-manifest.c b/src/builder-manifest.c index 74d1074f..85e4a270 100644 --- a/src/builder-manifest.c +++ b/src/builder-manifest.c @@ -3056,9 +3056,16 @@ builder_manifest_cleanup (BuilderManifest *self, g_autofree char *arg_media_dir = g_strdup_printf ("--media-dir=%s", flatpak_file_get_path_cached (media_dir)); + gboolean has_no_partial_urls = appstream_version_check (0, 16, 3); + if (!has_no_partial_urls) + { + g_warning ("Found AppStream version < 0.16.3. Failed to add '--no-partial-urls' to compose"); + } + g_print ("Running appstreamcli compose\n"); g_print ("Saving screenshots in %s\n", flatpak_file_get_path_cached (media_dir)); if (!appstreamcli_compose (error, + has_no_partial_urls ? "--no-partial-urls" : NULL, "--prefix=/", origin, arg_base_url, diff --git a/src/builder-utils.c b/src/builder-utils.c index 7c838170..d1283128 100644 --- a/src/builder-utils.c +++ b/src/builder-utils.c @@ -1836,3 +1836,50 @@ flatpak_version_check (int major, return FALSE; } + +gboolean +appstream_version_check (int major, + int minor, + int micro) +{ + static int as_major = 0; + static int as_minor = 0; + static int as_micro = 0; + + if (as_major == 0 && + as_minor == 0 && + as_micro == 0) + { + const char * argv[] = { "appstreamcli", "--version", NULL }; + g_autoptr(GSubprocess) subp = NULL; + g_autofree char *out = NULL; + + subp = g_subprocess_newv (argv, G_SUBPROCESS_FLAGS_STDOUT_PIPE, NULL); + g_subprocess_communicate_utf8 (subp, NULL, NULL, &out, NULL, NULL); + + gchar **lines = g_strsplit (out, "\n", -1); + for (int i = 0; lines[i] != NULL; i++) + { + /* Only prefer library version over cli version in case of mismatch */ + if (g_str_has_prefix (lines[i], "AppStream library version:")) + { + if (sscanf (lines[i], "AppStream library version: %d.%d.%d", &as_major, &as_minor, &as_micro) == 3) + break; + } + else if (g_str_has_prefix (lines[i], "AppStream version:")) + { + if (sscanf (lines[i], "AppStream version: %d.%d.%d", &as_major, &as_minor, &as_micro) == 3) + break; + } + } + g_strfreev (lines); + + if (as_major == 0 && as_minor == 0 && as_micro == 0) + g_warning ("Failed to find appstream version"); + g_debug ("Found AppStream version %d.%d.%d", as_major, as_minor, as_micro); + } + + return (as_major > major) || + (as_major == major && as_minor > minor) || + (as_major == major && as_minor == minor && as_micro >= micro); +} diff --git a/src/builder-utils.h b/src/builder-utils.h index 05dfd839..6e2ebe52 100644 --- a/src/builder-utils.h +++ b/src/builder-utils.h @@ -216,6 +216,10 @@ gboolean flatpak_version_check (int major, int minor, int micro); +gboolean appstream_version_check (int major, + int minor, + int micro); + G_DEFINE_AUTOPTR_CLEANUP_FUNC (FlatpakXml, flatpak_xml_free); G_END_DECLS