Skip to content

Commit 6fcd407

Browse files
committed
builder-manifest: Set some optional appstream compose flags
Screencasts are generally unwanted in catalogue to as they are more expensive to download, store in ref and serve. Also no appstore currently supports showing them. Appstream by default produces partial media URLs in catalogue after mirroring but libappstream-glib did not and generally the full URL is required by Flathub at least.
1 parent 456d740 commit 6fcd407

File tree

7 files changed

+78
-1
lines changed

7 files changed

+78
-1
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ PKG_PROG_PKG_CONFIG([0.24])
8686
# For libglnx
8787
AC_CHECK_HEADER([sys/xattr.h], [], [AC_MSG_ERROR([You must have sys/xattr.h from glibc])])
8888

89-
PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0 ostree-1 >= $OSTREE_REQS json-glib-1.0 libxml-2.0 >= 2.4 libcurl appstream-compose >= $APPSTREAMCLI_REQS])
89+
PKG_CHECK_MODULES(BASE, [glib-2.0 >= $GLIB_REQS gio-2.0 gio-unix-2.0 ostree-1 >= $OSTREE_REQS json-glib-1.0 libxml-2.0 >= 2.4 libcurl appstream >= $APPSTREAMCLI_REQS appstream-compose >= $APPSTREAMCLI_REQS])
9090

9191
dnl ************************
9292
dnl *** check for libelf ***

doc/flatpak-builder.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,22 @@
587587
</para></listitem>
588588
</varlistentry>
589589

590+
<varlistentry>
591+
<term><option>--compose-enable-screencasts</option></term>
592+
593+
<listitem><para>
594+
Allow screencasts in Appstream catalogue.
595+
</para></listitem>
596+
</varlistentry>
597+
598+
<varlistentry>
599+
<term><option>--compose-enable-partial-urls</option></term>
600+
<listitem><para>
601+
Use partial URLs in Appstream catalogue. Requires
602+
appstream >= 0.16.3.
603+
</para></listitem>
604+
</varlistentry>
605+
590606
<varlistentry>
591607
<term><option>--add-tag=TAG</option></term>
592608

src/builder-context.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ struct BuilderContext
8686
gboolean no_shallow_clone;
8787
gboolean opt_export_only;
8888
char *opt_mirror_screenshots_url;
89+
gboolean opt_compose_enable_screencasts;
90+
gboolean opt_compose_enable_partial_urls;
8991

9092
BuilderSdkConfig *sdk_config;
9193
};
@@ -376,6 +378,32 @@ builder_context_get_opt_mirror_screenshots_url (BuilderContext *self)
376378
return self->opt_mirror_screenshots_url;
377379
}
378380

381+
void
382+
builder_context_set_opt_compose_enable_screencasts (BuilderContext *self,
383+
gboolean opt_compose_enable_screencasts)
384+
{
385+
self->opt_compose_enable_screencasts = !!opt_compose_enable_screencasts;
386+
}
387+
388+
gboolean
389+
builder_context_get_opt_compose_enable_screencasts (BuilderContext *self)
390+
{
391+
return self->opt_compose_enable_screencasts;
392+
}
393+
394+
void
395+
builder_context_set_opt_compose_enable_partial_urls (BuilderContext *self,
396+
gboolean opt_compose_enable_partial_urls)
397+
{
398+
self->opt_compose_enable_partial_urls = !!opt_compose_enable_partial_urls;
399+
}
400+
401+
gboolean
402+
builder_context_get_opt_compose_enable_partial_urls (BuilderContext *self)
403+
{
404+
return self->opt_compose_enable_partial_urls;
405+
}
406+
379407
GFile *
380408
builder_context_find_in_sources_dirs (BuilderContext *self,
381409
...)

