#1031679 lintian: d/rules: should suggest using `execute_before/_after_dh_command` instead of `override_dh_command`

#1031679#5
Date:
2023-02-20 11:24:10 UTC
From:
To:
Lintian should warn about the use of `override_dh_command` to inject
commands before or after the execution of `dh_command`. In such
situations one should use `execute_before_dh_command` and
`execute_after_dh_command`.

Many debian/rules files use `override_dh_command` to inject commands
before or after the execution of the default dh_command. For example:

     override_dh_clean:
         dh_clean:
         touch this_strange_file

Since debhelper 12.8 (compat 10, Debian 11) one should use the more
expressive `execute_before_dh_command` and `execute_after_dh_command`.
For example:

     execute_after_dh_clean:
         touch this_strange_file

Real-life examples of such uses of `override_dh_command`:
https://salsa.debian.org/debian/pkg-collectd/-/blob/694f2c9/debian/rules#L278-310

In addition to simplifying the code of `d/rules` and making it more
expressive, the use of `execute_before/_after` ensures that all
dh_command-specific BUILD_OPTIONS-/BUILD_PROFILE-related actions are
taken into account without having to reimplement them inside
`override_dh_command`.

Regards,

#1031679#8
Date:
2023-02-20 14:48:00 UTC
From:
To:
Re: Gioele Barabucci

The downside of this is that it makes backporting to buster-and-older
harder since it doesn't have the required debhelper version yet.

Christoph

#1031679#13
Date:
2023-02-20 14:54:25 UTC
From:
To:
It might make sense to only give this warning for packages that are
already on >= 13?

Jelmer