]> git.donarmstrong.com Git - debhelper.git/blob - dh_installudev
r1992: * Fix absurd typo. How did I test for an hour and miss that? Closes: #419612
[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 in
23 etc/udev/rules.d/ in the package build directory.
24
25 Code is added to the preinst and postinst to handle the upgrade from the
26 old udev rules file location.
27
28 =head1 OPTIONS
29
30 =over 4
31
32 =item B<--name=>I<name>
33
34 When this parameter is used, dh_installudev looks for and
35 installs files named debian/package.name.udev instead of the usual
36 debian/package.udev.
37
38 =item B<--priority=>I<priority>
39
40 Sets the priority string of the rules.d symlink. Default is z60.
41
42 =item B<-n>, B<--noscripts>
43
44 Do not modify postinst/postrm scripts.
45
46 =head1 NOTES
47
48 Note that this command is not idempotent. "dh_clean -k" should be called
49 between invocations of this command. Otherwise, it may cause multiple
50 instances of the same text to be added to maintainer scripts.
51
52 =back
53
54 =cut
55
56 init();
57
58 if (! defined $dh{PRIORITY}) {
59         $dh{PRIORITY}="z60";
60 }
61 if ($dh{PRIORITY}) {
62         $dh{PRIORITY}.="_";
63 }
64
65 foreach my $package (@{$dh{DOPACKAGES}}) {
66         my $tmp=tmpdir($package);
67         my $rules_file=pkgfile($package,"udev");
68         my $filename=basename($rules_file);
69         if ($filename eq 'udev') {
70                 $filename = "$package.udev";
71         }
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/rules.d/$dh{PRIORITY}$filename");
79                 if (! $dh{NOSCRIPTS}) {
80                         my $old="/etc/udev/$filename";
81                         my $rule="/etc/udev/rules.d/$dh{PRIORITY}$filename";
82                         autoscript($package,"preinst","preinst-udev","s!#OLD#!$old!g;s!#RULE#!$rule!g");
83                         autoscript($package,"postinst","postinst-udev","s!#OLD#!$old!g;s!#RULE#!$rule!g");
84                 }
85         }
86 }
87
88 =head1 SEE ALSO
89
90 L<debhelper(7)>
91
92 This program is a part of debhelper.
93
94 =head1 AUTHOR
95
96 Joey Hess <joeyh@debian.org>
97
98 =cut