@@ -2405,19 +2405,20 @@ rewrite_appdata (GFile *file,
2405
2405
}
2406
2406
2407
2407
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 )
2410
2410
{
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
+ */
2414
2415
const char * extensions [] = {
2415
- ".appdata.xml" ,
2416
2416
".metainfo.xml" ,
2417
+ ".appdata.xml" ,
2417
2418
};
2418
2419
const char * dirs [] = {
2419
- "share/appdata" ,
2420
2420
"share/metainfo" ,
2421
+ "share/appdata" ,
2421
2422
};
2422
2423
g_autoptr (GFile ) source = NULL ;
2423
2424
@@ -2451,8 +2452,8 @@ builder_manifest_cleanup (BuilderManifest *self,
2451
2452
g_autoptr (GFile ) app_root = NULL ;
2452
2453
GList * l ;
2453
2454
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 ;
2456
2457
int i ;
2457
2458
2458
2459
builder_manifest_checksum_for_cleanup (self , cache , context );
@@ -2513,29 +2514,33 @@ builder_manifest_cleanup (BuilderManifest *self,
2513
2514
2514
2515
app_root = g_file_get_child (app_dir , "files" );
2515
2516
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 )
2518
2519
{
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 );
2522
2527
2523
- appdata_file = g_file_get_child (appdata_dir , appdata_basename );
2528
+ metainfo_file = g_file_get_child (metainfo_dir , metainfo_basename );
2524
2529
2525
- if (!g_file_equal (appdata_source , appdata_file ))
2530
+ if (!g_file_equal (metainfo_source , metainfo_file ))
2526
2531
{
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 );
2529
2534
2530
- if (!flatpak_mkdir_p (appdata_dir , NULL , error ))
2535
+ if (!flatpak_mkdir_p (metainfo_dir , NULL , error ))
2531
2536
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 ))
2533
2538
return FALSE;
2534
2539
}
2535
2540
2536
2541
if (self -> appdata_license != NULL && self -> appdata_license [0 ] != 0 )
2537
2542
{
2538
- if (!rewrite_appdata (appdata_file , self -> appdata_license , error ))
2543
+ if (!rewrite_appdata (metainfo_file , self -> appdata_license , error ))
2539
2544
return FALSE;
2540
2545
}
2541
2546
}
@@ -2551,7 +2556,7 @@ builder_manifest_cleanup (BuilderManifest *self,
2551
2556
if (!g_file_move (src , dest , 0 , NULL , NULL , NULL , error ))
2552
2557
return FALSE;
2553
2558
2554
- if (appdata_file != NULL )
2559
+ if (metainfo_file != NULL )
2555
2560
{
2556
2561
FlatpakXml * n_id ;
2557
2562
FlatpakXml * n_root ;
@@ -2560,7 +2565,7 @@ builder_manifest_cleanup (BuilderManifest *self,
2560
2565
g_autoptr (GInputStream ) in = NULL ;
2561
2566
g_autoptr (GString ) new_contents = NULL ;
2562
2567
2563
- in = (GInputStream * ) g_file_read (appdata_file , NULL , error );
2568
+ in = (GInputStream * ) g_file_read (metainfo_file , NULL , error );
2564
2569
if (!in )
2565
2570
return FALSE;
2566
2571
xml_root = flatpak_xml_parse (in , FALSE, NULL , error );
@@ -2601,7 +2606,7 @@ builder_manifest_cleanup (BuilderManifest *self,
2601
2606
2602
2607
new_contents = g_string_new ("" );
2603
2608
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 ),
2605
2610
new_contents -> str ,
2606
2611
new_contents -> len ,
2607
2612
error ))
@@ -2749,7 +2754,7 @@ builder_manifest_cleanup (BuilderManifest *self,
2749
2754
return FALSE;
2750
2755
}
2751
2756
2752
- if (self -> appstream_compose && appdata_file != NULL )
2757
+ if (self -> appstream_compose && metainfo_file != NULL )
2753
2758
{
2754
2759
g_autofree char * basename_arg = g_strdup_printf ("--basename=%s" , self -> id );
2755
2760
g_print ("Running appstream-compose\n" );
0 commit comments