]> git.donarmstrong.com Git - debhelper.git/blob - dh_installmodules
Updated French man page translation. Closes: #685560
[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 B<dh_installmodules> is a debhelper program that is responsible for
21 registering kernel modules.
22
23 Kernel modules are searched for in the package build directory and if
24 found, F<preinst>, F<postinst> and F<postrm> commands are automatically generated to
25 run B<depmod> and register the modules when the package is installed. 
26 These commands are inserted into the maintainer scripts by
27 L<dh_installdeb(1)>.
28
29 =head1 FILES
30
31 =over 4
32
33 =item debian/I<package>.modprobe
34
35 Installed to etc/modprobe.d/I<package>.conf in the package build directory.
36
37 =item debian/I<package>.modules
38
39 These files were installed for use by modutils, but are now not used
40 and B<dh_installmodules> will warn if these files are present.
41
42 =back
43
44 =head1 OPTIONS
45
46 =over 4
47
48 =item B<-n>, B<--noscripts>
49
50 Do not modify F<preinst>/F<postinst>/F<postrm> scripts.
51
52 =item B<--name=>I<name>
53
54 When this parameter is used, B<dh_installmodules> looks for and
55 installs files named debian/I<package>.I<name>.modprobe instead
56 of the usual debian/I<package>.modprobe
57
58 =back
59
60 =head1 NOTES
61
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.
65
66 =cut
67
68 init();
69
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 {
73         my $searchdir=shift;
74         my %versions;
75
76         return unless -d $searchdir;
77         find(sub {
78                 if (/\.k?o$/) {
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");
82                         }
83                         else {
84                                 $versions{$kvers}=1;
85                         }
86                 }
87         }, $searchdir);
88
89         return keys %versions;
90 }
91
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");
96
97         if (! -e $tmp) {
98                 doit("install","-d",$tmp);
99         }
100
101         if ($modutils_file) {
102                 warning("ignoring $modutils_file, since modutils is no longer in Debian");
103         }
104
105         if ($modprobe_file) {
106                 if (! -e "$tmp/etc/modprobe.d") {
107                         doit("install","-d","$tmp/etc/modprobe.d");
108                 }
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");
114         }
115         
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");
120                 }
121         }
122 }
123
124 =head1 SEE ALSO
125
126 L<debhelper(7)>
127
128 This program is a part of debhelper.
129
130 =head1 AUTHOR
131
132 Joey Hess <joeyh@debian.org>
133
134 =cut