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

Please document news-to-appdata script #437

Open fedelibre opened 2 years ago

fedelibre commented 2 years ago

I'm trying to use the appstream-util news-to-appdata script present in the 21.08 Freedesktop SDK flatpak package, but I can't find any information about the syntax to be used. I'm using it within an application flatpak manifest, because upstream devs could not add the script in their build system.

[📦 org.freedesktop.Platform ~]$ appstream-util --version
Version:    0.7.18

I tried this (taken from appstreamcli) but it didn't work:

appstream-util news-to-appdata NEWS ${FLATPAK_DEST}/id.appdata.xml ${FLATPAK_DEST}/id.appdata.xml

Here's the short error message:

Not enough arguments, expected NEWS
ximion commented 2 years ago

Hi! appstream-util does not do an equivalent thing to appstreamcli here. What you need to do is run appstream-util news-to-appdata ./NEWS (no other parameters) and then the tool will print release description markup (and just that) to stdout.

fedelibre commented 2 years ago

Ok, I see. Unfortunately it parses the NEWS file differently from appstreamcli, as it assumes that each item in a list is on a single line. In other words, every line within a section becomes a <li>element</li>.

I'm working on a too long and verbose NEWS file. It's time to simplify it.

fedelibre commented 2 years ago

Can you help me with the sed script to copy the output of appstream-util in the right place of the appdata file? (i.e. before the last line </application> or after the previous line <content_rating)

I don't know how to use appstream-util stdout within the sed command. Here's what I tried:

appstream-util news-to-appdata NEWS | xargs sed -i '/^<content_rating/a STDOUT' /app/share/appdata/org.denemo.Denemo.appdata.xml

where STDOUT should be replaced by appstream-util stdout.

Or do you know better ways?

ximion commented 2 years ago

before the last line </application>

If you have any <application> tag in your metainfo file, you should seriously think about upgrading that file to a newer version of the AppStream spec - that stuff has been deprecated for about 8 years now ;-)

Honest question: Is there a reason why you can't use appstreamcli, which makes you not require all sed magic?

fedelibre commented 2 years ago

Honest question: Is there a reason why you can't use appstreamcli, which makes you not require all sed magic?

The only reason is that appstreamcli is not available in Freedesktop SDK 21.08, so I have to build appstream and all its dependencies within my application manifest. Probably I'd better fo this. And maybe ask Freedesktop to include appstreamcli.

fedelibre commented 2 years ago

Wait, I've just realized there's a freedesktop appstream.cli extension!

ximion commented 2 years ago

Jup, but including it in the SDK directly is also probably a good idea (but I'll leave that call to the Flatpak people, I don't have enough experience with building runtimes yet to say that this is a good idea for sure ^^)

fedelibre commented 2 years ago

I suspect it is a good idea. How can I access appstreamcli otherwise? (when building a flatpak app) I've just opened a new issue and we can follow-up the discussion there.