5
dh_modaliases - scan kmod modaliases and provide a substvar for them
11
use Debian::Debhelper::Dh_Lib;
15
B<dh_modaliases> [S<I<debhelper options>>]
19
B<dh_modaliases> is useful for packages that ship third-party kernel modules,
20
either in binary form, or as sources (with e. g. DKMS). It extracts the
21
modules' modaliases from either the compile .ko files themselves (for packages
22
which ship them in compiled form, using B<modinfo>), or from a package file
23
B<debian/>I<package>B<.modaliases> (see below).
25
I creates a package substitution variable C<${modaliases}> which you should add
26
to C<debian/control> as
30
XB-Modaliases: ${modaliases}
34
This enables software which is looking for missing driver packages (such as
35
Jockey or the operating system installer) to identify which package(s) will
36
provide a driver for a piece of hardware, identified by its modalias.
38
=head1 PACKAGE MODALIAS FILES
40
If a package ships source code (using DKMS, module-assistant, etc.) instead of
41
compiled binary kernel modules, then B<dh_modaliases> can't figure out the
42
modaliases by scanning the *.ko files, and you have to provide the modalias
43
list manually as a package file B<debian/>I<package>B<.modaliases>.
45
The format matches the /lib/modules/`uname -r`/modules.alias file from the
46
Linux kernel. Examples:
50
alias ssb:v1234id5678 snd_super_booster
51
alias pci:v000010DEd0000004Esv*sd*bc03sc*i* nvidia_current
55
You can generate such a list if you locally build and install this module, and
60
modinfo mymodname | perl -nae 'print "alias $1 mymodname\n" if /^alias:\s+(.*)$/'
64
(replacing "mymodname" with the actual module name).
68
The standard debhelper options are supported.
76
sub modalises_from_ko {
78
return unless /\.ko$/;
79
return if -l $_ or -d $_; # Skip directories and symlinks
81
# See if we were asked to exclude this file.
82
foreach my $f (@{$dh{EXCLUDE}}) {
83
return if ($File::Find::name =~ m/\Q$f\E/);
86
my ($modname) = ($name =~ /^(.*)\.ko$/);
87
$modname =~ s/-/_/g; # canonical names are with underscores
89
open M, '-|', 'modinfo', $name or die "open: $!";
91
if (/^alias:\s*(.*)$/) {
92
verbose_print("$File::Find::name: module $modname has alias $1");
99
$aliases .= $modname . '(' . (join ', ', @a) . ')';
102
sub modalises_from_pkgfile {
103
my %module_alias_map = ();
108
if (/^alias\s*([^[:space:]]+)\s*([^[:space:]]+)/) {
109
verbose_print("package file $_[0]: module $2 has alias $1");
110
push @{$module_alias_map{$2}}, $1;
112
warning("$_[0]: cannot translate line into modalias: $_");
116
foreach my $m (sort keys %module_alias_map) {
120
$aliases .= $m . '(' . (join ', ', @{$module_alias_map{$m}}) . ')';
124
foreach my $package (@{$dh{DOPACKAGES}})
126
my $tmp = tmpdir($package);
128
delsubstvar($package, 'modaliases');
130
my $manual_list = pkgfile($package, 'modaliases');
132
modalises_from_pkgfile $manual_list;
134
find(\&modalises_from_ko, tmpdir($package));
136
addsubstvar($package, 'modaliases', $aliases);
141
L<debhelper(1)>, L<dkms(8)>
143
This program is an extension to debhelper.
147
Martin Pitt <martin.pitt@ubuntu.com>