GNOME Bugzilla – Bug 784748
Compulsory for desktop field checks entire contents of XDG_CURRENT_DESKTOP, not each individual element
Last modified: 2017-08-17 18:07:19 UTC
See https://git.gnome.org/browse/gnome-software/tree/plugins/core/gs-appstream.c#n753 It checks that any of the compulsory_for_desktop values are exactly the same as XDG_CURRENT_DESKTOP. I think this should instead check that any of the elements of a compound XDG_CURRENT_DESKTOP is equal to the value (g_strsplit and g_strv_contains). The main motivation is that then we can follow upstream's recommendations and not have to duplicate them all downstream. For example, GNOME Calculator would remain compulsory in such an environment. Also the other way around, the distro could then make apps compulsory for "Ubuntu" and then they'd remain compulsory if the underlying session changes. For example a hypothetical Ubuntu software updater with appdata would be compulsory on Ubuntu (GNOME), Ubuntu with MATE, Ubuntu with KDE, ... That app would have <compulsory_for_desktop>Ubuntu</compulsory_for_desktop> in its appdata file. Since there's an explicit comment justifying the current behaviour, I thought I'd file a bug to talk about it. The current Ubuntu release (Artful, to be 17.10) doesn't do this currently but I'd like to retain the option to do so. Old releases do, but they weren't called GNOME anyway so this doesn't matter so much. Therefore this bug is currently not urgent. :)
So, the reason we do it this way is that "Ubuntu GNOME" wanted different compulsory apps to "Upstream GNOME". If that's no longer the case, I guess we can do what you suggest.
I guess you can say this - if the value in compulsory_for_desktop contains a ":" character, compare against the whole of XDG_CURRENT_DESKTOP, otherwise split and compare each element?
We talked about this a bit on IRC, and hughsie was OK with the patch to follow... The change for distributors is that you'll need to replace the compulsory for desktops values for an app if you want to make something non-compulsory contrary to its metainfo file, whereas before it wouldn't show up at all if it wasn't an exact match and you'd have to make a merge component to add your compound desktop. The motivator for me supplying this patch is that Ubuntu is now a compound desktop, and we want to inherit GNOME's compulsory applications without further work if possible - and this behaviour seems generally to be more intuitive to me.
The following fix has been pushed: 38c13b3 appstream: Consider each element of a compound XDG_CURRENT_DESKTOP separately
Created attachment 357826 [details] [review] appstream: Consider each element of a compound XDG_CURRENT_DESKTOP separately If a distro (or a user) has set XDG_CURRENT_DESKTOP=foo:bar, we will not currently consider apps marked with <compulsory_for_desktop>foo</> as compulsory for that desktop. The distro would have to create a merge file specifying their own set of compulsory applications - most likely replicating those specified upstream. It seems more generally useful to allow derived desktops to inherit compulsory applications from their parents to avoid this work. In the case where a distro wants to override the compulsory desktops for a component, they can supply a replace component to achieve this. Split XDG_CURRENT_DESKTOP and compare each element against the values given in the AppStream. If any of them match, the application is compulsory.