=head1 SYNOPSIS
-B<dh> I<sequence> [B<--with> I<addon>[B<,>I<addon> ...]] [B<--list>] [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining>] [S<I<debhelper options>>]
+B<dh> I<sequence> [B<--with> I<addon>[B<,>I<addon> ...]] [B<--list>] [S<I<debhelper options>>]
=head1 DESCRIPTION
List all available addons.
-=item B<--until> I<cmd>
-
-Run commands in the sequence until and including I<cmd>, then stop.
-(Deprecated)
-
-=item B<--before> I<cmd>
-
-Run commands in the sequence before I<cmd>, then stop.
-(Deprecated)
-
-=item B<--after> I<cmd>
-
-Run commands in the sequence that come after I<cmd>.
-(Deprecated)
-
-=item B<--remaining>
-
-Run all commands in the sequence that have yet to be run.
-(Deprecated)
-
=item B<--no-act>
Prints commands that would run for a given sequence, but does not run them.
=back
-All other options passed to B<dh> are passed on to each command it runs. This
+Other options passed to B<dh> are passed on to each command it runs. This
can be used to set an option like B<-v> or B<-X> or B<-N>, as well as for more
specialised options.
-In the above options, I<cmd> can be a full name of a debhelper command, or
-a substring. It'll first search for a command in the sequence exactly
-matching the name, to avoid any ambiguity. If there are multiple substring
-matches, the last one in the sequence will be used.
-
-=cut
-
-sub command_pos {
- my $command=shift;
- my @sequence=@_;
-
- foreach my $i (0..$#sequence) {
- if ($command eq $sequence[$i]) {
- return $i;
- }
- }
-
- my @matches;
- foreach my $i (0..$#sequence) {
- if ($sequence[$i] =~ /\Q$command\E/) {
- push @matches, $i;
- }
- }
- if (! @matches) {
- error "command specification \"$command\" does not match any command in the sequence"
- }
- else {
- return pop @matches;
- }
-}
-
=head1 EXAMPLES
To see what commands are included in a sequence, without actually doing
%:
dh $@ --buildsystem=perl_build
-To patch your package using quilt, you can tell B<dh> to use quilt's B<dh>
-sequence addons like this:
-
- #!/usr/bin/make -f
- %:
- dh $@ --with quilt
-
Here is an example of overriding where the B<dh_auto_>I<*> commands find
the package's source, for a package where the source is located in a
subdirectory.
A sequence can also run dependent targets in debian/rules. For
example, the "binary" sequence runs the "install" target.
-B<dh> sets environment variables listed by B<dpkg-buildflags>, unless
-they are already set. It supports DEB_BUILD_OPTIONS=noopt too.
-
B<dh> uses the B<DH_INTERNAL_OPTIONS> environment variable to pass information
through to debhelper commands that are run inside override targets. The
contents (and indeed, existence) of this environment variable, as the name
might suggest, is subject to change at any time.
+=head1 DEPRECATED OPTIONS
+
+The following options are deprecated. It's much
+better to use override targets instead.
+
+=over 4
+
+=item B<--until> I<cmd>
+
+Run commands in the sequence until and including I<cmd>, then stop.
+
+=item B<--before> I<cmd>
+
+Run commands in the sequence before I<cmd>, then stop.
+
+=item B<--after> I<cmd>
+
+Run commands in the sequence that come after I<cmd>.
+
+=item B<--remaining>
+
+Run all commands in the sequence that have yet to be run.
+
+=back
+
+In the above options, I<cmd> can be a full name of a debhelper command, or
+a substring. It'll first search for a command in the sequence exactly
+matching the name, to avoid any ambiguity. If there are multiple substring
+matches, the last one in the sequence will be used.
+
=cut
# Stash this away before init modifies it.
dh_makeshlibs
dh_shlibdeps
};
+if (! getpackages("arch")) {
+ @ba=();
+}
my @b=qw{
dh_installdeb
dh_gencontrol
# Now run the commands in the sequence.
foreach my $i (0..$stoppoint) {
+ my $command=$sequence[$i];
+
# Figure out which packages need to run this command.
my @exclude;
foreach my $package (@packages) {
next;
}
- run($sequence[$i], \@packages, \@exclude, @options);
+ my $rules_target = rules_target($command);
+ if (defined $rules_target) {
+ # Don't pass DH_ environment variables, since this is
+ # a fresh invocation of debian/rules and any sub-dh commands.
+ delete $ENV{DH_INTERNAL_OPTIONS};
+ delete $ENV{DH_INTERNAL_OVERRIDE};
+ run("debian/rules", $rules_target);
+ next;
+ }
+
+ my @opts=@options;
+ # If some packages are excluded, add flags
+ # to prevent them from being acted on.
+ push @opts, map { "-N$_" } @exclude;
+
+ # Check for override targets in debian/rules, and run instead of
+ # the usual command.
+ next if run_override("override_".$command, $command,
+ \@packages, \@exclude, @opts);
+
+ run($command, @opts);
}
sub run {
my $command=shift;
- my @packages=@{shift()};
- my @exclude=@{shift()};
my @options=@_;
-
- # If some packages are excluded, add flags
- # to prevent them from being acted on.
- push @options, map { "-N$_" } @exclude;
- # Check for override targets in debian/rules and
- # run them instead of running the command directly.
- my $override_command;
- my $has_explicit_target = rules_explicit_target("override_".$command);
+ # Include additional command options if any
+ unshift @options, @{$command_opts{$command}}
+ if exists $command_opts{$command};
- my $rules_target = rules_target($command);
- if (defined $rules_target) {
- # Don't pass DH_ environment variables, since this is
- # a fresh invocation of debian/rules and any sub-dh
- # commands.
- $override_command=$command;
- delete $ENV{DH_INTERNAL_OPTIONS};
- delete $ENV{DH_INTERNAL_OVERRIDE};
- $command="debian/rules";
- @options=$rules_target;
- }
- elsif (defined $has_explicit_target) {
- $override_command=$command;
- # Check if target isn't noop
- if ($has_explicit_target) {
- # This passes the options through to commands called
- # inside the target.
- $ENV{DH_INTERNAL_OPTIONS}=join("\x1e", @options);
- $ENV{DH_INTERNAL_OVERRIDE}=$command;
- $command="debian/rules";
- @options="override_".$override_command;
- }
- else {
- $command = undef;
- }
- }
- else {
- # Pass additional command options if any
- unshift @options, @{$command_opts{$command}} if exists $command_opts{$command};
- }
+ # 3 space indent lines the command being run up under the
+ # sequence name after "dh ".
+ print " ".escape_shell($command, @options)."\n";
- if (defined $command) {
- # 3 space indent lines the command being run up under the
- # sequence name after "dh ".
- print " ".escape_shell($command, @options)."\n";
+ return if $dh{NO_ACT};
+
+ my $ret=system($command, @options);
+ if ($ret >> 8 != 0) {
+ exit $ret >> 8;
}
- else {
- print " ", "# Skipping ", $override_command, " - empty override", "\n";
+ elsif ($ret) {
+ exit 1;
}
-
- if (! $dh{NO_ACT}) {
- if (defined $command) {
- my $ret=system($command, @options);
-
- if ($ret >> 8 != 0) {
- exit $ret >> 8;
- }
- elsif ($ret) {
- exit 1;
- }
- }
+}
- if (defined $override_command) {
- # Update log for overridden command now that it has
- # finished successfully.
- # (But avoid logging for dh_clean since it removes
- # the log earlier.)
- if ($override_command ne 'dh_clean') {
- my %packages=map { $_ => 1 } @packages;
- map { delete $packages{$_} } @exclude;
- write_log($override_command, keys %packages);
- commit_override_log(keys %packages);
- }
+# Returns true if an override target exists for a command.
+sub run_override {
+ my $override=shift;
+ my $command=shift;
+ my @packages=@{shift()};
+ my @exclude=@{shift()};
+ my @options=@_;
+
+ my $has_explicit_target = rules_explicit_target($override);
+ return 0 unless defined $has_explicit_target; # no such override
+ return 1 if ! $has_explicit_target; # has empty override
- delete $ENV{DH_INTERNAL_OPTIONS};
- delete $ENV{DH_INTERNAL_OVERRIDE};
- }
+ # This passes the options through to commands called
+ # inside the target.
+ $ENV{DH_INTERNAL_OPTIONS}=join("\x1e", @options);
+ $ENV{DH_INTERNAL_OVERRIDE}=$command;
+ run("debian/rules", "override_".$command);
+ delete $ENV{DH_INTERNAL_OPTIONS};
+ delete $ENV{DH_INTERNAL_OVERRIDE};
+
+ # Update log for overridden command now that it has
+ # finished successfully.
+ # (But avoid logging for dh_clean since it removes
+ # the log earlier.)
+ if (! $dh{NO_ACT} && $command ne 'dh_clean') {
+ my %packages=map { $_ => 1 } @packages;
+ map { delete $packages{$_} } @exclude;
+ write_log($command, keys %packages);
+ commit_override_log(keys %packages);
}
+
+ return 1;
}
sub optimize_sequence {
}
}
+sub command_pos {
+ my $command=shift;
+ my @sequence=@_;
+
+ foreach my $i (0..$#sequence) {
+ if ($command eq $sequence[$i]) {
+ return $i;
+ }
+ }
+
+ my @matches;
+ foreach my $i (0..$#sequence) {
+ if ($sequence[$i] =~ /\Q$command\E/) {
+ push @matches, $i;
+ }
+ }
+ if (! @matches) {
+ error "command specification \"$command\" does not match any command in the sequence"
+ }
+ else {
+ return pop @matches;
+ }
+}
+
=head1 SEE ALSO
L<debhelper(7)>