~ubuntu-branches/ubuntu/natty/debhelper/natty

« back to all changes in this revision

Viewing changes to dh

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess, Joey Hess, Valery Perrin
  • Date: 2011-02-05 12:00:04 UTC
  • mto: This revision was merged to the branch mainline in revision 66.
  • Revision ID: james.westby@ubuntu.com-20110205120004-9ayvm0q0xe2yl0hx
Tags: 8.1.0
[ Joey Hess ]
* python_distutils: Pass --force to setup.py build, to ensure that when
  python-dbg is run it does not win and result in scripts having it in
  the shebang line. Closes: #589759
* Man page fixes about what program -u passes params to. Closes: #593342
* Avoid open fd 5 or 6 breaking buildsystem test suite. Closes: #596679
* Large update to Spanish man page translations by Omar Campagne.
  Closes: #600913
* dh_installdeb: Support debian/package.maintscript files,
  which can contain dpkg-maintscript-helper commands. This can be used
  to automate moving or removing conffiles, or anything added to
  dpkg-maintscript-helper later on. Closes: #574443
  (Thanks, Colin Watson)
* Massive man page typography patch. Closes: #600883
  (Thanks, David Prévot)
* Explicitly build-depend on a new enough perl-base. Closes: #601188
* dh: Inhibit logging when an override target runs the overridden command,
  to avoid unexpected behavior if the command succeeded but the overall
  target fails. Closes: #601037
* Fix deprecated command list on translated debhelper(7) man pages.
  Closes: #601204
* dh: Improve filtering in dh_listpackages example. Closes: #604561
* dh: Add support for build-arch, build-indep, install-arch and
  install-indep sequences. Closes: #604563
  (Thanks, Roger Leigh)
* dh_listpackages: Do not display warnings if options cause no packages
  to be listed.
* dh_installdocs: Clarify that debian/README.Debian and debian/TODO are
  only installed into the first package listed in debian/control.
  Closes: #606036
* dh_compress: Javascript files are not compressed, as these go with
  (uncompressed) html files. Closes: #603553
* dh_compress: Ignore objects.inv files, generated by Sphinx documentation.
  Closes: #608907
* dh_installinit: never call init scripts directly, only through invoke-rc.d
  Closes: #610340
  (Thanks, Steve Langasek)

[ Valery Perrin ]
* update french translation.
* Fix french misspelling.
* French translation update after massive man page typography 

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
=head1 SYNOPSIS
13
13
 
14
 
B<dh> sequence [B<--with> I<addon>[,I<addon>,...]] [B<--list>] [B<--until> I<cmd>] [B<--before> I<cmd>] [B<--after> I<cmd>] [B<--remaining>] [S<I<debhelper options>>]
 
14
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>>]
15
15
 
16
16
=head1 DESCRIPTION
17
17
 
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".
21
 
 
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.
26
 
 
27
 
If debian/rules contains a target with a name like "override_I<dh_command>",
28
 
then when it would normally run I<dh_command>, dh will instead call that
 
18
B<dh> runs a sequence of debhelper commands. The supported I<sequence>s
 
19
correspond to the targets of a F<debian/rules> file: B<build-arch>,
 
20
B<build-indep>, B<build>, B<clean>, B<install-indep>, B<install-arch>,
 
21
B<install>, B<binary-arch>, B<binary-indep>, and B<binary>.
 
22
 
 
23
Commands in the B<build-indep>, B<install-indep> and B<binary-indep>
 
24
sequences are passed the B<-i> option to ensure they only work on
 
25
architecture independent packages, and commands in the B<build-arch>,
 
26
B<install-arch> and B<binary-arch> sequences are passed the B<-a>
 
27
option to ensure they only work on architecture dependent packages.
 
28
 
 
29
If F<debian/rules> contains a target with a name like B<override_>I<dh_command>,
 
30
then when it would normally run I<dh_command>, B<dh> will instead call that
29
31
target. The override target can then run the command with additional options,
30
32
or run entirely different commands instead. See examples below. (Note that to
31
33
use this feature, you should Build-Depend on debhelper 7.0.50 or above.)
34
36
 
35
37
=over 4
36
38
 
37
 
=item B<--with> I<addon>[,I<addon>,...]
 
39
=item B<--with> I<addon>[B<,>I<addon> ...]
38
40
 
39
41
Add the debhelper commands specified by the given addon to appropriate places
40
42
in the sequence of commands that is run. This option can be repeated more
41
43
than once, or multiple addons can be listed, separated by commas.
42
44
This is used when there is a third-party package that provides
43
 
debhelper commands. See the PROGRAMMING file for documentation about
 
45
debhelper commands. See the F<PROGRAMMING> file for documentation about
44
46
the sequence addon interface.
45
47
 
46
48
=item B<--without> I<addon>
47
49
 
48
 
The inverse of --with, disables using the given addon.
 
50
The inverse of B<--with>, disables using the given addon.
49
51
 
50
52
=item B<--list>, B<-l>
51
53
 
