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

2023-02-20 Thread Jelmer Vernooij
On Mon, Feb 20, 2023 at 03:48:00PM +0100, Christoph Berg wrote:
> Re: Gioele Barabucci
> > execute_after_dh_clean:
> > touch this_strange_file
> 
> The downside of this is that it makes backporting to buster-and-older
> harder since it doesn't have the required debhelper version yet.

It might make sense to only give this warning for packages that are
already on >= 13?

Jelmer



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

2023-02-20 Thread Christoph Berg
Re: Gioele Barabucci
> execute_after_dh_clean:
> touch this_strange_file

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



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

2023-02-20 Thread Gioele Barabucci

Package: lintian
Version: 2.116.3
Severity: wishlist

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,

--
Gioele Barabucci