1DH(1) Debhelper DH(1)
2
3
4
6 dh - debhelper command sequencer
7
9 dh sequence [--with addon[,addon ...]] [--list] [debhelperĀ options]
10
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
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
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. Note that only relations in
46 the Build-Depends field are considered (i.e. Build-Depends-Indep
47 and Build-Depends-Arch are deliberately unsupported). Please keep
48 in mind that dh insists on "simple" relations (e.g. a relation like
49 "dh-sequence-addon | some-other-pkg" will not imply --with addon).
50
51 --without addon
52 The inverse of --with, disables using the given addon. This option
53 can be repeated more than once, or multiple addons to disable can
54 be listed, separated by commas.
55
56 --list, -l
57 List all available addons.
58
59 When called only with this option, dh can be called from any
60 directory (i.e. it does not need access to files from a source
61 package).
62
63 --no-act
64 Prints commands that would run for a given sequence, but does not
65 run them.
66
67 Note that dh normally skips running commands that it knows will do
68 nothing. With --no-act, the full list of commands in a sequence is
69 printed.
70
71 Other options passed to dh are passed on to each command it runs. This
72 can be used to set an option like -v or -X or -N, as well as for more
73 specialised options.
74
76 To see what commands are included in a sequence, without actually doing
77 anything:
78
79 dh binary-arch --no-act
80
81 This is a very simple rules file, for packages where the default
82 sequences of commands work with no additional options.
83
84 #!/usr/bin/make -f
85 %:
86 dh $@
87
88 Often you'll want to pass an option to a specific debhelper command.
89 The easy way to do with is by adding an override target for that
90 command.
91
92 #!/usr/bin/make -f
93 %:
94 dh $@
95
96 override_dh_strip:
97 dh_strip -Xfoo
98
99 override_dh_auto_configure:
100 dh_auto_configure -- --with-foo --disable-bar
101
102 Sometimes the automated dh_auto_configure(1) and dh_auto_build(1) can't
103 guess what to do for a strange package. Here's how to avoid running
104 either and instead run your own commands.
105
106 #!/usr/bin/make -f
107 %:
108 dh $@
109
110 override_dh_auto_configure:
111 ./mondoconfig
112
113 override_dh_auto_build:
114 make universe-explode-in-delight
115
116 Another common case is wanting to do something manually before or after
117 a particular debhelper command is run.
118
119 #!/usr/bin/make -f
120 %:
121 dh $@
122
123 override_dh_fixperms:
124 dh_fixperms
125 chmod 4755 debian/foo/usr/bin/foo
126
127 Python tools are not run by dh by default, due to the continual change
128 in that area. Here is how to use dh_python2.
129
130 #!/usr/bin/make -f
131 %:
132 dh $@ --with python2
133
134 Here is how to force use of Perl's Module::Build build system, which
135 can be necessary if debhelper wrongly detects that the package uses
136 MakeMaker.
137
138 #!/usr/bin/make -f
139 %:
140 dh $@ --buildsystem=perl_build
141
142 Here is an example of overriding where the dh_auto_* commands find the
143 package's source, for a package where the source is located in a
144 subdirectory.
145
146 #!/usr/bin/make -f
147 %:
148 dh $@ --sourcedirectory=src
149
150 And here is an example of how to tell the dh_auto_* commands to build
151 in a subdirectory, which will be removed on clean.
152
153 #!/usr/bin/make -f
154 %:
155 dh $@ --builddirectory=build
156
157 If your package can be built in parallel, please either use compat 10
158 or pass --parallel to dh. Then dpkg-buildpackage -j will work.
159
160 #!/usr/bin/make -f
161 %:
162 dh $@ --parallel
163
164 If your package cannot be built reliably while using multiple threads,
165 please pass --no-parallel to dh (or the relevant dh_auto_* command):
166
167 #!/usr/bin/make -f
168 %:
169 dh $@ --no-parallel
170
171 Here is a way to prevent dh from running several commands that you
172 don't want it to run, by defining empty override targets for each
173 command.
174
175 #!/usr/bin/make -f
176 %:
177 dh $@
178
179 # Commands not to run:
180 override_dh_auto_test override_dh_compress override_dh_fixperms:
181
182 A long build process for a separate documentation package can be
183 separated out using architecture independent overrides. These will be
184 skipped when running build-arch and binary-arch sequences.
185
186 #!/usr/bin/make -f
187 %:
188 dh $@
189
190 override_dh_auto_build-indep:
191 $(MAKE) -C docs
192
193 # No tests needed for docs
194 override_dh_auto_test-indep:
195
196 override_dh_auto_install-indep:
197 $(MAKE) -C docs install
198
199 Adding to the example above, suppose you need to chmod a file, but only
200 when building the architecture dependent package, as it's not present
201 when building only documentation.
202
203 override_dh_fixperms-arch:
204 dh_fixperms
205 chmod 4755 debian/foo/usr/bin/foo
206
208 If you're curious about dh's internals, here's how it works under the
209 hood.
210
211 In compat 10 (or later), dh creates a stamp file
212 debian/debhelper-build-stamp after the build step(s) are complete to
213 avoid re-running them. It is possible to avoid the stamp file by
214 passing --without=build-stamp to dh. This makes "no clean" builds
215 behave more like what some people expect at the expense of possibly
216 running the build and test twice (the second time as root or under
217 fakeroot(1)).
218
219 Inside an override target, dh_* commands will create a log file
220 debian/package.debhelper.log to keep track of which packages the
221 command(s) have been run for. These log files are then removed once
222 the override target is complete.
223
224 In compat 9 or earlier, each debhelper command will record when it's
225 successfully run in debian/package.debhelper.log. (Which dh_clean
226 deletes.) So dh can tell which commands have already been run, for
227 which packages, and skip running those commands again.
228
229 Each time dh is run (in compat 9 or earlier), it examines the log, and
230 finds the last logged command that is in the specified sequence. It
231 then continues with the next command in the sequence. The --until,
232 --before, --after, and --remaining options can override this behavior
233 (though they were removed in compat 10).
234
235 A sequence can also run dependent targets in debian/rules. For
236 example, the "binary" sequence runs the "install" target.
237
238 dh uses the DH_INTERNAL_OPTIONS environment variable to pass
239 information through to debhelper commands that are run inside override
240 targets. The contents (and indeed, existence) of this environment
241 variable, as the name might suggest, is subject to change at any time.
242
243 Commands in the build-indep, install-indep and binary-indep sequences
244 are passed the -i option to ensure they only work on architecture
245 independent packages, and commands in the build-arch, install-arch and
246 binary-arch sequences are passed the -a option to ensure they only work
247 on architecture dependent packages.
248
250 The following options are deprecated. It's much better to use override
251 targets instead. They are not available in compat 10.
252
253 --until cmd
254 Run commands in the sequence until and including cmd, then stop.
255
256 --before cmd
257 Run commands in the sequence before cmd, then stop.
258
259 --after cmd
260 Run commands in the sequence that come after cmd.
261
262 --remaining
263 Run all commands in the sequence that have yet to be run.
264
265 In the above options, cmd can be a full name of a debhelper command, or
266 a substring. It'll first search for a command in the sequence exactly
267 matching the name, to avoid any ambiguity. If there are multiple
268 substring matches, the last one in the sequence will be used.
269
271 debhelper(7)
272
273 This program is a part of debhelper.
274
276 Joey Hess <joeyh@debian.org>
277
278
279
28011.4 2018-09-14 DH(1)