src/builder-context.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ void builder_context_set_opt_mirror_screenshots_url (BuilderContext *
180180

181181
const char * builder_context_get_opt_mirror_screenshots_url (BuilderContext *self);
182182

183+
void builder_context_set_opt_compose_enable_screencasts (BuilderContext *self,
184+
gboolean opt_compose_enable_screencasts);
185+
186+
gboolean builder_context_get_opt_compose_enable_screencasts (BuilderContext *self);
187+
188+
void builder_context_set_opt_compose_enable_partial_urls (BuilderContext *self,
189+
gboolean opt_compose_enable_partial_urls);
190+
191+
gboolean builder_context_get_opt_compose_enable_partial_urls (BuilderContext *self);
192+
183193
BuilderSdkConfig * builder_context_get_sdk_config (BuilderContext *self);
184194

185195
gboolean builder_context_create_state_dir (BuilderContext *self,

src/builder-main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static gboolean opt_log_session_bus;
8989
static gboolean opt_log_system_bus;
9090
static gboolean opt_yes;
9191
static gint64 opt_source_date_epoch = -1;
92+
static gboolean opt_compose_enable_screencasts;
93+
static gboolean opt_compose_enable_partial_urls;
9294

9395
static GOptionEntry entries[] = {
9496
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL },
@@ -144,6 +146,8 @@ static GOptionEntry entries[] = {
144146
{ "assumeyes", 'y', 0, G_OPTION_ARG_NONE, &opt_yes, N_("Automatically answer yes for all questions"), NULL },
145147
{ "no-shallow-clone", 0, 0, G_OPTION_ARG_NONE, &opt_no_shallow_clone, "Don't use shallow clones when mirroring git repos", NULL },
146148
{ "override-source-date-epoch", 0, 0, G_OPTION_ARG_INT64, &opt_source_date_epoch, "Use this timestamp to perform the build, instead of the last modification time of the manifest.", NULL },
149+
{ "compose-enable-screencasts", 0, 0, G_OPTION_ARG_NONE, &opt_compose_enable_screencasts, "Allow screencasts in Appstream catalogue", NULL },
150+
{ "compose-enable-partial-urls", 0, 0, G_OPTION_ARG_NONE, &opt_compose_enable_partial_urls, "Allow partial URLs in Appstream catalogue", NULL },
147151
{ NULL }
148152
};
149153

@@ -605,6 +609,8 @@ main (int argc,
605609
builder_context_set_bundle_sources (build_context, opt_bundle_sources);
606610
builder_context_set_opt_export_only (build_context, opt_export_only);
607611
builder_context_set_opt_mirror_screenshots_url (build_context, opt_mirror_screenshots_url);
612+
builder_context_set_opt_compose_enable_screencasts (build_context, opt_compose_enable_screencasts);
613+
builder_context_set_opt_compose_enable_partial_urls (build_context, opt_compose_enable_partial_urls);
608614

609615
git_init_email ();
610616

src/builder-manifest.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,8 @@ builder_appstreamcli_compose (const gchar *origin,
24152415
const gchar *media_dir,
24162416
const gchar *hint_dir,
24172417
const gchar *media_baseurl,
2418+
gboolean enable_screencasts,
2419+
gboolean enable_partial_urls,
24182420
GError **error)
24192421
{
24202422
g_autoptr(AscCompose) compose = NULL;
@@ -2449,6 +2451,14 @@ builder_appstreamcli_compose (const gchar *origin,
24492451

24502452
asc_compose_add_flags (compose, ASC_COMPOSE_FLAG_PROPAGATE_CUSTOM);
24512453

2454+
#if AS_CHECK_VERSION(0, 16, 3)
2455+
if (!enable_partial_urls)
2456+
asc_compose_add_flags (compose, ASC_COMPOSE_FLAG_NO_PARTIAL_URLS);
2457+
#endif
2458+
2459+
if (!enable_screencasts)
2460+
asc_compose_remove_flags (compose, ASC_COMPOSE_FLAG_ALLOW_SCREENCASTS);
2461+
24522462
g_autoptr(GPtrArray) results = asc_compose_run (compose, NULL, error);
24532463
if (results == NULL)
24542464
{
@@ -3080,6 +3090,8 @@ builder_manifest_cleanup (BuilderManifest *self,
30803090
const char *hint_dir = flatpak_file_get_path_cached(hint_out);
30813091
const char *opt_mirror_screenshots_url = builder_context_get_opt_mirror_screenshots_url (context);
30823092
gboolean opt_export_only = builder_context_get_opt_export_only (context);
3093+
gboolean opt_enable_screencasts = builder_context_get_opt_compose_enable_screencasts(context);
3094+
gboolean opt_enable_partial_urls = builder_context_get_opt_compose_enable_partial_urls(context);
30833095

30843096
g_print ("Running appstreamcli compose\n");
30853097
if (opt_mirror_screenshots_url && !opt_export_only)
@@ -3095,6 +3107,8 @@ builder_manifest_cleanup (BuilderManifest *self,
30953107
media_dir,
30963108
hint_dir,
30973109
url,
3110+
opt_enable_screencasts,
3111+
opt_enable_partial_urls,
30983112
error))
30993113
return FALSE;
31003114
}
@@ -3108,6 +3122,8 @@ builder_manifest_cleanup (BuilderManifest *self,
31083122
NULL,
31093123
hint_dir,
31103124
NULL,
3125+
FALSE,
3126+
opt_enable_partial_urls,
31113127
error))
31123128
return FALSE;
31133129
}

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ flatpak_builder_deps = [
5757
dependency('libglnx', default_options: ['tests=false']),
5858
dependency('libxml-2.0', version: '>= 2.4'),
5959
dependency('ostree-1', version: '>= 2017.14'),
60+
dependency('appstream', version: '>=0.15.0'),
6061
dependency('appstream-compose', version: '>=0.15.0'),
6162
yaml_dep,
6263
]

0 commit comments

Comments
 (0)