]> git.donarmstrong.com Git - debhelper.git/blob - dh_installmodules
r1695: * dh_gconf: gconf schemas moved to /usr/share/gconf/schemas. Relocate
[debhelper.git] / dh_installmodules
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installmodules - register modules with modutils
6
7
8 =cut
9
10 use strict;
11 use Debian::Debhelper::Dh_Lib;
12 use File::Find;
13
14 =head1 SYNOPSIS
15
16 B<dh_installmodules> [S<I<debhelper options>>] [B<-n>] [B<--name=>I<name>]
17
18 =head1 DESCRIPTION
19
20 dh_installmodules is a debhelper program that is responsible for
21 registering kernel modules with modutils.
22
23 Files named debian/package.modules will be installed as
24 etc/modutils/package in the package build directory. This is for use by
25 modutils. Files named debian/package.modprobe will be installed in
26 etc/modprobe.d/package in the package build directory, to be used by
27 module-init-tools's version of modprobe.
28
29 Then postinst and postrm commands are automatically generated to register
30 the modules when the package is installed. See L<dh_installdeb(1)> for an
31 explanation of how this works. Note that this will be done for any
32 package this program acts on which has either a package.modules file, or
33 has .o or .ko files in /lib/modules.
34
35 =head1 OPTIONS
36
37 =over 4
38
39 =item B<-n>, B<--noscripts>
40
41 Do not modify postinst/postrm scripts.
42
43 =item B<--name=>I<name>
44
45 Use "name" as the filename the modules file is installed in
46 etc/modutils/. When this parameter is used, dh_installmodules looks for and
47 installs files named debian/package.name.modules instead of the usual
48 debian/package.modules.
49
50 =back
51
52 =head1 NOTES
53
54 Note that this command is not idempotent. "dh_clean -k" should be called
55 between invocations of this command. Otherwise, it may cause multiple
56 instances of the same text to be added to maintainer scripts.
57
58 =cut
59
60 init();
61
62 # Returns true if there are any .o or .ko files in the passed directory.
63 sub find_kernel_modules {
64         my $searchdir=shift;
65         my @results=();
66
67         return unless -d $searchdir;
68         find(sub { push @results, $_ if /\.k?o$/ }, $searchdir);
69         return @results > 0;
70 }
71
72 foreach my $package (@{$dh{DOPACKAGES}}) {
73         my $tmp=tmpdir($package);
74         my $modutils_file=pkgfile($package,"modules");
75         my $modprobe_file=pkgfile($package,"modprobe");
76
77         if (! -e $tmp) {
78                 doit("install","-d",$tmp);
79         }
80
81         if ($modutils_file) {
82                 if (! -e "$tmp/etc/modutils") {
83                         doit("install","-d","$tmp/etc/modutils");
84                 }
85                 doit("install","-m","0644",$modutils_file,"$tmp/etc/modutils/".pkgfilename($package));
86         }
87
88         if ($modprobe_file) {
89                 if (! -e "$tmp/etc/modprobe.d") {
90                         doit("install","-d","$tmp/etc/modprobe.d");
91                 }
92                 doit("install","-m","0644",$modprobe_file,"$tmp/etc/modprobe.d/".pkgfilename($package));
93         }
94         
95         if (! $dh{NOSCRIPTS} &&
96             ($modutils_file || find_kernel_modules("$tmp/lib/modules"))) {
97                         autoscript($package,"postinst","postinst-modules","s/#PACKAGE#/$package/");
98                         autoscript($package,"postrm","postrm-modules","s/#PACKAGE#/$package/");
99         }
100 }
101
102 =head1 SEE ALSO
103
104 L<debhelper(7)>
105
106 This program is a part of debhelper.
107
108 =head1 AUTHOR
109
110 Joey Hess <joeyh@debian.org>
111
112 =cut