3 debhelper - the debhelper tool suite
7 B<dh_>I<*> [B<-v>] [B<-a>] [B<-i>] [B<-s>] [B<--no-act>] [B<-p>I<package>] [B<-N>I<package>] [B<-P>I<tmpdir>]
11 Debhelper is used to help you build a Debian package. The philosophy behind
12 debhelper is to provide a collection of small, simple, and easily
13 understood tools that are used in F<debian/rules> to automate various common
14 aspects of building a package. This means less work for you, the packager.
15 It also, to some degree means that these tools can be changed if Debian
16 policy changes, and packages that use them will require only a rebuild to
17 comply with the new policy.
19 A typical F<debian/rules> file that uses debhelper will call several debhelper
20 commands in sequence, or use L<dh(1)> to automate this process. Examples of
21 rules files that use debhelper are in F</usr/share/doc/debhelper/examples/>
23 To create a new Debian package using debhelper, you can just copy one of
24 the sample rules files and edit it by hand. Or you can try the B<dh-make>
25 package, which contains a L<dh_make|dh_make(1)> command that partially
26 automates the process. For a more gentle introduction, the B<maint-guide> Debian
27 package contains a tutorial about making your first package using debhelper.
29 =head1 DEBHELPER COMMANDS
31 Here is the list of debhelper commands you can use. See their man
32 pages for additional documentation.
40 =head2 Deprecated Commands
42 A few debhelper commands are deprecated and should not be used.
52 If a program's name starts with B<dh_>, and the program is not on the above
53 lists, then it is not part of the debhelper package, but it should still
54 work like the other programs described on this page.
56 =head1 DEBHELPER CONFIG FILES
58 Many debhelper commands make use of files in F<debian/> to control what they
59 do. Besides the common F<debian/changelog> and F<debian/control>, which are
60 in all packages, not just those using debhelper, some additional files can
61 be used to configure the behavior of specific debhelper commands. These
62 files are typically named debian/I<package>.foo (where I<package> of course,
63 is replaced with the package that is being acted on).
65 For example, B<dh_installdocs> uses files named F<debian/package.docs> to list
66 the documentation files it will install. See the man pages of individual
67 commands for details about the names and formats of the files they use.
68 Generally, these files will list files to act on, one file per line. Some
69 programs in debhelper use pairs of files and destinations or slightly more
72 Note that if a package is the first (or only) binary package listed in
73 F<debian/control>, debhelper will use F<debian/foo> if no F<debian/package.foo>
76 In some rare cases, you may want to have different versions of these files
77 for different architectures or OSes. If files named debian/I<package>.foo.I<ARCH>
78 or debian/I<package>.foo.I<OS> exist, where I<ARCH> and I<OS> are the same as the
79 output of "B<dpkg-architecture -qDEB_HOST_ARCH>" /
80 "B<dpkg-architecture -qDEB_HOST_ARCH_OS>",
81 then they will be used in preference to other, more general files.
83 In many cases, these config files are used to specify various types of
84 files. Documentation or example files to install, files to move, and so on.
85 When appropriate, in cases like these, you can use standard shell wildcard
86 characters (B<?> and B<*> and B<[>I<..>B<]> character classes) in the files.
88 You can also put comments in these files; lines beginning with B<#> are
91 =head1 SHARED DEBHELPER OPTIONS
93 The following command line options are supported by all debhelper programs.
97 =item B<-v>, B<--verbose>
99 Verbose mode: show all commands that modify the package build directory.
103 Do not really do anything. If used with -v, the result is that the command
104 will output what it would have done.
106 =item B<-a>, B<--arch>
108 Act on architecture dependent packages that should be built for the
111 =item B<-i>, B<--indep>
113 Act on all architecture independent packages.
115 =item B<-p>I<package>, B<--package=>I<package>
117 Act on the package named I<package>. This option may be specified multiple
118 times to make debhelper operate on a given set of packages.
120 =item B<-s>, B<--same-arch>
122 This used to be a smarter version of the B<-a> flag, but the B<-a> flag is now
125 =item B<-N>I<package>, B<--no-package=>I<package>
127 Do not act on the specified package even if an B<-a>, B<-i>, or B<-p> option lists
128 the package as one that should be acted on.
130 =item B<--remaining-packages>
132 Do not act on the packages which have already been acted on by this debhelper
133 command earlier (i.e. if the command is present in the package debhelper log).
134 For example, if you need to call the command with special options only for a
135 couple of binary packages, pass this option to the last call of the command to
136 process the rest of packages with default settings.
138 =item B<--ignore=>I<file>
140 Ignore the specified file. This can be used if F<debian/> contains a debhelper
141 config file that a debhelper command should not act on. Note that
142 F<debian/compat>, F<debian/control>, and F<debian/changelog> can't be ignored, but
143 then, there should never be a reason to ignore those files.
145 For example, if upstream ships a F<debian/init> that you don't want
146 B<dh_installinit> to install, use B<--ignore=debian/init>
148 =item B<-P>I<tmpdir>, B<--tmpdir=>I<tmpdir>
150 Use I<tmpdir> for package build directory. The default is debian/I<package>
152 =item B<--mainpackage=>I<package>
154 This little-used option changes the package which debhelper considers the
155 "main package", that is, the first one listed in F<debian/control>, and the
156 one for which F<debian/foo> files can be used instead of the usual
157 F<debian/package.foo> files.
159 =item B<-O=>I<option>|I<bundle>
161 This is used by L<dh(1)> when passing user-specified options to all the
162 commands it runs. If the command supports the specified option or option
163 bundle, it will take effect. If the command does not support the option (or
164 any part of an option bundle), it will be ignored.
168 =head1 COMMON DEBHELPER OPTIONS
170 The following command line options are supported by some debhelper programs.
171 See the man page of each program for a complete explanation of what each
178 Do not modify F<postinst>, F<postrm>, etc. scripts.
180 =item B<-X>I<item>, B<--exclude=>I<item>
182 Exclude an item from processing. This option may be used multiple times,
183 to exclude more than one thing.
185 =item B<-A>, B<--all>
187 Makes files or other items that are specified on the command line take effect
188 in ALL packages acted on, not just the first.
192 =head1 BUILD SYSTEM OPTIONS
194 The following command line options are supported by all of the B<dh_auto_>I<*>
195 debhelper programs. These programs support a variety of build systems,
196 and normally heuristically determine which to use, and how to use them.
197 You can use these command line options to override the default behavior.
201 =item B<-S>I<buildsystem>, B<--buildsystem=>I<buildsystem>
203 Force use of the specified I<buildsystem>, instead of trying to auto-select
204 one which might be applicable for the package.
206 =item B<-D>I<directory>, B<--sourcedirectory=>I<directory>
208 Assume that the original package source tree is at the specified
209 I<directory> rather than the top level directory of the Debian
212 =item B<-B>[I<directory>], B<--builddirectory=>[I<directory>]
214 Enable out of source building and use the specified I<directory> as the build
215 directory. If I<directory> parameter is omitted, a default build directory
218 If this option is not specified, building will be done in source by default
219 unless the build system requires or prefers out of source tree building.
220 In such a case, the default build directory will be used even if
221 B<--builddirectory> is not specified.
223 If the build system prefers out of source tree building but still
224 allows in source building, the latter can be re-enabled by passing a build
225 directory path that is the same as the source directory path.
229 Enable parallel builds if underlying build system supports them.
230 The number of parallel jobs is controlled by the
231 B<DEB_BUILD_OPTIONS> environment variable (L<Debian Policy, section 4.9.1>) at
232 build time. It might also be subject to a build system specific limit.
234 If this option is not specified, debhelper currently defaults to not
235 allowing parallel package builds.
237 =item B<--max-parallel=>I<maximum>
239 This option implies B<--parallel> and allows further limiting the number of
240 jobs that can be used in a parallel build. If the package build is known to
241 only work with certain levels of concurrency, you can set this to the maximum
242 level that is known to work, or that you wish to support.
244 =item B<--list>, B<-l>
246 List all build systems supported by debhelper on this system. The list
247 includes both default and third party build systems (marked as such). Also
248 shows which build system would be automatically selected, or which one
249 is manually specified with the B<--buildsystem> option.
253 =head1 COMPATABILITY LEVELS
255 From time to time, major non-backwards-compatible changes need to be made
256 to debhelper, to keep it clean and well-designed as needs change and its
257 author gains more experience. To prevent such major changes from breaking
258 existing packages, the concept of debhelper compatibility levels was
259 introduced. You tell debhelper which compatibility level it should use, and
260 it modifies its behavior in various ways.
262 Tell debhelper what compatibility level to use by writing a number to
263 F<debian/compat>. For example, to turn on v8 mode:
265 % echo 8 > debian/compat
267 Unless otherwise indicated, all debhelper documentation assumes that you
268 are using the most recent compatibility level, and in most cases does not
269 indicate if the behavior is different in an earlier compatibility level, so
270 if you are not using the most recent compatibility level, you're advised to
271 read below for notes about what is different in earlier compatibility
274 These are the available compatibility levels:
280 This is the original debhelper compatibility level, and so it is the default
281 one. In this mode, debhelper will use F<debian/tmp> as the package tree
282 directory for the first binary package listed in the control file, while using
283 debian/I<package> for all other packages listed in the F<control> file.
285 This mode is deprecated.
289 In this mode, debhelper will consistently use debian/I<package>
290 as the package tree directory for every package that is built.
292 This mode is deprecated.
296 This mode works like v2, with the following additions:
302 Debhelper config files support globbing via B<*> and B<?>, when appropriate. To
303 turn this off and use those characters raw, just prefix with a backslash.
307 B<dh_makeshlibs> makes the F<postinst> and F<postrm> scripts call B<ldconfig>.
311 Every file in F<etc/> is automatically flagged as a conffile by B<dh_installdeb>.
315 This mode is deprecated.
325 B<dh_makeshlibs -V> will not include the Debian part of the version number in
326 the generated dependency line in the shlibs file.
330 You are encouraged to put the new B<${misc:Depends}> into F<debian/control> to
331 supplement the B<${shlibs:Depends}> field.
335 B<dh_fixperms> will make all files in F<bin/> directories and in F<etc/init.d>
340 B<dh_link> will correct existing links to conform with policy.
344 This mode is deprecated.
354 Comments are ignored in debhelper config files.
358 B<dh_strip --dbg-package> now specifies the name of a package to put debugging
359 symbols in, not the packages to take the symbols from.
363 B<dh_installdocs> skips installing empty files.
367 B<dh_install> errors out if wildcards expand to nothing.
379 Commands that generate maintainer script fragments will order the
380 fragments in reverse order for the F<prerm> and F<postrm> scripts.
384 B<dh_installwm> will install a slave manpage link for F<x-window-manager.1.gz>,
385 if it sees the man page in F<usr/share/man/man1> in the package build
390 B<dh_builddeb> did not previously delete everything matching
391 B<DH_ALWAYS_EXCLUDE>, if it was set to a list of things to exclude, such as
392 B<CVS:.svn:.git>. Now it does.
396 B<dh_installman> allows overwriting existing man pages in the package build
397 directory. In previous compatibility levels it silently refuses to do this.
409 B<dh_install>, will fall back to looking for files in F<debian/tmp> if it doesn't
410 find them in the current directory (or wherever you tell it look using
411 B<--sourcedir>). This allows B<dh_install> to interoperate with B<dh_auto_install>,
412 which installs to F<debian/tmp>, without needing any special parameters.
416 B<dh_clean> will read F<debian/clean> and delete files listed there.
420 B<dh_clean> will delete toplevel F<*-stamp> files.
424 B<dh_installchangelogs> will guess at what file is the upstream changelog if
431 This is the recommended mode of operation.
439 Commands will fail rather than warning when they are passed unknown options.
443 B<dh_makeshlibs> will run B<dpkg-gensymbols> on all shared libraries that it
444 generates shlibs files for. So B<-X> can be used to exclude libraries.
445 Also, libraries in unusual locations that B<dpkg-gensymbols> would not
446 have processed before will be passed to it, a behavior change that
447 can cause some packages to fail to build.
451 B<dh> requires the sequence to run be specified as the first parameter, and
452 any switches come after it. Ie, use "B<dh $@ --foo>", not "B<dh --foo $@>".
456 B<dh_auto_>I<*> prefer to use Perl's B<Module::Build> in preference to F<Makefile.PL>.
462 This compatibility level is still open for development; use with caution.
470 Multiarch support. In particular, B<dh_auto_configure> passes
471 multiarch directories to autoconf in --libdir and --libexecdir.
475 dh allows defining custom build, build-arch, and build-indep targets
476 in debian/rules, without needing to manually define the other targets
481 B<dh_auto_configure> does not include the source package name
482 in --libexecdir when using autoconf.
486 B<dh> does not default to enabling --with=python-support
490 All of the B<dh_auto_>I<*> debhelper programs and B<dh> set
491 environment variables listed by B<dpkg-buildflags>, unless
492 they are already set. They support DEB_BUILD_OPTIONS=noopt too.
500 =head2 Multiple binary package support
502 If your source package generates more than one binary package, debhelper
503 programs will default to acting on all binary packages when run. If your
504 source package happens to generate one architecture dependent package, and
505 another architecture independent package, this is not the correct behavior,
506 because you need to generate the architecture dependent packages in the
507 binary-arch F<debian/rules> target, and the architecture independent packages
508 in the binary-indep F<debian/rules> target.
510 To facilitate this, as well as give you more control over which packages
511 are acted on by debhelper programs, all debhelper programs accept the
512 B<-a>, B<-i>, B<-p>, and B<-s> parameters. These parameters are cumulative.
513 If none are given, debhelper programs default to acting on all packages listed
516 =head2 Automatic generation of Debian install scripts
518 Some debhelper commands will automatically generate parts of Debian
519 maintainer scripts. If you want these automatically generated things
520 included in your existing Debian maintainer scripts, then you need to add
521 B<#DEBHELPER#> to your scripts, in the place the code should be added.
522 B<#DEBHELPER#> will be replaced by any auto-generated code when you run
525 If a script does not exist at all and debhelper needs to add something to
526 it, then debhelper will create the complete script.
528 All debhelper commands that automatically generate code in this way let it
529 be disabled by the -n parameter (see above).
531 Note that the inserted code will be shell code, so you cannot directly use
532 it in a Perl script. If you would like to embed it into a Perl script, here
533 is one way to do that (note that I made sure that $1, $2, etc are set with
536 my $temp="set -e\nset -- @ARGV\n" . << 'EOF';
539 system ($temp) / 256 == 0
540 or die "Problem with debhelper scripts: $!";
542 =head2 Automatic generation of miscellaneous dependencies.
544 Some debhelper commands may make the generated package need to depend on
545 some other packages. For example, if you use L<dh_installdebconf(1)>, your
546 package will generally need to depend on debconf. Or if you use
547 L<dh_installxfonts(1)>, your package will generally need to depend on a
548 particular version of xutils. Keeping track of these miscellaneous
549 dependencies can be annoying since they are dependent on how debhelper does
550 things, so debhelper offers a way to automate it.
552 All commands of this type, besides documenting what dependencies may be
553 needed on their man pages, will automatically generate a substvar called
554 B<${misc:Depends}>. If you put that token into your F<debian/control> file, it
555 will be expanded to the dependencies debhelper figures you need.
557 This is entirely independent of the standard B<${shlibs:Depends}> generated by
558 L<dh_makeshlibs(1)>, and the B<${perl:Depends}> generated by L<dh_perl(1)>.
559 You can choose not to use any of these, if debhelper's guesses don't match
562 =head2 Package build directories
564 By default, all debhelper programs assume that the temporary directory used
565 for assembling the tree of files in a package is debian/I<package>.
567 Sometimes, you might want to use some other temporary directory. This is
568 supported by the B<-P> flag. For example, "B<dh_installdocs -Pdebian/tmp>", will
569 use B<debian/tmp> as the temporary directory. Note that if you use B<-P>, the
570 debhelper programs can only be acting on a single package at a time. So if
571 you have a package that builds many binary packages, you will need to also
572 use the B<-p> flag to specify which binary package the debhelper program will
577 Debhelper includes support for udebs. To create a udeb with debhelper,
578 add "B<Package-Type: udeb>" to the package's stanza in F<debian/control>, and
579 build-depend on debhelper (>= 4.2). Debhelper will try to create udebs that
580 comply with debian-installer policy, by making the generated package files
581 end in F<.udeb>, not installing any documentation into a udeb, skipping over
582 F<preinst>, F<postrm>, F<prerm>, and F<config> scripts, etc.
586 Once your package uses debhelper to build, be sure to add
587 debhelper to your Build-Depends line in F<debian/control>. You should
588 build-depend on a version of debhelper equal to (or greater than) the
589 debhelper compatibility level your package uses. So if your package used
590 compatibility level 7:
592 Build-Depends: debhelper (>= 7)
600 Set to B<1> to enable verbose mode. Debhelper will output every command it runs
601 that modifies files on the build system.
605 Temporarily specifies what compatibility level debhelper should run at,
606 overriding any value in F<debian/compat>.
610 Set to B<1> to enable no-act mode.
614 Anything in this variable will be prepended to the command line arguments
615 of all debhelper commands. Command-specific options will be ignored by
616 commands that do not support them.
618 This is useful in some situations, for example, if you need to pass B<-p> to
619 all debhelper commands that will be run. One good way to set B<DH_OPTIONS> is
620 by using "Target-specific Variable Values" in your F<debian/rules> file. See
621 the make documentation for details on doing this.
623 =item B<DH_ALWAYS_EXCLUDE>
625 If set, this adds the value the variable is set to to the B<-X> options of all
626 commands that support the B<-X> option. Moreover, B<dh_builddeb> will B<rm -rf>
627 anything that matches the value in your package build tree.
629 This can be useful if you are doing a build from a CVS source tree, in
630 which case setting B<DH_ALWAYS_EXCLUDE=CVS> will prevent any CVS directories
631 from sneaking into the package you build. Or, if a package has a source
632 tarball that (unwisely) includes CVS directories, you might want to export
633 B<DH_ALWAYS_EXCLUDE=CVS> in F<debian/rules>, to make it take effect wherever
634 your package is built.
636 Multiple things to exclude can be separated with colons, as in
637 B<DH_ALWAYS_EXCLUDE=CVS:.svn>
645 =item F</usr/share/doc/debhelper/examples/>
647 A set of example F<debian/rules> files that use debhelper.
649 =item L<http://kitenet.net/~joey/code/debhelper/>
657 Joey Hess <joeyh@debian.org>