diff options
author | Modestas Vainius <modestas@vainius.eu> | 2009-06-16 03:44:43 +0300 |
---|---|---|
committer | Modestas Vainius <modestas@vainius.eu> | 2009-06-17 22:33:45 +0300 |
commit | 49b64c7852744f54250121b1c60544e1f5de70b6 (patch) | |
tree | c23ce0ebd947e5ff707b716c6fd3f0ccd832c5d7 | |
parent | 4703e65b1f45f1859d4bd4b71dcb534d89e63dfd (diff) | |
download | debhelper-49b64c7852744f54250121b1c60544e1f5de70b6.tar.gz |
Add --help-buildsystem option to dh_auto.
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>
-rw-r--r-- | Debian/Debhelper/Dh_Buildsystems.pm | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm index 83017ece..6748a746 100644 --- a/Debian/Debhelper/Dh_Buildsystems.pm +++ b/Debian/Debhelper/Dh_Buildsystems.pm @@ -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); |