5 dh - debhelper command sequencer
10 use Debian::Debhelper::Dh_Lib;
14 B<dh> sequence [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining> [S<I<debhelper options>>]
18 dh runs a sequence of debhelper commands. The supported sequences
19 correspond to the targets of a debian/rules file: "build", "clean",
20 "install", "binary-arch", "binary-indep", and "binary".
22 Commands in the binary-indep sequence are passed the "-i" option to ensure
23 they only work on binary independent packages, and commands in the
24 binary-arch sequences are passed the "-a" option to ensure they only work
25 on architecture dependent packages.
27 Options passed to dh are passed on to each command it runs. This can be
28 used to set an option like "-v" or "-X" or "-N", as well as for more
31 Each debhelper command will record when it's successfully run in
32 debian/package.log.debhelper. (Which dh_clean deletes.) So dh can tell
33 which commands have already been run, for which packages, and skip running
36 Each time dh is run, it examines the log, and finds the last logged command
37 that is in the specified sequence. It then continues with the next command
38 in the sequence. The B<--until>, B<--before>, B<--after>, and B<--remaining>
39 options can override this behavior.
45 =item B<--until> I<cmd>
47 Run commands in the sequence until and including I<cmd>, then stop.
49 =item B<--before> I<cmd>
51 Run commands in the sequence before I<cmd>, then stop.
53 =item B<--after> I<cmd>
55 Run commands in the sequence that come after I<cmd>.
59 Run all commands in the sequence that have yet to be run.
61 =head1 COMMAND SPECIFICATON
63 I<cmd> can be a full name of a debhelper command, or a substring. It'll first
64 search for a command in the sequence exactly matching the name, to avoid any
65 ambiguity. If there are multiple substring matches, the last one in the
66 sequence will be used.
70 To see what commands are included in a sequence, without actually doing
75 This is a very simple rules file, for packages where the default seqences of
76 commands work with no additional options.
82 This is a simple rules file that is a good starting place for customisation.
83 (It's also available in F</usr/share/doc/debhelper/examples/rules.simple>
102 binary: binary-arch binary-indep
104 Often you'll want to pass an option to ./configure. This uses dh to run all
105 commands before L<dh_auto_configure(1)>, then runs that command by hand,
106 and then finished up by running the rest of the sequence. You could also
107 run ./configure by hand, instead of bothering with using dh_auto_configure.
108 And if necessary, you can add commands to run automake, etc here too.
111 dh build --before configure
112 dh_auto_configure --kitchen-sink=yes
113 dh build --after configure
115 Here's how to skip two automated in a row (configure and build), and
116 instead run the commands by hand.
119 dh build --before configure
121 make universe-explode-in-delight
122 dh build --after build
124 Another common case is wanting to run some code manually after a particular
125 debhelper command is run.
128 dh binary-arch --until dh_fixperms
129 # dh_fixperms has run, now override it for one program
130 chmod 4755 debian/foo/usr/bin/foo
132 dh binary-arch --after dh_fixperms
134 It's also fine to run debhelper commands before starting the dh sequence.
135 Just be sure to use the B<--remaining> option to ensure that commands
136 that normally come before those in the sequence are still run.
141 dh binary-arch --remaining
145 # Stash this away before init modifies it.
150 # Definitions of sequences.
152 $sequences{build} = [qw{
158 $sequences{clean} = [qw{
163 $sequences{install} = [@{$sequences{build}}, "dh_testroot", "dh_clean -k", qw{
209 $sequences{'binary-indep'} = [@{$sequences{install}}, @b];
210 $sequences{binary} = [@{$sequences{install}}, qw{
215 $sequences{'binary-arch'} = [@{$sequences{binary}}];
217 # Sequence parameter.
219 error "specify a sequence to run";
222 if (! exists $sequences{$sequence}) {
223 error "Unknown sequence $sequence (chose from: ".
224 join(" ", sort keys %sequences).")";
227 # Get the options to pass to commands in the sequence.
228 # Filter out options intended only for this program.
230 if ($sequence eq 'binary-arch') {
233 elsif ($sequence eq 'binary-indep') {
237 my $opt=shift @ARGV_orig;
238 next if $opt eq $sequence;
239 if ($opt =~ /^--?(after|until|before)$/) {
243 elsif ($opt =~ /^--?(remaining|(after|until|before)=)/) {
250 $_ ne $sequence && !/^--?(before|after|remaining)$/
253 foreach my $cmd (@{$sequences{$sequence}}) {
254 print "$cmd @options\n";
257 foreach my $package (@{$dh{DOPACKAGES}}) {
258 my $tmp=tmpdir($package);
259 my $ext=pkgext($package);
266 This program is a part of debhelper.
270 Joey Hess <joeyh@debian.org>