]> git.donarmstrong.com Git - debhelper.git/blob - dh_installudev
r1908: * dh_installudev: Include rules.d directory so symlink can be made even
[debhelper.git] / dh_installudev
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installudev - install udev rules files
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_installudev> [S<I<debhelper options>>] [B<-n>] [B<--name=>I<name>] [B<--priority=>I<priority>]
17
18 =head1 DESCRIPTION
19
20 dh_installudev is a debhelper program that is responsible for
21 installing udev rules files.
22
23 Files named debian/package.udev will be installed as
24 etc/udev/package.rules in the package build directory.
25
26 Then postinst and postrm commands are automatically generated to enable
27 the rules file when the package is first installed, by creating a symlink
28 to it in the /etc/udev/rules.d/ directory. See L<dh_installdeb(1)> for an
29 explanation of how this works.
30
31 =head1 OPTIONS
32
33 =over 4
34
35 =item B<-n>, B<--noscripts>
36
37 Do not modify postinst/postrm scripts.
38
39 =item B<--name=>I<name>
40
41 When this parameter is used, dh_installudev looks for and
42 installs files named debian/package.name.udev instead of the usual
43 debian/package.udev.
44
45 =item B<--priority=>I<priority>
46
47 Sets the priority string of the rules.d symlink. Default is z60.
48
49 =back
50
51 =head1 NOTES
52
53 Note that this command is not idempotent. "dh_clean -k" should be called
54 between invocations of this command. Otherwise, it may cause multiple
55 instances of the same text to be added to maintainer scripts.
56
57 =cut
58
59 init();
60
61 if (! defined $dh{PRIORITY}) {
62         $dh{PRIORITY}="z60";
63 }
64 if ($dh{PRIORITY}) {
65         $dh{PRIORITY}.="_";
66 }
67
68 foreach my $package (@{$dh{DOPACKAGES}}) {
69         my $tmp=tmpdir($package);
70         my $rules_file=pkgfile($package,"udev");
71         my $filename=basename($rules_file);
72         $filename=~s/\.udev$/.rules/;
73
74         if ($rules_file) {
75                 if (! -e "$tmp/etc/udev/rules.d") {
76                         doit("install","-d","$tmp/etc/udev/rules.d");
77                 }
78                 doit("install","-m","0644",$rules_file,"$tmp/etc/udev/$filename");
79
80                 if (! $dh{NOSCRIPTS}) {
81                         autoscript($package,"postinst","postinst-udev",
82                                 "s/#FILE#/$filename/g;s/#PRIO#/$dh{PRIORITY}/g");
83                         autoscript($package,"postrm","postrm-udev",
84                                 "s/#FILE#/$filename/g;s/#PRIO#/$dh{PRIORITY}/g");
85                 }
86         }
87 }
88
89 =head1 SEE ALSO
90
91 L<debhelper(7)>
92
93 This program is a part of debhelper.
94
95 =head1 AUTHOR
96
97 Joey Hess <joeyh@debian.org>
98
99 =cut