]> git.donarmstrong.com Git - debhelper.git/blob - dh_bugfiles
Typo. Closes: #653339
[debhelper.git] / dh_bugfiles
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_bugfiles - install bug reporting customization files into package build directories
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_bugfiles> [B<-A>] [S<I<debhelper options>>]
15
16 =head1 DESCRIPTION
17
18 B<dh_bugfiles> is a debhelper program that is responsible for installing
19 bug reporting customization files (bug scripts and/or bug control files
20 and/or presubj files) into package build directories.
21
22 =head1 FILES
23
24 =over 4
25
26 =item debian/I<package>.bug-script
27
28 This is the script to be run by the bug reporting program for generating a bug
29 report template. This file is installed as F<usr/share/bug/package> in the
30 package build directory if no other types of bug reporting customization
31 files are going to be installed for the package in question. Otherwise,
32 this file is installed as F<usr/share/bug/package/script>. Finally, the
33 installed script is given execute permissions.
34
35 =item debian/I<package>.bug-control
36
37 It is the bug control file containing some directions for the bug reporting
38 tool. This file is installed as F<usr/share/bug/package/control> in the
39 package build directory.
40
41 =item debian/I<package>.bug-presubj
42
43 The contents of this file are displayed to the user by the bug reporting
44 tool before allowing the user to write a bug report on the package to the
45 Debian Bug Tracking System. This file is installed as
46 F<usr/share/bug/package/presubj> in the package build directory.
47
48 =back
49
50 =head1 OPTIONS
51
52 =over 4
53
54 =item B<-A>, B<--all>
55
56 Install F<debian/bug-*> files to ALL packages acted on when respective
57 F<debian/package.bug-*> files do not exist. Normally, F<debian/bug-*> will
58 be installed to the first package only.
59
60 =back
61
62 =cut
63
64 init();
65
66 # Types of bug files this debhelper program handles.
67 # Hash value is the name of the pkgfile of the respective
68 # type.
69 my %bugfile_types = (
70         "script" => "bug-script",
71         "control" => "bug-control",
72         "presubj" => "bug-presubj",
73 );
74
75 foreach my $package (@{$dh{DOPACKAGES}}) {
76         next if is_udeb($package);
77
78         my $tmp=tmpdir($package);
79         my $dir="$tmp/usr/share/bug/$package";
80         
81         # Gather information which bug files are available for the
82         # package in question
83         my %bugfiles=();
84         while (my ($type, $pkgfilename) = each(%bugfile_types)) {
85                 my $file=pkgfile($package,$pkgfilename);
86                 if ($file) {
87                         $bugfiles{$type}=$file;
88                 } elsif (-f "debian/$pkgfilename" && $dh{PARAMS_ALL}) {
89                         $bugfiles{$type}="debian/$pkgfilename";
90                 }
91         }
92         
93         # If there is only a bug script to install, install it as
94         # usr/share/bug/$package (unless this path is a directory)
95         if (! -d $dir && scalar(keys(%bugfiles)) == 1 && exists $bugfiles{script}) {
96                 doit("install","-D","-p","-m755",$bugfiles{script},$dir);
97         }
98         elsif (scalar(keys(%bugfiles)) > 0) {
99                 if (-f $dir) {
100                         # Move usr/share/bug/$package to usr/share/bug/$package/script
101                         doit("mv", $dir, "${dir}.tmp");
102                         doit("install","-d",$dir);
103                         doit("mv", "${dir}.tmp", "$dir/script");
104                 }
105                 elsif (! -d $dir) {
106                         doit("install","-d",$dir);
107                 }
108                 while (my ($type, $srcfile) = each(%bugfiles)) {
109                         doit("install","-p","-m644",$srcfile, "$dir/$type");
110                 }
111         }
112         
113         # Ensure that the bug script is executable
114         if (-f $dir) {
115                 chmod 0755, $dir;
116         }
117         elsif (-f "$dir/script") {
118                 chmod 0755, "$dir/script";
119         }
120 }
121
122 =head1 SEE ALSO
123
124 F</usr/share/doc/reportbug/README.developers.gz>
125
126 L<debhelper(1)>
127
128 This program is a part of debhelper.
129
130 =head1 AUTHOR
131
132 Modestas Vainius <modestas@vainius.eu>
133
134 =cut