Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/dependencies.apt.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
appstream-compose
dbus
debugedit
desktop-file-utils
Expand All @@ -9,6 +8,7 @@ fuse3
gettext
git
git-lfs
libappstream-compose-dev
libarchive-tools
libcurl4-openssl-dev
libelf-dev
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
check-meson:
name: Ubuntu meson build
runs-on: ${{ matrix.os }}
container: ubuntu:26.04
strategy:
matrix:
os: ['ubuntu-24.04']
Expand All @@ -39,14 +40,14 @@ jobs:

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y findutils
sudo apt-get install -y \
apt-get update
apt-get install -y findutils
apt-get install -y \
${{ matrix.compiler }} \
$(xargs < .github/dependencies.apt.txt)

- name: Configure flatpak-builder
run: meson setup --wrap-mode nodownload ${CONFIG_OPTS} ${BUILDDIR} .
run: meson setup --wrap-mode nodownload ${CONFIG_OPTS} -Dwerror=true ${BUILDDIR} .

- name: Build flatpak-builder with Meson
run: meson compile -C ${BUILDDIR}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
release:
name: Build and publish release
runs-on: ubuntu-24.04
container: ubuntu:26.04
permissions:
contents: write
steps:
Expand All @@ -24,9 +25,9 @@ jobs:

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y findutils
sudo apt-get install -y \
apt-get update
apt-get install -y findutils
apt-get install -y \
gcc \
perl \
jq \
Expand Down
15 changes: 11 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ foreach arg : project_c_args
endif
endforeach

if cc.get_id() == 'clang'
clang_args = [
'-Wno-typedef-redefinition',
]
foreach arg : clang_args
if cc.has_argument(arg)
add_project_arguments(arg, language: 'c')
endif
endforeach
endif

# The debugedit program is a hard dependency
debugedit = find_program('debugedit', version: '>= 5.0')

# Require appstream with compose plugin installed
appstreamcli = find_program('appstreamcli', version: '>= 0.15.0')
appstreamcli_compose = run_command(appstreamcli, ['compose', '--help'], check: true)

