5 dh_installmodules - register modules with modutils
11 use Debian::Debhelper::Dh_Lib;
16 B<dh_installmodules> [S<I<debhelper options>>] [B<-n>] [B<--name=>I<name>]
20 dh_installmodules is a debhelper program that is responsible for
21 registering kernel modules.
23 Files named debian/package.modprobe will be installed in
24 etc/modprobe.d/package.conf in the package build directory, to be used by
25 module-init-tools's version of modprobe.
27 Kernel modules are searched for in the package build directory and if
28 found, postinst and postrm commands are automatically generated to
29 run depmod and register the modules when the package is installed.
30 These commands are inserted into the maintainer scripts by dh_installdeb.
31 See L<dh_installdeb(1)> for an explanation of how this works.
33 Previous versions of dh_installmodules installed files named
34 etc/modprobe.d/package, code is added to the preinst and postinst to
35 handle the upgrade from the old location.
37 Previous versions of dh_installmodules also supported
38 files named debian/package.modules, which were installed into
39 etc/modutils/package in the package build directory. This was for use by
40 modutils, which is no longer in Debian. dh_installmodules will warn about
47 =item B<-n>, B<--noscripts>
49 Do not modify postinst/postrm scripts.
51 =item B<--name=>I<name>
53 When this parameter is used, dh_installmodules looks for and
54 installs files named debian/package.name.modules and
55 debian/package.name.modprobe instead of the usual
56 debian/package.modules and debian/package.modprobe
62 Note that this command is not idempotent. L<dh_prep(1)> should be called
63 between invocations of this command. Otherwise, it may cause multiple
64 instances of the same text to be added to maintainer scripts.
70 # Looks for kernel modules in the passed directory. If any are found,
71 # returns the kernel version (or versions) that the modules seem to be for.
72 sub find_kernel_modules {
76 return unless -d $searchdir;
79 my ($kvers)=$File::Find::dir=~m!lib/modules/([^/]+)/!;
80 if (! defined $kvers || ! length $kvers) {
81 warning("Cannot determine kernel version for module $File::Find::name");
89 return keys %versions;
92 foreach my $package (@{$dh{DOPACKAGES}}) {
93 my $tmp=tmpdir($package);
94 my $modutils_file=pkgfile($package,"modules");
95 my $modprobe_file=pkgfile($package,"modprobe");
98 doit("install","-d",$tmp);
101 if ($modutils_file) {
102 warning("ignoring $modutils_file, since modutils is no longer in Debian");
105 if ($modprobe_file) {
106 if (! -e "$tmp/etc/modprobe.d") {
107 doit("install","-d","$tmp/etc/modprobe.d");
109 my $old="/etc/modprobe.d/".pkgfilename($package);
110 my $new=$old.".conf";
111 doit("install","-m","0644",$modprobe_file,"$tmp/$new");
112 autoscript($package,"preinst","preinst-moveconffile","s!#OLD#!$old!g;s!#PACKAGE#!$package!g");
113 autoscript($package,"postinst","postinst-moveconffile","s!#OLD#!$old!g;s!#NEW#!$new!g");
116 if (! $dh{NOSCRIPTS}) {
117 foreach my $kvers (find_kernel_modules("$tmp/lib/modules")) {
118 autoscript($package,"postinst","postinst-modules","s/#KVERS#/$kvers/g");
119 autoscript($package,"postrm","postrm-modules","s/#KVERS#/$kvers/g");
128 This program is a part of debhelper.
132 Joey Hess <joeyh@debian.org>