--- /dev/null
+Title: Using modalias info to find packages handling my hardware
+Tags: english, debian
+Date: 2013-01-15 08:00
+
+<p>Yesterday, I wrote about the
+<a href="http://people.skolelinux.org/pere/blog/Modalias_strings___a_practical_way_to_map__stuff__to_hardware.html">modalias
+values provided by the Linux kernel</a> following my hope for
+<a href="http://people.skolelinux.org/pere/blog/Lets_make_hardware_dongles_easier_to_use_in_Debian.html">better
+dongle support in Debian</a>. Using this knowledge, I have tested how
+modalias values attached to package names can be used to map packages
+to hardware. This allow the system to look up and suggest relevant
+packages when I plug in some new hardware into my machine, and replace
+discover and discover-data as the database used to map hardware to
+packages.</p>
+
+<p>I create a modaliases file with entries like the following,
+containing package name, kernel module name (if relevant, otherwise
+the package name) and globs matching the relevant hardware
+modalias.</p>
+
+<p><blockquote>
+Package: package-name
+<br>Modaliases: module(modaliasglob, modaliasglob, modaliasglob)</p>
+</blockquote></p>
+
+<p>It is fairly trivial to write code to find the relevant packages
+for a given modalias value using this file.</p>
+
+<p>An entry like this would suggest the video and picture application
+cheese for many USB web cameras (interface bus class 0E01):</p>
+
+<p><blockquote>
+Package: cheese
+<br>Modaliases: cheese(usb:v*p*d*dc*dsc*dp*ic0Eisc01ip*)</p>
+</blockquote></p>
+
+<p>An entry like this would suggest the pcmciautils package when a
+CardBus bridge (bus class 0607) PCI device is present:</p>
+
+<p><blockquote>
+Package: pcmciautils
+<br>Modaliases: pcmciautils(pci:v*d*sv*sd*bc06sc07i*)
+</blockquote></p>
+
+<p>An entry like this would suggest the package colorhug-client when
+plugging in a ColorHug with USB IDs 04D8:F8DA:</p>
+
+<p><blockquote>
+Package: colorhug-client
+<br>Modaliases: colorhug-client(usb:v04D8pF8DAd*)</p>
+</blockquote></p>
+
+<p>I believe the format is compatible with the format of the Packages
+file in the Debian archive. Ubuntu already uses their Packages file
+to store their mappings from packages to hardware.</p>
+
+<p>By adding a XB-Modaliases: header in debian/control, any .deb can
+announce the hardware it support in a way my prototype understand.
+This allow those publishing packages in an APT source outside the
+Debian archive as well as those backporting packages to make sure the
+hardware mapping are included in the package meta information. I've
+tested such header in the pymissile package, and its modalias mapping
+is working as it should with my prototype. It even made it to Ubuntu
+Raring.</p>
+
+<p>To test if it was possible to look up supported hardware using only
+the shell tools available in the Debian installer, I wrote a shell
+implementation of the lookup code. The idea is to create files for
+each modalias and let the shell do the matching. Please check out and
+try the
+<a href="http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/hw-support-lookup?view=co">hw-support-lookup</a>
+shell script. It run without any extra dependencies and fetch the
+hardware mappings from the Debian archive and the subversion
+repository where I currently work on my prototype.</p>
+
+<p>When I use it on a machine with a yubikey inserted, it suggest to
+install yubikey-personalization:</p>
+
+<p><blockquote>
+% ./hw-support-lookup
+<br>yubikey-personalization:
+<br>%
+</blockquote></p>
+
+<p>When I run it on my Thinkpad X40 with a PCMCIA/CardBus slot, it
+propose to install the pcmciautils package:</p>
+
+<p><blockquote>
+% ./hw-support-lookup
+<br>pcmciautils
+<br>%
+</blockquote></p>
+
+<p>If you know of any hardware-package mapping that should be added to
+<a href="http://anonscm.debian.org/viewvc/debian-edu/trunk/src/hw-support-handler/modaliases?view=co">my
+database</a>, please tell me about it.</p>
+
+<p>It could be possible to generate several of the mappings between
+packages and hardware. One source would be to look at packages with
+kernel modules, ie packages with *.ko files in /lib/modules/, and
+extract their modalias information. Another would be to look at
+packages with udev rules, ie packages with files in
+/lib/udev/rules.d/, and extract their vendor/model information to
+generate a modalias matching rule. I have not tested any of these to
+see if it work.</p>
+
+<p>If you want to help implementing a system to let us propose what
+packages to install when new hardware is plugged into a Debian
+machine, please send me an email or talk to me on
+<a href="irc://irc.debian.org/%23debian-devel">#debian-devel</a>.</p>