Skip to content

Commit f9cc8fb

Browse files
committed
builder-manifest: Add some optional 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 c05ad5c commit f9cc8fb

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

doc/flatpak-builder.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,21 @@
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.
602+
</para></listitem>
603+
</varlistentry>
604+
590605
<varlistentry>
591606
<term><option>--add-tag=TAG</option></term>
592607

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: 14 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,12 @@ builder_appstreamcli_compose (const gchar *origin,
24492451

24502452
asc_compose_add_flags (compose, ASC_COMPOSE_FLAG_PROPAGATE_CUSTOM);
24512453

2454+
if (!enable_screencasts)
2455+
asc_compose_remove_flags (compose, ASC_COMPOSE_FLAG_ALLOW_SCREENCASTS);
2456+
2457+
if (!enable_partial_urls)
2458+
asc_compose_add_flags (compose, ASC_COMPOSE_FLAG_NO_PARTIAL_URLS);
2459+
24522460
g_autoptr(GPtrArray) results = asc_compose_run (compose, NULL, error);
24532461
if (results == NULL)
24542462
{
@@ -3080,6 +3088,8 @@ builder_manifest_cleanup (BuilderManifest *self,
30803088
const char *hint_dir = flatpak_file_get_path_cached(hint_out);
30813089
const char *opt_mirror_screenshots_url = builder_context_get_opt_mirror_screenshots_url (context);
30823090
gboolean opt_export_only = builder_context_get_opt_export_only (context);
3091+
gboolean opt_enable_screencasts = builder_context_get_opt_compose_enable_screencasts(context);
3092+
gboolean opt_enable_partial_urls = builder_context_get_opt_compose_enable_partial_urls(context);
30833093

30843094
g_print ("Running appstreamcli compose\n");
30853095
if (opt_mirror_screenshots_url && !opt_export_only)
@@ -3095,6 +3105,8 @@ builder_manifest_cleanup (BuilderManifest *self,
30953105
media_dir,
30963106
hint_dir,
30973107
url,
3108+
opt_enable_screencasts,
3109+
opt_enable_partial_urls,
30983110
error))
30993111
return FALSE;
31003112
}
@@ -3108,6 +3120,8 @@ builder_manifest_cleanup (BuilderManifest *self,
31083120
NULL,
31093121
hint_dir,
31103122
NULL,
3123+
FALSE,
3124+
opt_enable_partial_urls,
31113125
error))
31123126
return FALSE;
31133127
}

0 commit comments

Comments
 (0)