]> git.donarmstrong.com Git - debhelper.git/commitdiff
Add --help-buildsystem option to dh_auto.
authorModestas Vainius <modestas@vainius.eu>
Tue, 16 Jun 2009 00:44:43 +0000 (03:44 +0300)
committerModestas Vainius <modestas@vainius.eu>
Wed, 17 Jun 2009 19:33:45 +0000 (22:33 +0300)
Displays POD of the (auto)selected build system. It should be useful to get
more information about third party build systems. Implementation uses
perldoc whenever possible.

Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Debian/Debhelper/Dh_Buildsystems.pm

index 83017ece738443f7c6da47bc6928777104447f36..6748a74629d64dd77a25e9e0fab809db4710e94b 100644 (file)
@@ -29,6 +29,7 @@ my $opt_buildsys;
 my $opt_sourcedir;
 my $opt_builddir;
 my $opt_list;
+my $opt_help_buildsys;
 
 sub create_buildsystem_instance {
        my $system=shift;
@@ -121,6 +122,8 @@ sub buildsystems_init {
 
            "l" => \$opt_list,
            "list" => \$opt_list,
+
+           "help-buildsystem" => \$opt_help_buildsys,
        );
        $args{options}{$_} = $options{$_} foreach keys(%options);
        Debian::Debhelper::Dh_Lib::init(%args);
@@ -151,6 +154,50 @@ sub buildsystems_list {
                if ! defined $auto && ! defined $specified;
 }
 
+sub help_buildsystem {
+       my $step=shift;
+
+       # Print build system help page to standard output
+
+       my $inst = load_buildsystem($opt_buildsys, $step);
+       if ($inst) {
+               my $pmfile = ref $inst;
+               $pmfile =~ s#::#/#g;
+               $pmfile = $INC{"$pmfile.pm"};
+
+               # Display help with perldoc if it is installed and output is
+               # a tty
+               my $perldoc;
+               if (-t STDOUT) {
+                       eval "use Pod::Perldoc";
+                       $perldoc = "Pod::Perldoc" if (!$@);
+               }
+               if ($perldoc) {
+                       $perldoc = new Pod::Perldoc();
+                       $perldoc->{args} = [ '-oman',
+                                            '-w', 'section=7" "--name=dh_auto_'.lc($inst->NAME()),
+                                            '-w', 'center=Dh_auto build system documentation',
+                                            '-w', 'release=',
+                                            '-F', $pmfile ];
+                       $perldoc->process();
+               }
+               else {
+                       # No perldoc on the system. Use Pod::Usage to emit simple text
+                       eval "use Pod::Usage";
+                       pod2usage( -message => "Help page for the ".$inst->NAME()." build system\n" .
+                                              '<' . '-'x74 . '>',
+                                  -input => $pmfile, -exitval => 'NOEXIT',
+                                  -verbose => 2, -noperldoc => 1 );
+                       print '<', '-'x74, '>', "\n";
+               }
+               return 0;
+       }
+       else {
+               print STDERR "No system auto-selected or specified. Try using --buildsystem option\n";
+               return 1;
+       }
+}
+
 sub buildsystems_do {
        my $step=shift;
 
@@ -168,6 +215,10 @@ sub buildsystems_do {
                exit 0;
        }
 
+       if ($opt_help_buildsys) {
+               exit help_buildsystem($step);
+       }
+
        my $buildsystem = load_buildsystem($opt_buildsys, $step);
        if (defined $buildsystem) {
                $buildsystem->pre_building_step($step);