+sub split_options_string {
+ my $str=shift;
+ $str=~s/^\s+//;
+ return split(/\s+/,$str);
+}
+
+# Parse options and set %dh values.
+sub parseopts {
+ my $options=shift;
+
+ my @ARGV_extra;
+
+ # DH_INTERNAL_OPTIONS is used to pass additional options from
+ # dh through an override target to a command.
+ if (defined $ENV{DH_INTERNAL_OPTIONS}) {
+ @ARGV_extra=split_options_string($ENV{DH_INTERNAL_OPTIONS});
+ # Unknown options will be silently ignored.
+ my $oldwarn=$SIG{__WARN__};
+ $SIG{__WARN__}=sub {};
+ getoptions(\@ARGV_extra, $options);
+ $SIG{__WARN__}=$oldwarn;
+
+ # 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
+ # nothing is specified, the excludes will cause the set of
+ # packages DH_INTERNAL_OPTIONS specifies to be acted on.
+ if (defined $dh{DOPACKAGES}) {
+ foreach my $package (getpackages()) {
+ if (! grep { $_ eq $package } @{$dh{DOPACKAGES}}) {
+ $exclude_package{$package}=1;
+ }
+ }
+ }
+ delete $dh{DOPACKAGES};
+ delete $dh{DOINDEP};
+ delete $dh{DOARCH};
+ delete $dh{DOSAME};