1DH(1)                              Debhelper                             DH(1)
2
3
4

NAME

6       dh - debhelper command sequencer
7

SYNOPSIS

9       dh sequence [--with addon[,addon ...]] [--list] [debhelperĀ options]
10

DESCRIPTION

12       dh runs a sequence of debhelper commands. The supported sequences
13       correspond to the targets of a debian/rules file: build-arch, build-
14       indep, build, clean, install-indep, install-arch, install, binary-arch,
15       binary-indep, and binary.
16

OVERRIDE TARGETS

18       A debian/rules file using dh can override the command that is run at
19       any step in a sequence, by defining an override target.
20
21       To override dh_command, add a target named override_dh_command to the
22       rules file. When it would normally run dh_command, dh will instead call
23       that target. The override target can then run the command with
24       additional options, or run entirely different commands instead. See
25       examples below.
26
27       Override targets can also be defined to run only when building
28       architecture dependent or architecture independent packages.  Use
29       targets with names like override_dh_command-arch and
30       override_dh_command-indep.  (Note that to use this feature, you should
31       Build-Depend on debhelper 8.9.7 or above.)
32

OPTIONS

34       --with addon[,addon ...]
35           Add the debhelper commands specified by the given addon to
36           appropriate places in the sequence of commands that is run. This
37           option can be repeated more than once, or multiple addons can be
38           listed, separated by commas.  This is used when there is a third-
39           party package that provides debhelper commands. See the PROGRAMMING
40           file for documentation about the sequence addon interface.
41
42           A Build-Depends relation on the package dh-sequence-addon implies a
43           --with addon. This avoids the need for an explicit --with in
44           debian/rules that only duplicates what is already declared via the
45           build dependencies in debian/control.  The relation can (since
46           12.5) be made optional via e.g.  build-profiles.  This enables you
47           to easily disable an addon that is only useful with certain
48           profiles (e.g. to facilitate bootstraping).
49
50           Since debhelper 12.5, addons can also be activated in indep-only
51           mode (via Build-Depends-Indep) or arch-only mode (via Build-
52           Depends-Arch). Such addons are only active in the particular
53           sequence (e.g. binary-indep) which simplifies dependency management
54           for cross-builds.
55
56           Please note that addons activated via Build-Depends-Indep or Build-
57           Depends-Arch are subject to additional limitations to ensure the
58           result is deterministic even when the addon is unavailable (e.g.
59           during clean).  This implies that some addons are incompatible with
60           these restrictions and can only be used via Build-Depends (or
61           manually via debian/rules).  Currently, such addons can only add
62           commands to sequences.
63
64       --without addon
65           The inverse of --with, disables using the given addon. This option
66           can be repeated more than once, or multiple addons to disable can
67           be listed, separated by commas.
68
69       --list, -l
70           List all available addons.
71
72           When called only with this option, dh can be called from any
73           directory (i.e. it does not need access to files from a source
74           package).
75
76       --no-act
77           Prints commands that would run for a given sequence, but does not
78           run them.
79
80           Note that dh normally skips running commands that it knows will do
81           nothing.  With --no-act, the full list of commands in a sequence is
82           printed.
83
84       Other options passed to dh are passed on to each command it runs. This
85       can be used to set an option like -v or -X or -N, as well as for more
86       specialised options.
87

EXAMPLES

