From: Petter Reinholdtsen Date: Sun, 14 Jul 2024 10:29:33 +0200 Subject: calibre: Please announce supported hardware using AppStream (Closes: #838069) Package: calibre Version: 2.60.0+dfsg-1 Severity: wishlist User: pere@hungry.com Usertags: appstream-modalias Hi. The calibre package is one of the packages in the Debian archive that should be proposed for installation when a given hardware dongle is inserted or available. Thanks to the appstream system, this can now be announced in a way other tools can use and act on. I've written the isenkram system to ask the current user if hardware specific packages should be installed when a new dongle is installed or already present on a machine, and isenkram now uses appstream as one source for hardware to package mappings. You can read more about this on my blog, . Instructions on how to create the metadata XML file can be found in . It would be great if you could add an appstream metainfo file to the calibre package, with content similar to this: [...] usb:v2237p*d*ic08isc*ip* usb:v0525pA4A5d*ic08isc*ip* If there are other USB ids also supposed by the package, please add those too. :) ---------- I had a look at how to modify the source to fix this. Here is an untested patch to implement support for provides in the generated metadata XML file. Unfortunately I lacked the required free disk space to do a test build. I did not add the provides to the editor metadata entry, assuming that it is most relevant for the two other components. Signed-off-by: YOKOTA Hiroshi --- src/calibre/linux.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calibre/linux.py b/src/calibre/linux.py index 3f7f4b2..1a82327 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -1224,6 +1224,10 @@ def get_appdata(): 'You can use calibre to catalog your books, fetch metadata for them automatically, convert them from and to all the various e-book formats, send them to your e-book reader devices, read the books on your computer, edit the books in a dedicated e-book editor and even make them available over the network with the built-in Content server. You can also download news and periodicals in e-book format from over a thousand different news and magazine websites.' # noqa: E501 ), ), + 'provides': [ + {'modalias': 'usb:v2237p*d*ic08isc*ip*'}, + {'modalias': 'usb:v0525pA4A5d*ic08isc*ip*'}, + ], 'screenshots': ( ( 1408, @@ -1281,6 +1285,10 @@ def get_appdata(): _('The calibre E-book viewer allows you to read e-books in over a dozen different formats.'), _('It has a full screen mode for distraction free reading and can display the text with multiple columns per screen.'), ), + 'provides': [ + {'modalias': 'usb:v2237p*d*ic08isc*ip*'}, + {'modalias': 'usb:v0525pA4A5d*ic08isc*ip*'}, + ], 'screenshots': ( ( 1408, @@ -1351,7 +1359,7 @@ def make_appdata_releases(): def write_appdata(key, entry, base, translators): from lxml.builder import E - from lxml.etree import tostring + from lxml.etree import Element, tostring fpath = os.path.join(base, f'{key}.metainfo.xml') screenshots = E.screenshots() @@ -1392,6 +1400,14 @@ def write_appdata(key, entry, base, translators): tp = t.gettext(entry['summary']) if tp != entry['summary']: root.append(E.summary(tp, **{'{http://www.w3.org/XML/1998/namespace}lang': lang})) + if 0 < len(entry.get('provides', [])): + provides = E.provides() + for p in entry['provides']: + for tag in p.keys(): + provided = Element(tag) + provided.text = p[tag] + provides.append(provided) + root.append(provides) if entry.get('include-releases', False): try: root.append(make_appdata_releases())