fusermount = get_option('system_fusermount')
if fusermount == ''
fusermount_program = find_program(['fusermount3', 'fusermount'], required: true)
Expand Down
18 changes: 9 additions & 9 deletions src/builder-flatpak-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ flatpak_path_match_prefix (const char *pattern,
/* special case * at end */
if (c == 0)
{
char *tmp = strchr (string, '/');
const char *tmp = strchr (string, '/');
if (tmp != NULL)
return tmp;
return string + strlen (string);
Expand Down Expand Up @@ -1163,11 +1163,11 @@ flatpak_create_curl_session (const char *user_agent)
if (curl_session == NULL)
return NULL;

curl_easy_setopt (curl_session, CURLOPT_CONNECTTIMEOUT, 60);
curl_easy_setopt (curl_session, CURLOPT_FAILONERROR, 1);
curl_easy_setopt (curl_session, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt (curl_session, CURLOPT_MAXREDIRS, 50);
curl_easy_setopt (curl_session, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt (curl_session, CURLOPT_CONNECTTIMEOUT, 60L);
curl_easy_setopt (curl_session, CURLOPT_FAILONERROR, 1L);
curl_easy_setopt (curl_session, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt (curl_session, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt (curl_session, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt (curl_session, CURLOPT_LOW_SPEED_TIME, 60L);
curl_easy_setopt (curl_session, CURLOPT_LOW_SPEED_LIMIT, 10000L);
curl_easy_setopt (curl_session, CURLOPT_USERAGENT, user_agent);
Expand Down Expand Up @@ -1633,7 +1633,7 @@ get_xdg_user_dir_from_string (const char *filesystem,
const char **suffix,
const char **dir)
{
char *slash;
const char *slash;
const char *rest;
g_autofree char *prefix = NULL;
gsize len;
Expand Down Expand Up @@ -2087,7 +2087,7 @@ option_add_generic_policy_cb (const gchar *option_name,
GError **error)
{
FlatpakContext *context = data;
char *t;
const char *t;
g_autofree char *key = NULL;
const char *policy_value;

Expand All @@ -2114,7 +2114,7 @@ option_remove_generic_policy_cb (const gchar *option_name,
GError **error)
{
FlatpakContext *context = data;
char *t;
const char *t;
g_autofree char *key = NULL;
const char *policy_value;
g_autofree char *extended_value = NULL;
Expand Down
6 changes: 0 additions & 6 deletions src/builder-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,6 @@ main (int argc,
return 1;
}

if (policy == BUILDER_AS_URL_POLICY_FULL && !appstream_has_version (0, 16, 3))
{
g_printerr ("AppStream version >= 0.16.3 required for 'full' compose URL policy\n");
return 1;
}

builder_context_set_as_url_policy (build_context, policy);
}

Expand Down
147 changes: 92 additions & 55 deletions src/builder-manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
#include <sys/statfs.h>
#include <glib/gi18n.h>

#define I_KNOW_THE_APPSTREAM_COMPOSE_API_IS_SUBJECT_TO_CHANGE

#include <appstream.h>
#include <appstream-compose.h>

#include "builder-manifest.h"
#include "builder-utils.h"
#include "builder-flatpak-utils.h"
Expand Down Expand Up @@ -2422,30 +2427,71 @@ cmpstringp (const void *p1, const void *p2)
}

static gboolean
appstreamcli_compose (GError **error,
BuilderAsUrlPolicy as_url_policy,
...)
builder_appstreamcli_compose (const gchar *origin,
const gchar *app_id,
const gchar *result_root,
const gchar *data_dir,
const gchar *icon_dir,
const gchar *media_dir,
const gchar *media_baseurl,
BuilderAsUrlPolicy as_url_policy,
GError **error)
{
g_autoptr(GPtrArray) args = NULL;
const gchar *arg;
va_list ap;
g_autoptr(AscCompose) compose = NULL;
g_autoptr(AscDirectoryUnit) dirunit = NULL;
g_autofree gchar *desktop_component = NULL;

args = g_ptr_array_new_with_free_func (g_free);
g_ptr_array_add (args, g_strdup ("appstreamcli"));
g_ptr_array_add (args, g_strdup ("compose"));
g_return_val_if_fail (origin != NULL, FALSE);
g_return_val_if_fail (app_id != NULL, FALSE);
g_return_val_if_fail (result_root != NULL, FALSE);
g_return_val_if_fail (data_dir != NULL, FALSE);
g_return_val_if_fail (icon_dir != NULL, FALSE);

compose = asc_compose_new ();

asc_compose_set_format (compose, AS_FORMAT_KIND_XML);
asc_compose_set_origin (compose, origin);
asc_compose_set_prefix (compose, "/");

asc_compose_add_allowed_cid (compose, app_id);
desktop_component = g_strdup_printf ("%s.desktop", app_id);
asc_compose_add_allowed_cid (compose, desktop_component);

dirunit = asc_directory_unit_new (result_root);
asc_compose_add_unit (compose, ASC_UNIT (dirunit));

asc_compose_set_data_result_dir (compose, data_dir);
asc_compose_set_icons_result_dir (compose, icon_dir);
asc_compose_set_media_baseurl (compose, media_baseurl);
asc_compose_set_media_result_dir (compose, media_dir);

#if AS_CHECK_VERSION(0, 16, 3)
if (as_url_policy == BUILDER_AS_URL_POLICY_FULL)
asc_compose_add_flags (compose, ASC_COMPOSE_FLAG_NO_PARTIAL_URLS);
#else
if (as_url_policy == BUILDER_AS_URL_POLICY_FULL)
g_ptr_array_add (args, g_strdup ("--no-partial-urls"));
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"AppStream >= 0.16.3 required for 'full' compose URL policy "
"(Found: %s)", as_version_string ());
return FALSE;
}
#endif

va_start (ap, as_url_policy);
while ((arg = va_arg (ap, const gchar *)))
g_ptr_array_add (args, g_strdup (arg));
g_ptr_array_add (args, NULL);
va_end (ap);
asc_compose_remove_flags (compose, ASC_COMPOSE_FLAG_ALLOW_SCREENCASTS);
asc_compose_add_flags (compose, ASC_COMPOSE_FLAG_PROPAGATE_CUSTOM);

if (!flatpak_spawnv (NULL, NULL, 0, error, (const char * const *)args->pdata, NULL))
g_autoptr(GPtrArray) results = asc_compose_run (compose, NULL, error);
if (results == NULL)
{
g_prefix_error (error, "ERROR: appstreamcli compose failed: ");
g_prefix_error (error, "AppStream compose failed: ");
return FALSE;
}

if (asc_compose_has_errors (compose))
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"AppStream compose completed with errors");
return FALSE;
}

Expand Down Expand Up @@ -3071,59 +3117,50 @@ builder_manifest_cleanup (BuilderManifest *self,

if (self->appstream_compose && appdata_file != NULL)
{
g_autofree char *origin = g_strdup_printf ("--origin=%s",
builder_manifest_get_id (self));
g_autofree char *components_arg = g_strdup_printf ("--components=%s,%s.desktop",
self->id, self->id);
const char *app_root_path = flatpak_file_get_path_cached (app_root);
g_autofree char *result_root_arg = g_strdup_printf ("--result-root=%s", app_root_path);
g_autoptr(GFile) xml_dir = flatpak_build_file (app_root, "share/app-info/xmls", NULL);

g_autoptr(GFile) data_out = flatpak_build_file (app_root, "share/app-info/xmls", NULL);
g_autoptr(GFile) icon_out = flatpak_build_file (app_root, "share/app-info/icons/flatpak", NULL);
g_autoptr(GFile) media_dir = flatpak_build_file (app_root, "share/app-info/media", NULL);
g_autofree char *data_dir = g_strdup_printf ("--data-dir=%s",
flatpak_file_get_path_cached (xml_dir));
g_autofree char *icon_dir = g_strdup_printf ("--icons-dir=%s",
flatpak_file_get_path_cached (icon_out));
g_autoptr(GFile) media_out = flatpak_build_file (app_root, "share/app-info/media", NULL);

const char *data_dir = flatpak_file_get_path_cached (data_out);
const char *icon_dir = flatpak_file_get_path_cached (icon_out);
const char *media_dir = flatpak_file_get_path_cached (media_out);
const char *opt_mirror_screenshots_url = builder_context_get_opt_mirror_screenshots_url (context);

gboolean opt_export_only = builder_context_get_opt_export_only (context);

BuilderAsUrlPolicy as_url_policy = builder_context_get_as_url_policy (context);

if (opt_mirror_screenshots_url && !opt_export_only)
{
g_autofree char *url = g_build_filename (opt_mirror_screenshots_url, NULL);
g_autofree char *arg_base_url = g_strdup_printf ("--media-baseurl=%s", url);
g_autofree char *arg_media_dir = g_strdup_printf ("--media-dir=%s",
flatpak_file_get_path_cached (media_dir));

g_print ("Running appstreamcli compose\n");
g_print ("Saving screenshots in %s\n", flatpak_file_get_path_cached (media_dir));
if (!appstreamcli_compose (error,
as_url_policy,
"--prefix=/",
origin,
arg_base_url,
arg_media_dir,
result_root_arg,
data_dir,
icon_dir,
components_arg,
app_root_path,
NULL))
return FALSE;
g_print ("Saving screenshots in %s\n", media_dir);
if (!builder_appstreamcli_compose (builder_manifest_get_id (self),
self->id,
app_root_path,
data_dir,
icon_dir,
media_dir,
url,
as_url_policy,
error))
return FALSE;
}
else
{
g_print ("Running appstreamcli compose\n");
if (!appstreamcli_compose (error,
as_url_policy,
"--prefix=/",
origin,
result_root_arg,
data_dir,
icon_dir,
components_arg,
app_root_path,
NULL))
if (!builder_appstreamcli_compose (builder_manifest_get_id (self),
self->id,
app_root_path,
data_dir,
icon_dir,
NULL,
NULL,
as_url_policy,
error))
return FALSE;
}
}
Expand Down
Loading