summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Getopt.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-01-04 18:41:51 -0500
committerJoey Hess <joey@gnu.kitenet.net>2010-01-04 19:00:49 -0500
commit02bf22b2c4c695fd959f11c0d6a803795e014c2e (patch)
tree826d990cda08018db2c6cab9f62bc51b520a1952 /Debian/Debhelper/Dh_Getopt.pm
parent09d21e9f004aabe6a409c981c8d11e7cb4c2051f (diff)
solve the dh -Bbuild problem
* Add -O option, which can be used to pass options to commands, ignoring options that they do not support. * dh: Use -O to pass user-specified options to the commands it runs. This solves the problem with passing "-Bbuild" to dh, where commands that do not support -B would see a bogus -u option. Closes: #541773 (It also ensures that the commands dh prints out can really be run.)
Diffstat (limited to 'Debian/Debhelper/Dh_Getopt.pm')
-rw-r--r--Debian/Debhelper/Dh_Getopt.pm42
1 files changed, 27 insertions, 15 deletions
diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm
index 0d021072..4df3eed2 100644
--- a/Debian/Debhelper/Dh_Getopt.pm
+++ b/Debian/Debhelper/Dh_Getopt.pm
@@ -69,15 +69,8 @@ sub NonOption {
sub getoptions {
my $array=shift;
my %params=@_;
- my %options=%{$params{options}} if ref $params{options};
-
- my $oldwarn;
- if ($params{ignore_unknown_options}) {
- $oldwarn=$SIG{__WARN__};
- $SIG{__WARN__}=sub {};
- }
- my $ret=Getopt::Long::GetOptionsFromArray($array,
+ my %options=(
"v" => \$dh{VERBOSE},
"verbose" => \$dh{VERBOSE},
@@ -137,18 +130,37 @@ sub getoptions {
"ignore=s" => \&AddIgnore,
- %options,
+ "O=s" => sub { my($option,$value)=@_;
+ # Try to parse an option, but ignore it
+ # if it is not known.
+ if (getoptions([$value], %params, test => 1)) {
+ getoptions([$value], %params);
+ }
+ },
+
+ (ref $params{options} ? %{$params{options}} : ()) ,
"<>" => \&NonOption,
);
- if ($params{ignore_unknown_options}) {
- $SIG{__WARN__}=$oldwarn;
- return 1;
+ if ($params{test}) {
+ foreach my $key (keys %options) {
+ $options{$key}=sub {};
+ }
}
- else {
- return $ret;
+
+ my $oldwarn;
+ if ($params{test} || $params{ignore_unknown_options}) {
+ $oldwarn=$SIG{__WARN__};
+ $SIG{__WARN__}=sub {};
+ }
+ my $ret=Getopt::Long::GetOptionsFromArray($array, %options);
+ if ($oldwarn) {
+ $SIG{__WARN__}=$oldwarn;
}
+
+ return 1 if $params{ignore_unknown_options};
+ return $ret;
}
sub split_options_string {
@@ -171,7 +183,7 @@ sub parseopts {
# Avoid forcing acting on packages specified in
# DH_INTERNAL_OPTIONS. This way, -p can be specified
- # at the command line to act on a specific package, and if
+ # at the command line to act on a specific package, but when
# nothing is specified, the excludes will cause the set of
# packages DH_INTERNAL_OPTIONS specifies to be acted on.
if (defined $dh{DOPACKAGES}) {