/usr/bin/dh_modaliases is in dh-modaliases 0.9.7-0ubuntu7.16.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | #!/usr/bin/perl -w
=head1 NAME
dh_modaliases - scan kmod modaliases and provide a substvar for them
=cut
use strict;
use File::Find;
use Debian::Debhelper::Dh_Lib;
=head1 SYNOPSIS
B<dh_modaliases> [S<I<debhelper options>>]
=head1 DESCRIPTION
B<dh_modaliases> is useful for packages that ship third-party kernel modules,
either in binary form, or as sources (with e. g. DKMS). It extracts the
modules' modaliases from either the compile .ko files themselves (for packages
which ship them in compiled form, using B<modinfo>), or from a package file
B<debian/>I<package>B<.modaliases> (see below).
I creates a package substitution variable C<${modaliases}> which you should add
to C<debian/control> as
=over 4
XB-Modaliases: ${modaliases}
=back
This enables software which is looking for missing driver packages (such as
Jockey or the operating system installer) to identify which package(s) will
provide a driver for a piece of hardware, identified by its modalias.
=head1 PACKAGE MODALIAS FILES
If a package ships source code (using DKMS, module-assistant, etc.) instead of
compiled binary kernel modules, then B<dh_modaliases> can't figure out the
modaliases by scanning the *.ko files, and you have to provide the modalias
list manually as a package file B<debian/>I<package>B<.modaliases>.
The format matches the /lib/modules/`uname -r`/modules.alias file from the
Linux kernel. Examples:
=over 4
alias ssb:v1234id5678 snd_super_booster
alias pci:v000010DEd0000004Esv*sd*bc03sc*i* nvidia_current
=back
You can generate such a list if you locally build and install this module, and
then run
=over 4
modinfo mymodname | perl -nae 'print "alias $1 mymodname\n" if /^alias:\s+(.*)$/'
=back
(replacing "mymodname" with the actual module name).
=head1 OPTIONS
The standard debhelper options are supported.
=cut
init();
my $aliases;
sub modalises_from_ko {
my $name = $_;
return unless /\.ko$/;
return if -l $_ or -d $_; # Skip directories and symlinks
# See if we were asked to exclude this file.
foreach my $f (@{$dh{EXCLUDE}}) {
return if ($File::Find::name =~ m/\Q$f\E/);
}
my ($modname) = ($name =~ /^(.*)\.ko$/);
$modname =~ s/-/_/g; # canonical names are with underscores
my @a;
open M, '-|', 'modinfo', $name or die "open: $!";
while (<M>) {
if (/^alias:\s*(.*)$/) {
verbose_print("$File::Find::name: module $modname has alias $1");
push @a, $1;
}
}
if ($aliases) {
$aliases .= ', ';
}
$aliases .= $modname . '(' . (join ', ', @a) . ')';
}
sub modalises_from_pkgfile {
my %module_alias_map = ();
open F, $_[0];
while (<F>) {
next if /^#/;
if (/^alias\s*([^[:space:]]+)\s*([^[:space:]]+)/) {
verbose_print("package file $_[0]: module $2 has alias $1");
push @{$module_alias_map{$2}}, $1;
} else {
warning("$_[0]: cannot translate line into modalias: $_");
}
}
foreach my $m (sort keys %module_alias_map) {
if ($aliases) {
$aliases .= ', ';
}
$aliases .= $m . '(' . (join ', ', @{$module_alias_map{$m}}) . ')';
}
}
foreach my $package (@{$dh{DOPACKAGES}})
{
my $tmp = tmpdir($package);
delsubstvar($package, 'modaliases');
$aliases = '';
my $manual_list = pkgfile($package, 'modaliases');
if ($manual_list) {
modalises_from_pkgfile $manual_list;
} else {
find(\&modalises_from_ko, tmpdir($package));
}
addsubstvar($package, 'modaliases', $aliases);
}
=head1 SEE ALSO
L<debhelper(1)>, L<dkms(8)>
This program is an extension to debhelper.
=head1 AUTHOR
Martin Pitt <martin.pitt@ubuntu.com>
=cut
|