]> git.donarmstrong.com Git - debhelper.git/blob - dh_installudev
696543f182ed9955185d78d9af9ca94ee3131de5
[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 Use "name" as the filename the rules file is installed in
42 /etc/udev/. When this parameter is used, dh_installudev looks for and
43 installs files named debian/package.name.udev instead of the usual
44 debian/package.udev.
45
46 =item B<--priority=>I<priority>
47
48 Sets the priority string of the rules.d symlink. Default is z60.
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 if (! defined $dh{PRIORITY}) {
63         $dh{PRIORITY}="z60";
64 }
65 if ($dh{PRIORITY}) {
66         $dh{PRIORITY}.="_";
67 }
68
69 foreach my $package (@{$dh{DOPACKAGES}}) {
70         my $tmp=tmpdir($package);
71         my $rules_file=pkgfile($package,"udev");
72         my $filename=basename($rules_file);
73         $filename=~s/\.udev$/.rules/;
74
75         if ($rules_file) {
76                 if (! -e "$tmp/etc/udev") {
77                         doit("install","-d","$tmp/etc/udev");
78                 }
79                 doit("install","-m","0644",$rules_file,"$tmp/etc/udev/$filename");
80
81                 if (! $dh{NOSCRIPTS}) {
82                         autoscript($package,"postinst","postinst-udev",
83                                 "s/#FILE#/$filename/g;s/#PRIO#/$dh{PRIORITY}/g");
84                         autoscript($package,"postrm","postrm-udev",
85                                 "s/#FILE#/$filename/g;s/#PRIO#/$dh{PRIORITY}/g");
86                 }
87         }
88 }
89
90 =head1 SEE ALSO
91
92 L<debhelper(7)>
93
94 This program is a part of debhelper.
95
96 =head1 AUTHOR
97
98 Joey Hess <joeyh@debian.org>
99
100 =cut