89       To see what commands are included in a sequence, without actually doing
90       anything:
91
92               dh binary-arch --no-act
93
94       This is a very simple rules file, for packages where the default
95       sequences of commands work with no additional options.
96
97               #!/usr/bin/make -f
98               %:
99                       dh $@
100
101       Often you'll want to pass an option to a specific debhelper command.
102       The easy way to do with is by adding an override target for that
103       command.
104
105               #!/usr/bin/make -f
106               %:
107                       dh $@
108
109               override_dh_strip:
110                       dh_strip -Xfoo
111
112               override_dh_auto_configure:
113                       dh_auto_configure -- --with-foo --disable-bar
114
115       Sometimes the automated dh_auto_configure(1) and dh_auto_build(1) can't
116       guess what to do for a strange package. Here's how to avoid running
117       either and instead run your own commands.
118
119               #!/usr/bin/make -f
120               %:
121                       dh $@
122
123               override_dh_auto_configure:
124                       ./mondoconfig
125
126               override_dh_auto_build:
127                       make universe-explode-in-delight
128
129       Another common case is wanting to do something manually before or after
130       a particular debhelper command is run.
131
132               #!/usr/bin/make -f
133               %:
134                       dh $@
135
136               override_dh_fixperms:
137                       dh_fixperms
138                       chmod 4755 debian/foo/usr/bin/foo
139
140       Python tools are not run by dh by default, due to the continual change
141       in that area. Here is how to use dh_python2.
142
143               #!/usr/bin/make -f
144               %:
145                       dh $@ --with python2
146
147       Here is how to force use of Perl's Module::Build build system, which
148       can be necessary if debhelper wrongly detects that the package uses
149       MakeMaker.
150
151               #!/usr/bin/make -f
152               %:
153                       dh $@ --buildsystem=perl_build
154
155       Here is an example of overriding where the dh_auto_* commands find the
156       package's source, for a package where the source is located in a
157       subdirectory.
158
159               #!/usr/bin/make -f
160               %:
161                       dh $@ --sourcedirectory=src
162
163       And here is an example of how to tell the dh_auto_* commands to build
164       in a subdirectory, which will be removed on clean.
165
166               #!/usr/bin/make -f
167               %:
168                       dh $@ --builddirectory=build
169
170       If your package can be built in parallel, please either use compat 10
171       or pass --parallel to dh. Then dpkg-buildpackage -j will work.
172
173               #!/usr/bin/make -f
174               %:
175                       dh $@ --parallel
176
177       If your package cannot be built reliably while using multiple threads,
178       please pass --no-parallel to dh (or the relevant dh_auto_* command):
179
180               #!/usr/bin/make -f
181               %:
182                       dh $@ --no-parallel
183
184       Here is a way to prevent dh from running several commands that you
185       don't want it to run, by defining empty override targets for each
186       command.
187
188               #!/usr/bin/make -f
189               %:
190                       dh $@
191
192               # Commands not to run:
193               override_dh_auto_test override_dh_compress override_dh_fixperms:
194
195       A long build process for a separate documentation package can be
196       separated out using architecture independent overrides.  These will be
197       skipped when running build-arch and binary-arch sequences.
198
199               #!/usr/bin/make -f
200               %:
201                       dh $@
202
203               override_dh_auto_build-indep:
204                       $(MAKE) -C docs
205
206               # No tests needed for docs
207               override_dh_auto_test-indep:
208
209               override_dh_auto_install-indep:
210                       $(MAKE) -C docs install
211
212       Adding to the example above, suppose you need to chmod a file, but only
213       when building the architecture dependent package, as it's not present
214       when building only documentation.
215
216               override_dh_fixperms-arch:
217                       dh_fixperms
218                       chmod 4755 debian/foo/usr/bin/foo
219

INTERNALS

221       If you're curious about dh's internals, here's how it works under the
222       hood.
223
224       In compat 10 (or later), dh creates a stamp file
225       debian/debhelper-build-stamp after the build step(s) are complete to
226       avoid re-running them.  It is possible to avoid the stamp file by
227       passing --without=build-stamp to dh.  This makes "no clean" builds
228       behave more like what some people expect at the expense of possibly
229       running the build and test twice (the second time as root or under
230       fakeroot(1)).
231
232       Inside an override target, dh_* commands will create a log file
233       debian/package.debhelper.log to keep track of which packages the
234       command(s) have been run for.  These log files are then removed once
235       the override target is complete.
236
237       In compat 9 or earlier, each debhelper command will record when it's
238       successfully run in debian/package.debhelper.log. (Which dh_clean
239       deletes.) So dh can tell which commands have already been run, for
240       which packages, and skip running those commands again.
241
242       Each time dh is run (in compat 9 or earlier), it examines the log, and
243       finds the last logged command that is in the specified sequence. It
244       then continues with the next command in the sequence.
245
246       A sequence can also run dependent targets in debian/rules.  For
247       example, the "binary" sequence runs the "install" target.
248
249       dh uses the DH_INTERNAL_OPTIONS environment variable to pass
250       information through to debhelper commands that are run inside override
251       targets. The contents (and indeed, existence) of this environment
252       variable, as the name might suggest, is subject to change at any time.
253
254       Commands in the build-indep, install-indep and binary-indep sequences
255       are passed the -i option to ensure they only work on architecture
256       independent packages, and commands in the build-arch, install-arch and
257       binary-arch sequences are passed the -a option to ensure they only work
258       on architecture dependent packages.
259

SEE ALSO

261       debhelper(7)
262
263       This program is a part of debhelper.
264

AUTHOR

266       Joey Hess <joeyh@debian.org>
267
268
269
27012.6.1                            2019-10-08                             DH(1)
Impressum