]> git.donarmstrong.com Git - debhelper.git/commitdiff
Add dh_bugfiles - a helper for reportbug files
authorModestas Vainius <modestas@vainius.eu>
Fri, 31 Oct 2008 10:43:31 +0000 (12:43 +0200)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 6 Mar 2009 23:22:47 +0000 (18:22 -0500)
* Add a new helper: dh_bugfiles. It can be used for installing
  bug reporting customization files (Closes: #326874).

Signed-off-by: Modestas Vainius <modestas@vainius.eu>
dh
dh_bugfiles [new file with mode: 0755]

diff --git a/dh b/dh
index 15b587d3b8d681b63c337f944df88fe860634ad9..498c7cff55162b207a8fadc66c02a1b016b4112b 100755 (executable)
--- a/dh
+++ b/dh
@@ -249,6 +249,7 @@ $sequences{install} = [@{$sequences{build}}, qw{
        dh_installudev
        dh_installwm
        dh_installxfonts
+       dh_bugfiles
        dh_lintian
        dh_desktop
        dh_gconf
diff --git a/dh_bugfiles b/dh_bugfiles
new file mode 100755 (executable)
index 0000000..2941443
--- /dev/null
@@ -0,0 +1,131 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_bugfiles - install bug reporting customization files into package build directories
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_bugfiles> [B<-A>] [S<I<debhelper options>>]
+
+=head1 DESCRIPTION
+
+dh_bugfiles is a debhelper program that is responsible for installing
+bug reporting customization files (bug scripts and/or bug control files
+and/or presubj files) into package build directories.
+
+This helper program installs the following files if they are found:
+
+=over 3
+
+=item B<debian/package.bug-script>, B<debian/bug-script>
+
+It is the script to be run by the bug reporting program for generating a bug
+report template. This file is installed as F<usr/share/bug/package> into the
+package build directory if no other types of bug reporting customization
+files are going to be installed for the package in question. Otherwise,
+this file is installed as F<usr/share/bug/package/script>. Finally, the
+installed script is given execute permissions.
+
+=item B<debian/package.bug-control>, B<debian/bug-control>
+
+It is the bug control file containing some directions for the bug reporting
+tool. This file is installed as F<usr/share/bug/package/control> into the
+package build directory.
+
+=item B<debian/package.bug-presubj>, B<debian/bug-presubj> 
+
+The contents of this file are displayed to the user by the bug reporting
+tool before allowing the user to write a bug report on the package to the
+Debian Bug Tracking System. This file is installed as
+F<usr/share/bug/package/control> into the package build directory.
+
+=back
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-A>, B<--all>
+
+Install debian/bug-* files to ALL packages acted on when respective
+debian/package.bug-* files do not exist. Normally, debian/bug-* will
+be installed to the first package only.
+
+=back
+
+=cut
+
+init();
+
+# Types of bug files this debhelper program handles.
+# Hash value is the name of the pkgfile of the respective
+# type.
+my %bugfile_types = (
+       "script" => "bug-script",
+       "control" => "bug-control",
+       "presubj" => "bug-presubj",
+);
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+       next if is_udeb($package);
+
+       my $tmp=tmpdir($package);
+       my $dir="$tmp/usr/share/bug/$package";
+       
+       # Gather information which bug files are available for the
+       # package in question
+       my %bugfiles=();
+       while (my ($type, $pkgfilename) = each(%bugfile_types)) {
+               my $file=pkgfile($package,$pkgfilename);
+               if ($file) {
+                       $bugfiles{$type}=$file;
+               } elsif (-f "debian/$pkgfilename" && $dh{PARAMS_ALL}) {
+                       $bugfiles{$type}="debian/$pkgfilename";
+               }
+       }
+       
+       # If there is only a bug script to install, install it as
+       # /usr/share/bug/$package (unless this path is a directory)
+       if (! -d $dir && scalar(keys(%bugfiles)) == 1 && exists $bugfiles{script}) {
+               doit("install","-D","-p","-m755",$bugfiles{script},$dir);
+       } elsif (scalar(keys(%bugfiles)) > 0) {
+               if (-f $dir) {
+                       # Move usr/share/bug/$package to usr/share/bug/$package/script
+                       doit("mv", $dir, "${dir}.tmp");
+                       doit("install","-d",$dir);
+                       doit("mv", "${dir}.tmp", "$dir/script");
+               } elsif (! -d $dir) {
+                       doit("install","-d",$dir);
+               }
+               while (my ($type, $srcfile) = each(%bugfiles)) {
+                       doit("install","-p","-m644",$srcfile, "$dir/$type");
+               }
+       }
+       
+       # Ensure that the bug script is executable
+       if (-f $dir) {
+               chmod 0755, $dir;
+       } elsif (-f "$dir/script") {
+               chmod 0755, "$dir/script";
+       }
+}
+
+=head1 SEE ALSO
+
+F</usr/share/doc/reportbug/README.developers.gz> (needs B<reportbug> package installed)
+
+L<debhelper(1)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Modestas Vainius <modestas@vainius.eu>
+
+=cut