Skip to content

builder-manifest: Run appstream-compose with no-partial-urls argument #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/builder-manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions src/builder-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 4 additions & 0 deletions src/builder-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down