73
75
 
74
76
=back
75
77
 
76
 
All other options passed to dh are passed on to each command it runs. This
77
 
can be used to set an option like "-v" or "-X" or "-N", as well as for more
 
78
All other options passed to B<dh> are passed on to each command it runs. This
 
79
can be used to set an option like B<-v> or B<-X> or B<-N>, as well as for more
78
80
specialised options.
79
81
 
80
82
In the above options, I<cmd> can be a full name of a debhelper command, or
160
162
                dh_fixperms
161
163
                chmod 4755 debian/foo/usr/bin/foo
162
164
 
163
 
If your package is a python package, dh will use dh_pysupport by
164
 
default. This is how to use dh_pycentral instead.
 
165
If your package is a Python package, B<dh> will use B<dh_pysupport> by
 
166
default. This is how to use B<dh_pycentral> instead.
165
167
 
166
168
        #!/usr/bin/make -f
167
169
        %:
168
170
                dh $@ --with python-central
169
171
 
170
 
If your package uses autotools and you want to freshen config.sub and
171
 
config.guess with newer versions from the autotools-dev package
172
 
at build time, you can use some commands provided in autotools-dev
 
172
If your package uses autotools and you want to freshen F<config.sub> and
 
173
F<config.guess> with newer versions from the B<autotools-dev> package
 
174
at build time, you can use some commands provided in B<autotools-dev>
173
175
that automate it, like this.
174
176
 
175
177
        #!/usr/bin/make -f
176
178
        %:
177
179
                dh $@ --with autotools_dev
178
180
 
179
 
Here is how to force use of perl's Module::Build build system,
 
181
Here is how to force use of Perl's B<Module::Build> build system,
180
182
which can be necessary if debhelper wrongly detects that the package
181
183
uses MakeMaker.
182
184
 
184
186
        %:
185
187
                dh $@ --buildsystem=perl_build
186
188
 
187
 
To patch your package using quilt, you can tell dh to use quilt's dh
 
189
To patch your package using quilt, you can tell B<dh> to use quilt's B<dh>
188
190
sequence addons like this:
189
191
        
190
192
        #!/usr/bin/make -f
191
193
        %:
192
194
                dh $@ --with quilt
193
195
 
194
 
Here is an example of overriding where the dh_auto_* commands find
 
196
Here is an example of overriding where the B<dh_auto_>I<*> commands find
195
197
the package's source, for a package where the source is located in a
196
198
subdirectory.
197
199
 
199
201
        %:
200
202
                dh $@ --sourcedirectory=src
201
203
 
202
 
And here is an example of how to tell the dh_auto_* commands to build
203
 
in a subdirectory, which will be removed on clean.
 
204
And here is an example of how to tell the B<dh_auto_>I<*> commands to build
 
205
in a subdirectory, which will be removed on B<clean>.
204
206
 
205
207
        #!/usr/bin/make -f
206
208
        %:
207
209
                dh $@ --builddirectory=build
208
210
 
209
211
If your package can be built in parallel, you can support parallel building
210
 
as follows. Then I<dpkg-buildpackage -j> will work.
 
212
as follows. Then B<dpkg-buildpackage -j> will work.
211
213
 
212
214
        #!/usr/bin/make -f
213
215
        %:
214
216
                dh $@ --parallel
215
217
 
216
 
Here is a way to prevent dh from running several commands that you don't
 
218
Here is a way to prevent B<dh> from running several commands that you don't
217
219
want it to run, by defining empty override targets for each command.
218
220
 
219
221
        #!/usr/bin/make -f
233
235
        
234
236
        override_dh_fixperms:
235
237
                dh_fixperms
236
 
        ifneq (,$(findstring foo, $(shell dh_listpackages)))
 
238
        ifneq (,$(filter foo, $(shell dh_listpackages)))
237
239
                chmod 4755 debian/foo/usr/bin/foo
238
240
        endif
239
241
 
240
242
Finally, remember that you are not limited to using override targets in the
241
 
rules file when using dh. You can also explicitly define any of the regular
 
243
rules file when using B<dh>. You can also explicitly define any of the regular
242
244
rules file targets when it makes sense to do so. A common reason to do this
243
 
is if your package needs different build-arch and build-indep targets. For
 
245
is if your package needs different B<build-arch> and B<build-indep> targets. For
244
246
example, a package with a long document build process can put it in
245
 
build-indep to avoid build daemons redundantly building the documentation.
 
247
B<build-indep> to avoid build daemons redundantly building the documentation.
246
248
 
247
249
        #!/usr/bin/make -f
248
250
        %:
256
258
 
257
259
=head1 INTERNALS
258
260
 
259
 
If you're curious about dh's internals, here's how it works under the hood.
 
261
If you're curious about B<dh>'s internals, here's how it works under the hood.
260
262
 
261
263
Each debhelper command will record when it's successfully run in
262
 
debian/package.debhelper.log. (Which dh_clean deletes.) So dh can tell
 
