Skip to content

Commit 1ae14fa

Browse files
committed
Export to share/metainfo not share/appdata
The old path will not be supported by the upcoming AppStream 1.0 release, and the new path is well supported. Fixes #252
1 parent b2363cb commit 1ae14fa

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

Diff for: src/builder-manifest.c

+30-25
Original file line numberDiff line numberDiff line change
@@ -2405,19 +2405,20 @@ rewrite_appdata (GFile *file,
24052405
}
24062406

24072407
static GFile *
2408-
builder_manifest_find_appdata_file (BuilderManifest *self,
2409-
GFile *app_root)
2408+
builder_manifest_find_metainfo_file (BuilderManifest *self,
2409+
GFile *app_root)
24102410
{
2411-
/* We order these so that share/appdata/XXX.appdata.xml if found
2412-
first, as this is the target name, and apps may have both, which will
2413-
cause issues with the rename. */
2411+
/* We order these so that share/metainfo/XXX.metainfo.xml is found
2412+
* first, as this is the target name, and apps may have both, which will
2413+
* cause issues with the rename.
2414+
*/
24142415
const char *extensions[] = {
2415-
".appdata.xml",
24162416
".metainfo.xml",
2417+
".appdata.xml",
24172418
};
24182419
const char *dirs[] = {
2419-
"share/appdata",
24202420
"share/metainfo",
2421+
"share/appdata",
24212422
};
24222423
g_autoptr(GFile) source = NULL;
24232424

@@ -2451,8 +2452,8 @@ builder_manifest_cleanup (BuilderManifest *self,
24512452
g_autoptr(GFile) app_root = NULL;
24522453
GList *l;
24532454
g_auto(GStrv) env = NULL;
2454-
g_autoptr(GFile) appdata_file = NULL;
2455-
g_autoptr(GFile) appdata_source = NULL;
2455+
g_autoptr(GFile) metainfo_file = NULL;
2456+
g_autoptr(GFile) metainfo_source = NULL;
24562457
int i;
24572458

24582459
builder_manifest_checksum_for_cleanup (self, cache, context);
@@ -2513,29 +2514,33 @@ builder_manifest_cleanup (BuilderManifest *self,
25132514

25142515
app_root = g_file_get_child (app_dir, "files");
25152516

2516-
appdata_source = builder_manifest_find_appdata_file (self, app_root);
2517-
if (appdata_source)
2517+
metainfo_source = builder_manifest_find_metainfo_file (self, app_root);
2518+
if (metainfo_source)
25182519
{
2519-
/* We always use the old name / dir, in case the runtime has older appdata tools */
2520-
g_autoptr(GFile) appdata_dir = g_file_resolve_relative_path (app_root, "share/appdata");
2521-
g_autofree char *appdata_basename = g_strdup_printf ("%s.appdata.xml", self->id);
2520+
/* Export to share/metainfo which usurped share/appdata as the
2521+
* correct directory in 2016 and is well-supported even on old
2522+
* distributions. However since we used to export to share/appdata
2523+
* Flatpak still looks there when exporting metainfo.
2524+
*/
2525+
g_autoptr(GFile) metainfo_dir = g_file_resolve_relative_path (app_root, "share/metainfo");
2526+
g_autofree char *metainfo_basename = g_strdup_printf ("%s.metainfo.xml", self->id);
25222527

2523-
appdata_file = g_file_get_child (appdata_dir, appdata_basename);
2528+
metainfo_file = g_file_get_child (metainfo_dir, metainfo_basename);
25242529

2525-
if (!g_file_equal (appdata_source, appdata_file))
2530+
if (!g_file_equal (metainfo_source, metainfo_file))
25262531
{
2527-
g_autofree char *src_basename = g_file_get_basename (appdata_source);
2528-
g_print ("Renaming %s to share/appdata/%s\n", src_basename, appdata_basename);
2532+
g_autofree char *src_basename = g_file_get_basename (metainfo_source);
2533+
g_print ("Renaming %s to share/metainfo/%s\n", src_basename, metainfo_basename);
25292534

2530-
if (!flatpak_mkdir_p (appdata_dir, NULL, error))
2535+
if (!flatpak_mkdir_p (metainfo_dir, NULL, error))
25312536
return FALSE;
2532-
if (!g_file_move (appdata_source, appdata_file, 0, NULL, NULL, NULL, error))
2537+
if (!g_file_move (metainfo_source, metainfo_file, 0, NULL, NULL, NULL, error))
25332538
return FALSE;
25342539
}
25352540

25362541
if (self->appdata_license != NULL && self->appdata_license[0] != 0)
25372542
{
2538-
if (!rewrite_appdata (appdata_file, self->appdata_license, error))
2543+
if (!rewrite_appdata (metainfo_file, self->appdata_license, error))
25392544
return FALSE;
25402545
}
25412546
}
@@ -2551,7 +2556,7 @@ builder_manifest_cleanup (BuilderManifest *self,
25512556
if (!g_file_move (src, dest, 0, NULL, NULL, NULL, error))
25522557
return FALSE;
25532558

2554-
if (appdata_file != NULL)
2559+
if (metainfo_file != NULL)
25552560
{
25562561
FlatpakXml *n_id;
25572562
FlatpakXml *n_root;
@@ -2560,7 +2565,7 @@ builder_manifest_cleanup (BuilderManifest *self,
25602565
g_autoptr(GInputStream) in = NULL;
25612566
g_autoptr(GString) new_contents = NULL;
25622567

2563-
in = (GInputStream *) g_file_read (appdata_file, NULL, error);
2568+
in = (GInputStream *) g_file_read (metainfo_file, NULL, error);
25642569
if (!in)
25652570
return FALSE;
25662571
xml_root = flatpak_xml_parse (in, FALSE, NULL, error);
@@ -2601,7 +2606,7 @@ builder_manifest_cleanup (BuilderManifest *self,
26012606

26022607
new_contents = g_string_new ("");
26032608
flatpak_xml_to_string (xml_root, new_contents);
2604-
if (!g_file_set_contents (flatpak_file_get_path_cached (appdata_file),
2609+
if (!g_file_set_contents (flatpak_file_get_path_cached (metainfo_file),
26052610
new_contents->str,
26062611
new_contents->len,
26072612
error))
@@ -2749,7 +2754,7 @@ builder_manifest_cleanup (BuilderManifest *self,
27492754
return FALSE;
27502755
}
27512756

2752-
if (self->appstream_compose && appdata_file != NULL)
2757+
if (self->appstream_compose && metainfo_file != NULL)
27532758
{
27542759
g_autofree char *basename_arg = g_strdup_printf ("--basename=%s", self->id);
27552760
g_print ("Running appstream-compose\n");

0 commit comments

Comments
 (0)