]> pere.pagekite.me Git - homepage.git/blob - blog/data/2016-10-07-isenkram-appstream-lego.txt
Generated.
[homepage.git] / blog / data / 2016-10-07-isenkram-appstream-lego.txt
1 Title: Isenkram, Appstream and udev make life as a LEGO builder easier
2 Tags: english, debian, isenkram
3 Date: 2016-10-07 09:50
4
5 <p><a href="http://packages.qa.debian.org/isenkram">The Isenkram
6 system</a> provide a practical and easy way to figure out which
7 packages support the hardware in a given machine. The command line
8 tool <tt>isenkram-lookup</tt> and the tasksel options provide a
9 convenient way to list and install packages relevant for the current
10 hardware during system installation, both user space packages and
11 firmware packages. The GUI background daemon on the other hand provide
12 a pop-up proposing to install packages when a new dongle is inserted
13 while using the computer. For example, if you plug in a smart card
14 reader, the system will ask if you want to install <tt>pcscd</tt> if
15 that package isn't already installed, and if you plug in a USB video
16 camera the system will ask if you want to install <tt>cheese</tt> if
17 cheese is currently missing. This already work just fine.</p>
18
19 <p>But Isenkram depend on a database mapping from hardware IDs to
20 package names. When I started no such database existed in Debian, so
21 I made my own data set and included it with the isenkram package and
22 made isenkram fetch the latest version of this database from git using
23 http. This way the isenkram users would get updated package proposals
24 as soon as I learned more about hardware related packages.</p>
25
26 <p>The hardware is identified using modalias strings. The modalias
27 design is from the Linux kernel where most hardware descriptors are
28 made available as a strings that can be matched using filename style
29 globbing. It handle USB, PCI, DMI and a lot of other hardware related
30 identifiers.</p>
31
32 <p>The downside to the Isenkram specific database is that there is no
33 information about relevant distribution / Debian version, making
34 isenkram propose obsolete packages too. But along came AppStream, a
35 cross distribution mechanism to store and collect metadata about
36 software packages. When I heard about the proposal, I contacted the
37 people involved and suggested to add a hardware matching rule using
38 modalias strings in the specification, to be able to use AppStream for
39 mapping hardware to packages. This idea was accepted and AppStream is
40 now a great way for a package to announce the hardware it support in a
41 distribution neutral way. I wrote
42 <a href="http://people.skolelinux.org/pere/blog/Using_appstream_with_isenkram_to_install_hardware_related_packages_in_Debian.html">a
43 recipe on how to add such meta-information</a> in a blog post last
44 December. If you have a hardware related package in Debian, please
45 announce the relevant hardware IDs using AppStream.</p>
46
47 <p>In Debian, almost all packages that can talk to a LEGO Mindestorms
48 RCX or NXT unit, announce this support using AppStream. The effect is
49 that when you insert such LEGO robot controller into your Debian
50 machine, Isenkram will propose to install the packages needed to get
51 it working. The intention is that this should allow the local user to
52 start programming his robot controller right away without having to
53 guess what packages to use or which permissions to fix.</p>
54
55 <p>But when I sat down with my son the other day to program our NXT
56 unit using his Debian Stretch computer, I discovered something
57 annoying. The local console user (ie my son) did not get access to
58 the USB device for programming the unit. This used to work, but no
59 longer in Jessie and Stretch. After some investigation and asking
60 around on #debian-devel, I discovered that this was because udev had
61 changed the mechanism used to grant access to local devices. The
62 ConsoleKit mechanism from <tt>/lib/udev/rules.d/70-udev-acl.rules</tt>
63 no longer applied, because LDAP users no longer was added to the
64 plugdev group during login. Michael Biebl told me that this method
65 was obsolete and the new method used ACLs instead. This was good
66 news, as the plugdev mechanism is a mess when using a remote user
67 directory like LDAP. Using ACLs would make sure a user lost device
68 access when she logged out, even if the user left behind a background
69 process which would retain the plugdev membership with the ConsoleKit
70 setup. Armed with this knowledge I moved on to fix the access problem
71 for the LEGO Mindstorms related packages.</p>
72
73 <p>The new system uses a udev tag, 'uaccess'. It can either be
74 applied directly for a device, or is applied in
75 /lib/udev/rules.d/70-uaccess.rules for classes of devices. As the
76 LEGO Mindstorms udev rules did not have a class, I decided to add the
77 tag directly in the udev rules files included in the packages. Here
78 is one example. For the nqc C compiler for the RCX, the
79 <tt>/lib/udev/rules.d/60-nqc.rules</tt> file now look like this:
80
81 <p><pre>
82 SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="0694", ATTR{idProduct}=="0001", \
83 SYMLINK+="rcx-%k", TAG+="uaccess"
84 </pre></p>
85
86 <p>The key part is the 'TAG+="uaccess"' at the end. I suspect all
87 packages using plugdev in their /lib/udev/rules.d/ files should be
88 changed to use this tag (either directly or indirectly via
89 <tt>70-uaccess.rules</tt>). Perhaps a lintian check should be created
90 to detect this?</p>
91
92 <p>I've been unable to find good documentation on the uaccess feature.
93 It is unclear to me if the uaccess tag is an internal implementation
94 detail like the udev-acl tag used by
95 <tt>/lib/udev/rules.d/70-udev-acl.rules</tt>. If it is, I guess the
96 indirect method is the preferred way. Michael
97 <a href="https://github.com/systemd/systemd/issues/4288">asked for more
98 documentation from the systemd project</a> and I hope it will make
99 this clearer. For now I use the generic classes when they exist and
100 is already handled by <tt>70-uaccess.rules</tt>, and add the tag
101 directly if no such class exist.</p>
102
103 <p>To learn more about the isenkram system, please check out
104 <a href="http://people.skolelinux.org/pere/blog/tags/isenkram/">my
105 blog posts tagged isenkram</a>.</p>
106
107 <p>To help out making life for LEGO constructors in Debian easier,
108 please join us on our IRC channel
109 <a href="irc://irc.debian.org/%23debian-lego">#debian-lego</a> and join
110 the <a href="https://alioth.debian.org/projects/debian-lego/">Debian
111 LEGO team</a> in the Alioth project we created yesterday. A mailing
112 list is not yet created, but we are working on it. :)</p>
113
114 <p>As usual, if you use Bitcoin and want to show your support of my
115 activities, please send Bitcoin donations to my address
116 <b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&label=PetterReinholdtsenBlog">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>