5
dh_dkms - correctly handle DKMS usage by a kernel module package
10
use Debian::Debhelper::Dh_Lib;
14
B<dh_dkms> [S<I<debhelper options>>] [S<B<-l>>] [S<B<-V>[I<version>]>] [S<B<--> I<file>>]
18
dh_dkms is a debhelper program that is responsible for correctly setting
19
postinst, postrm and dependencies in kernel module packages using DKMS.
21
If a file named debian/package.dkms exists, then different actions are
22
performed, depending on its contents.
28
=item debian/I<package>.dkms
32
It can be a proper configuration file, and in this case it would be installed
33
in the proper directory as dkms.conf.
35
It can also point to another file (this should be used when the configuration
36
is provided by upstream), and in this case that file will be installed as dkms.conf
37
in the propery directory.
39
This file can only miss if a filename is provided when calling dh_dkms.
47
=item B<-l>, B<--legacy>
49
Add code to also support DKMS versions < 2.1.0.0.
51
=item B<-V>, B<-V> I<version>
53
If C<PACKAGE_VERSION> in F<dkms.conf> is set to C<#MODULE_VERSION#>, set it to
54
the given I<version> or, if none is given, default to the upstream version of
55
the current package. Otherwise, leave the value specified in F<dkms.conf>.
59
Don't look for debian/I<package>.dkms or debian/dkms, but install I<file> as dkms.conf.
65
Note that this command is not idempotent. L<dh_prep(1)> should be called
66
between invocations of this command. Otherwise, it may cause multiple
67
instances of the same text to be added to maintainer scripts.
72
"l|legacy" => \$dh{LEGACY_DKMS},
75
foreach my $package (@{$dh{DOPACKAGES}}) {
76
#next if is_udeb($package);
78
my $tmp = tmpdir($package);
79
my $dkms_dir = "/usr/lib/dkms/";
80
my $dkms_conf = pkgfile($package, "dkms");
88
# let's see if it's a proper snippet
89
open(IN, "< $dkms_conf");
90
while (my $l = <IN>) {
91
$l =~ /PACKAGE_NAME=(["'])(.*)\1/ && ($is_snippet = 1);
99
@other_conf = filearray($dkms_conf);
100
if ($#other_conf > 1) {
101
error "cannot list more than one file in $dkms_conf!";
104
$name = $other_conf[0];
108
elsif ($#ARGV == 0) {
114
verbose_print "installing $name as dkms.conf";
116
# now, parse our configuration file
118
while (my $l = <IN>) {
119
$l =~ /PACKAGE_NAME=(["'])(.*)\1/ && ($is_snippet = 1 && $package_name = $2);
120
$l =~ /PACKAGE_VERSION=(["'])(.*)\1/ && ($package_version = $2);
124
#$ENV{DH_AUTOSCRIPTDIR} = "debian/scripts/";
125
if ($dh{LEGACY_DKMS}) {
126
doit("install", "-p", "-D", "-m755", "$dkms_dir/common.postinst", "$tmp/usr/share/$package/postinst");
127
addsubstvar($package, "misc:Depends", "dkms");
130
addsubstvar($package, "misc:Depends", "dkms", ">= 2.1.0.0");
133
if ($dh{V_FLAG_SET}) {
134
$package_version = $dh{V_FLAG};
135
if ($package_version eq "") {
136
# Call isnative because it sets $dh{VERSION}
139
$package_version = $dh{VERSION};
140
# Remove the Debian revision
141
$package_version =~ s/-[^-]+$//;
144
my $old_name = $name;
145
$name = "debian/".pkgext($package)."dkms.debhelper";
146
doit("cp", "-a", $old_name, $name);
147
doit("sed", "-i", "s/#MODULE_VERSION#/$package_version/g", $name);
150
autoscript($package, "prerm", "prerm-dkms",
151
"s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
152
autoscript($package, "postinst", "postinst-dkms",
153
"s/#MODULE_NAME#/$package_name/;s/#MODULE_VERSION#/$package_version/");
154
doit("install", "-p", "-D", "-m644", "$name", "$tmp/usr/src/$package_name-$package_version/dkms.conf");
161
This program is part of the Debian DKMS package.
167
David Paleino <dapal@debian.org>