]> git.donarmstrong.com Git - debhelper.git/blob - dh_installudev
r1970: * dh_installudev: Support debian/udev files. Closes: #381854
[debhelper.git] / dh_installudev
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installudev - install udev rules files
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11 use File::Find;
12
13 =head1 SYNOPSIS
14
15 B<dh_installudev> [S<I<debhelper options>>] [B<-n>] [B<--name=>I<name>] [B<--priority=>I<priority>]
16
17 =head1 DESCRIPTION
18
19 dh_installudev is a debhelper program that is responsible for
20 installing udev rules files.
21
22 Files named debian/package.udev will be installed as
23 etc/udev/package.rules in the package build directory.
24
25 Then postinst and postrm commands are automatically generated to enable
26 the rules file when the package is first installed, by creating a symlink
27 to it in the /etc/udev/rules.d/ directory. These commands are inserted into
28 the maintainer scripts by dh_installdeb. 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         if ($filename eq 'udev') {
73                 $filename = "$package.udev";
74         }
75         $filename=~s/\.udev$/.rules/;
76
77         if ($rules_file) {
78                 if (! -e "$tmp/etc/udev/rules.d") {
79                         doit("install","-d","$tmp/etc/udev/rules.d");
80                 }
81                 doit("install","-m","0644",$rules_file,"$tmp/etc/udev/$filename");
82
83                 if (! $dh{NOSCRIPTS}) {
84                         autoscript($package,"postinst","postinst-udev",
85                                 "s/#FILE#/$filename/g;s/#PRIO#/$dh{PRIORITY}/g");
86                         autoscript($package,"postrm","postrm-udev",
87                                 "s/#FILE#/$filename/g;s/#PRIO#/$dh{PRIORITY}/g");
88                 }
89         }
90 }
91
92 =head1 SEE ALSO
93
94 L<debhelper(7)>
95
96 This program is a part of debhelper.
97
98 =head1 AUTHOR
99
100 Joey Hess <joeyh@debian.org>
101
102 =cut