Debian Codegraph @

debian/patches/0017-calibre-Please-announce-supported-hardware-using-App.patch

raw
1 From: Petter Reinholdtsen <[email protected]>
2 Date: Sun, 14 Jul 2024 10:29:33 +0200
3 Subject: calibre: Please announce supported hardware using AppStream (Closes:
4 #838069)
5
6 Package: calibre
7 Version: 2.60.0+dfsg-1
8 Severity: wishlist
9 User: [email protected]
10 Usertags: appstream-modalias
11
12 Hi.
13
14 The calibre package is one of the packages in the Debian archive that
15 should be proposed for installation when a given hardware dongle is
16 inserted or available. Thanks to the appstream system, this can now be
17 announced in a way other tools can use and act on. I've written the
18 isenkram system to ask the current user if hardware specific packages
19 should be installed when a new dongle is installed or already present on
20 a machine, and isenkram now uses appstream as one source for hardware to
21 package mappings.
22
23 You can read more about this on my blog,
24 <URL: http://people.skolelinux.org/pere/blog/Using_appstream_with_isenkram_to_install_hardware_related_packages_in_Debian.html >.
25
26 Instructions on how to create the metadata XML file can be found in
27 <URL: https://wiki.debian.org/AppStream/Guidelines >.
28
29 It would be great if you could add an appstream metainfo file to the
30 calibre package, with content similar to this:
31
32 <?xml version="1.0" encoding="UTF-8"?>
33 <component>
34 [...]
35 <provides>
36 <modalias>usb:v2237p*d*ic08isc*ip*</modalias>
37 <modalias>usb:v0525pA4A5d*ic08isc*ip*</modalias>
38 </provides>
39 </component>
40
41 If there are other USB ids also supposed by the package, please add
42 those too. :)
43
44 ----------
45
46 I had a look at how to modify the source to fix this. Here is an
47 untested patch to implement support for provides in the generated
48 metadata XML file. Unfortunately I lacked the required free disk space
49 to do a test build. I did not add the provides to the editor metadata
50 entry, assuming that it is most relevant for the two other components.
51
52 Signed-off-by: YOKOTA Hiroshi <[email protected]>
53 ---
54 src/calibre/linux.py | 18 +++++++++++++++++-
55 1 file changed, 17 insertions(+), 1 deletion(-)
56
57 diff --git a/src/calibre/linux.py b/src/calibre/linux.py
58 index 3f7f4b2..1a82327 100644
59 --- a/src/calibre/linux.py
60 +++ b/src/calibre/linux.py
61 @@ -1224,6 +1224,10 @@ def get_appdata():
62 '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
63 ),
64 ),
65 + 'provides': [
66 + {'modalias': 'usb:v2237p*d*ic08isc*ip*'},
67 + {'modalias': 'usb:v0525pA4A5d*ic08isc*ip*'},
68 + ],
69 'screenshots': (
70 (
71 1408,
72 @@ -1281,6 +1285,10 @@ def get_appdata():
73 _('The calibre E-book viewer allows you to read e-books in over a dozen different formats.'),
74 _('It has a full screen mode for distraction free reading and can display the text with multiple columns per screen.'),
75 ),
76 + 'provides': [
77 + {'modalias': 'usb:v2237p*d*ic08isc*ip*'},
78 + {'modalias': 'usb:v0525pA4A5d*ic08isc*ip*'},
79 + ],
80 'screenshots': (
81 (
82 1408,
83 @@ -1351,7 +1359,7 @@ def make_appdata_releases():
84
85 def write_appdata(key, entry, base, translators):
86 from lxml.builder import E
87 - from lxml.etree import tostring
88 + from lxml.etree import Element, tostring
89
90 fpath = os.path.join(base, f'{key}.metainfo.xml')
91 screenshots = E.screenshots()
92 @@ -1392,6 +1400,14 @@ def write_appdata(key, entry, base, translators):
93 tp = t.gettext(entry['summary'])
94 if tp != entry['summary']:
95 root.append(E.summary(tp, **{'{http://www.w3.org/XML/1998/namespace}lang': lang}))
96 + if 0 < len(entry.get('provides', [])):
97 + provides = E.provides()
98 + for p in entry['provides']:
99 + for tag in p.keys():
100 + provided = Element(tag)
101 + provided.text = p[tag]
102 + provides.append(provided)
103 + root.append(provides)
104 if entry.get('include-releases', False):
105 try:
106 root.append(make_appdata_releases())