hughsie / appstream-glib

This library provides objects and helper methods to help reading and writing AppStream metadata.
GNU Lesser General Public License v2.1
65 stars 103 forks source link

<recommends> tag support #471

Open sidt4 opened 1 year ago

sidt4 commented 1 year ago

<recommends> tag is currently not supported / implemented in appstream-util

$ appstream-util validate-strict --nonet /usr/share/metainfo/org.gnome.Nautilus.appdata.xml 
/usr/share/metainfo/org.gnome.Nautilus.appdata.xml: FAILED:
• value-missing         : <!-- Copyright [year] [name] --> is not present
• tag-invalid           : XML data contains unknown tag
• tag-missing           : <content_rating> required [use https://odrs.gnome.org/oars]
• style-invalid         : <caption> is too short [Grid View];shortest allowed is 10 chars
• style-invalid         : <caption> is too short [List View];shortest allowed is 10 chars
• style-invalid         : <caption> is too short [Search];shortest allowed is 10 chars
Validation of files failed

The invalid tag name is missing in above log. With https://github.com/hughsie/appstream-glib/pull/470, the invalid tag name is now displayed.

$ appstream-util validate-strict --nonet /usr/share/metainfo/org.gnome.Nautilus.appdata.xml 
/usr/share/metainfo/org.gnome.Nautilus.appdata.xml: FAILED:

(appstream-util:292180): As-WARNING **: 14:24:14.636: Unknown tag: <recommends>
• value-missing         : <!-- Copyright [year] [name] --> is not present
• tag-invalid           : XML data contains unknown tag
• tag-missing           : <content_rating> required [use https://odrs.gnome.org/oars]
• style-invalid         : <caption> is too short [Grid View];shortest allowed is 10 chars
• style-invalid         : <caption> is too short [List View];shortest allowed is 10 chars
• style-invalid         : <caption> is too short [Search];shortest allowed is 10 chars
Validation of files failed

It appears that <recommends> tag is used by lot of apps, as below:

$ grep "<recommends>" -Ri /usr/share/metainfo/
/usr/share/metainfo/org.gnome.Maps.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Nautilus.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.seahorse.Application.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Software.metainfo.xml:  <recommends>
/usr/share/metainfo/org.gnome.DiskUtility.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Console.metainfo.xml:  <recommends>
/usr/share/metainfo/org.gnome.Terminal.metainfo.xml:  <recommends>
/usr/share/metainfo/org.gnome.Contacts.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.DejaDup.metainfo.xml:  <recommends>
/usr/share/metainfo/org.gnome.Sudoku.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Polari.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Calculator.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Chess.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Hitori.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Characters.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Extensions.metainfo.xml:  <recommends>
/usr/share/metainfo/org.gnome.Epiphany.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.clocks.metainfo.xml:  <recommends>
/usr/share/metainfo/org.inkscape.Inkscape.appdata.xml:  <recommends>
/usr/share/metainfo/org.gnome.Geary.appdata.xml:  <recommends>
sidt4 commented 1 year ago

Just FYI.

  1. /usr/share/metainfo/org.gnome.DejaDup.metainfo.xml

    (appstream-util:295440): As-WARNING **: 14:32:40.574: Unknown tag: <branding>

  2. /usr/share/metainfo/org.inkscape.Inkscape.appdata.xml:

    (appstream-util:295789): As-WARNING **: 14:32:42.416: Unknown tag: <supports>

hughsie commented 1 year ago

I think using appstreamcli is probably a much better idea - it's much more up to date that the validator here.

sidt4 commented 1 year ago

Yes, it seems like appstreamcli is better. But, then why keep the validator ? It's confusing.

ximion commented 1 year ago

For a while there was still tools using appstream-glib - nowadays we could probably remove it from Linux distributions, but then again, if someone needs it to reproduce previous behavior or wants to compile older code it is available and nice to have. For newer things, just use appstreamcli :)

sidt4 commented 1 year ago

Can we at least print a warning when using appstream-glib saying "appstreamcli should be used etc." ?

Point here is that, it sounds good for those who are aware of appstream-glib and appstreamcli. But based on the information available in web ( some articles point to appstream-glib and some appstreamcli ), new users could still start their appstream journey with appstream-glib, thinking they are using the new tools.

I have wasted few clocks on this. Don't want others to go through the same.

hughsie commented 1 year ago

Can we at least print a warning when using appstream-glib saying "appstreamcli should be used etc." ?

I'm worried about that breaking automated scripts --- but maybe that's something we should do anyway :)

The alternative is to just run appstreamcli if the user types in appstream-util validate. @ximion any concerns about this?

ximion commented 1 year ago

The alternative is to just run appstreamcli if the user types in appstream-util validate. @ximion any concerns about this?

The two tools are not quite 100% compatible - wouldn't that break scripts even more? It would also make appstream-glib and appstreamcli not coinstallable (although that's probably not an issue at this point).