On Sat, Jun 11, 2011 at 08:33:19PM -0400, Joey Hess wrote:
> Roger Leigh wrote:
> > +my @bd = qw{
> > dh_testdir
> > dh_auto_configure
> > dh_auto_build
> > dh_auto_test
> > -}],
> > -$sequences{'build-indep'} = [@{$sequences{build}}];
> > -$sequences{'build-arch'} = [@{$sequences{build}}];
> > +};
> > +$sequences{build} = [@bd, 'rules:build-arch', 'rules:build-indep'];
> > +$sequences{'build-indep'} = [@bd];
> > +$sequences{'build-arch'} = [@bd];
>
> So, this business of running the build-arch and build-indep only after
> running @bd, so that it only configures once, is a brilliant hack.
> Probably should be commented.
Done in the attached patch. Note that if you call
build-arch and build-indep separately, it will still potentially
configure twice, and in this situation you'll still need a
stamp file.
> > +$sequences{binary} = ['rules:install', @ba, @b, 'rules:binary-arch',
> > 'rules:binary-indep'];
> > +$sequences{'binary-indep'} = ['rules:install-indep', @b];
> > +$sequences{'binary-arch'} = ['rules:install-arch', @ba, @b];
>
> The continutation of it here worries me, in particular it
> seems that a binary-arch or binary-indep rule is only run after
> the deb is already built, and so will anything it tries
> to do to influence the build will not happen when running debian/rules binary
> (but will if running debian/rules binary-arch).
Good point. In the attached patch I've retained the scheme for
the build and install targets, where it serves a purpose, and
dropped it for binary.
I also added "$override_command=$command;" to the block
"if (defined $rules_target) {" which causes the rules:foo
command to go into the debhelper.log file; this is a simple
optimisation which will prevent the rule being invoked
multiple times as for other dh_ commands, without the need
for stamp files. This was mostly unnecessary due to the
fact that the rules were generally at the beginning of the
sequence and were automatically skipped anyway, but it
does mean you don't have repeated invocation of rules at
the end of the sequence when called recursively.
Regards,
Roger
--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.
From 8af32fa5d0cdb5d34729c204c1c949950fb5e844 Mon Sep 17 00:00:00 2001 From: Roger Leigh <[email protected]> Date: Fri, 3 Jun 2011 20:41:30 +0100 Subject: [PATCH] dh: Add sequence dependency support Rather than dh sequences containing dependent sequences within themselves, invoke the sub-sequence via debian/rules to permit overriding and customisation using the policy-defined debian/rules targets. Signed-off-by: Roger Leigh <[email protected]> --- dh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 60 insertions(+), 11 deletions(-) diff --git a/dh b/dh index 50e0f14..8e5cc05 100755 --- a/dh +++ b/dh @@ -151,6 +151,16 @@ either and instead run your own commands. override_dh_auto_build: make universe-explode-in-delight +If running a configure script, it may be necessary to prevent it being +run twice, once for architecture-independent packages, and again for +architecture-dependent packages. This may be accomplished by +overriding L<dh_autoconfigure(1)>: + + override_dh_auto_configure: config.status + + config.status: + dh_auto_configure -- $configure_options + Another common case is wanting to do something manually before or after a particular debhelper command is run. @@ -273,6 +283,13 @@ that is in the specified sequence. It then continues with the next command in the sequence. The B<--until>, B<--before>, B<--after>, and B<--remaining> options can override this behavior. +A sequence can also run dependent targets in debian/rules. For +example, the "binary" sequence runs the "install" target. This will +show up in the dh output as "debian/rules install", but internally +will be called "rules:install" in the sequence. The "install" +sequence likewise runs "debian/rules build", internally named +"rules:build". + B<dh> uses the B<DH_INTERNAL_OPTIONS> environment variable to pass information through to debhelper commands that are run inside override targets. The contents (and indeed, existence) of this environment variable, as the name @@ -321,14 +338,20 @@ if (is_make_jobserver_unavailable()) { # Definitions of sequences. my %sequences; -$sequences{build} = [qw{ +my @bd = qw{ dh_testdir dh_auto_configure dh_auto_build dh_auto_test -}], -$sequences{'build-indep'} = [@{$sequences{build}}]; -$sequences{'build-arch'} = [@{$sequences{build}}]; +}; +# The build sequences will call 'debian/rules build-arch' and +# 'debian/rules build-indep' after running the standard sequence; +# these will typically be no-ops but this permits the standard targets +# to be customised by the user and still run as a side-effect of the +# build target. +$sequences{build} = [@bd, 'rules:build-arch', 'rules:build-indep']; +$sequences{'build-indep'} = [@bd]; +$sequences{'build-arch'} = [@bd]; $sequences{clean} = [qw{ dh_testdir dh_auto_clean @@ -376,9 +399,15 @@ my @i = qw{ dh_compress dh_fixperms }; -$sequences{'install'} = [@{$sequences{build}}, @i]; -$sequences{'install-indep'} = [@{$sequences{'build-indep'}}, @i]; -$sequences{'install-arch'} = [@{$sequences{'build-arch'}}, @i]; +# The install sequences will call 'debian/rules build' before running +# the standard sequence, and 'debian/rules install-arch' and +# 'debian/rules install-indep' after running the standard sequence; +# these will typically be no-ops but this permits the install-arch and +# install-indep targets to be customised by the user and still run as +# a side-effect of the install target. +$sequences{'install'} = ['rules:build', @i, 'rules:install-arch', 'rules:install-indep']; +$sequences{'install-indep'} = ['rules:build-indep', @i]; +$sequences{'install-arch'} = ['rules:build-arch', @i]; my @ba=qw{ dh_strip dh_makeshlibs @@ -390,9 +419,11 @@ my @b=qw{ dh_md5sums dh_builddeb }; -$sequences{binary} = [@{$sequences{install}}, @ba, @b]; -$sequences{'binary-indep'} = [@{$sequences{'install-indep'}}, @b]; -$sequences{'binary-arch'} = [@{$sequences{'install-arch'}}, @ba, @b]; +# The binary sequences will call 'debian/rules install' before running +# the standard sequence. +$sequences{binary} = ['rules:install', @ba, @b]; +$sequences{'binary-indep'} = ['rules:install-indep', @b]; +$sequences{'binary-arch'} = ['rules:install-arch', @ba, @b]; # Additional command options my %command_opts; @@ -641,11 +672,29 @@ sub run { # to prevent them from being acted on. push @options, map { "-N$_" } @exclude; + # If the command has a rules: prefix, run debian/rules with + # the remainder as the target. + my $rules_target = undef; + if ($command =~ /^rules:(.*)/) { + $rules_target = $1; + } + # Check for override targets in debian/rules and # run them instead of running the command directly. my $override_command; my $has_explicit_target = rules_explicit_target("override_".$command); - if (defined $has_explicit_target) { + + if (defined $rules_target) { + # Don't pass DH_ environment variables, since this is + # a fresh invocation of debian/rules and any sub-dh + # commands. + $override_command=$command; + delete $ENV{DH_INTERNAL_OPTIONS}; + delete $ENV{DH_INTERNAL_OVERRIDE}; + $command="debian/rules"; + @options=$rules_target; + } + elsif (defined $has_explicit_target) { $override_command=$command; # Check if target isn't noop if ($has_explicit_target) { -- 1.7.5.4
signature.asc
Description: Digital signature