264
F<debian/package.debhelper.log>. (Which B<dh_clean> deletes.) So B<dh> can tell
263
265
which commands have already been run, for which packages, and skip running
264
266
those commands again.
265
267
 
266
 
Each time dh is run, it examines the log, and finds the last logged command
 
268
Each time B<dh> is run, it examines the log, and finds the last logged command
267
269
that is in the specified sequence. It then continues with the next command
268
270
in the sequence. The B<--until>, B<--before>, B<--after>, and B<--remaining>
269
271
options can override this behavior.
270
272
 
271
 
dh uses the DH_INTERNAL_OPTIONS environment variable to pass information
 
273
B<dh> uses the B<DH_INTERNAL_OPTIONS> environment variable to pass information
272
274
through to debhelper commands that are run inside override targets. The
273
275
contents (and indeed, existence) of this environment variable, as the name
274
276
might suggest, is subject to change at any time.
322
324
        dh_auto_build
323
325
        dh_auto_test
324
326
}],
 
327
$sequences{'build-indep'} = [@{$sequences{build}}];
 
328
$sequences{'build-arch'} = [@{$sequences{build}}];
325
329
$sequences{clean} = [qw{
326
330
        dh_testdir
327
331
        dh_auto_clean
328
332
        dh_clean
329
333
}];
330
 
$sequences{install} = [@{$sequences{build}}, qw{
 
334
my @i = qw{
331
335
        dh_testroot
332
336
        dh_prep
333
337
        dh_installdirs
366
370
        dh_link
367
371
        dh_compress
368
372
        dh_fixperms
369
 
}];
 
373
};
 
374
$sequences{'install'} = [@{$sequences{build}}, @i];
 
375
$sequences{'install-indep'} = [@{$sequences{'build-indep'}}, @i];
 
376
$sequences{'install-arch'} = [@{$sequences{'build-arch'}}, @i];
 
377
my @ba=qw{
 
378
        dh_strip
 
379
        dh_makeshlibs
 
380
        dh_shlibdeps
 
381
};
370
382
my @b=qw{
371
383
        dh_installdeb
372
384
        dh_gencontrol
373
385
        dh_md5sums
374
386
        dh_builddeb
375
387
};
376
 
$sequences{'binary-indep'} = [@{$sequences{install}}, @b];
377
 
$sequences{binary} = [@{$sequences{install}}, qw{
378
 
        dh_strip
379
 
        dh_makeshlibs
380
 
        dh_shlibdeps
381
 
}, @b];
382
 
$sequences{'binary-arch'} = [@{$sequences{binary}}];
 
388
$sequences{binary} = [@{$sequences{install}}, @ba, @b];
 
389
$sequences{'binary-indep'} = [@{$sequences{'install-indep'}}, @b];
 
390
$sequences{'binary-arch'} = [@{$sequences{'install-arch'}}, @ba, @b];
383
391
 
384
392
# Additional command options
385
393
my %command_opts;
514
522
# Get the options to pass to commands in the sequence.
515
523
# Filter out options intended only for this program.
516
524
my @options;
517
 
if ($sequence eq 'binary-arch') {
 
525
if ($sequence eq 'build-arch' ||
 
526
    $sequence eq 'install-arch' ||
 
527
    $sequence eq 'binary-arch') {
518
528
        push @options, "-a";
519
529
        # as an optimisation, remove from the list any packages
520
530
        # that are not arch dependent
521
531
        my %arch_packages = map { $_ => 1 } getpackages("arch");
522
532
        @packages = grep { $arch_packages{$_} } @packages;
523
533
}
524
 
elsif ($sequence eq 'binary-indep') {
 
534
elsif ($sequence eq 'build-indep' ||
 
535
       $sequence eq 'install-indep' ||
 
536
       $sequence eq 'binary-indep') {
525
537
        push @options, "-i";
526
538
        # ditto optimisation for arch indep
527
539
        my %indep_packages = map { $_ => 1 } getpackages("indep");
635
647
                        # This passes the options through to commands called
636
648
                        # inside the target.
637
649
                        $ENV{DH_INTERNAL_OPTIONS}=join("\x1e", @options);
 
650
                        # Prevent commands called inside the target from
 
651
                        # logging.
 
652
                        $ENV{DH_INHIBIT_LOG}=$command;
638
653
                        $command="debian/rules";
639
654
                        @options="override_".$override_command;
640
655
                }
669
684
 
670
685
                if (defined $override_command) {
671
686
                        delete $ENV{DH_INTERNAL_OPTIONS};
672
 
                        # Need to handle logging for overriden commands here,
673
 
                        # because the actual debhelper command may not have
674
 
                        # been run by the rules file target.
 
687
                        delete $ENV{DH_INHIBIT_LOG};
 
688
                        # Update log for overridden command now that it has
 
689
                        # finished successfully.
675
690
                        # (But avoid logging for dh_clean since it removes
676
691
                        # the log earlier.)
677
692
                        if ($override_command ne 'dh_clean') {