• [PATCH] Dpkg::Vendor::Ubuntu: Respect options env when override feature

    From Shengjing Zhu@21:1/5 to All on Sat Jan 14 03:40:01 2023
    It's bit unfortunate that I've to duplicate Dpkg::BuildOptions
    parsing here.

    LP: #2002582
    ---
    scripts/Dpkg/Vendor/Ubuntu.pm | 23 ++++++++++++++++++++++-
    scripts/t/Dpkg_BuildFlags_Ubuntu.t | 28 +++++++++++++++++++++++++++-
    2 files changed, 49 insertions(+), 2 deletions(-)

    diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index df42580e2..720475e94 100644
    --- a/scripts/Dpkg/Vendor/Ubuntu.pm
    +++ b/scripts/Dpkg/Vendor/Ubuntu.pm
    @@ -114,11 +114,32 @@ sub set_build_features {

    $self->SUPER::set_build_features($flags);

    + my %default_feature = (
    + optimize => {
    + lto => 0,
    + },
    + );
    +
    +
    require Dpkg::Arch;
    my $arch = Dpkg::Arch::get_host_arch();

    if (any { $_ eq $arch } qw(amd64 arm64 ppc64el s390x)) {
    - $flags->set_feature('optimize', 'lto', 1);
    + $default_feature{optimize}{lto} = 1;
    + }
    +
    + my $opts_build = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_OPTIONS');
    + my $opts_maint = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_MAINT_OPTIONS');
    +
    + foreach my $area
  • From Guillem Jover@21:1/5 to Shengjing Zhu on Thu Jan 19 10:00:01 2023
    Hi!

    On Sat, 2023-01-14 at 10:04:39 +0800, Shengjing Zhu wrote:
    It's bit unfortunate that I've to duplicate Dpkg::BuildOptions
    parsing here.

    Right, and that's one of the reasons I wanted to avoid with the recent refactoring there. :) I started further reworking the code to fix this
    but it ended up getting out of hand, so I'll postpone that for 1.22.x. Meanwhile I'll apply the following attached patch instead for the code
    part, and your tests on top. Thanks!

    Regards,
    Guillem

    diff --git i/scripts/Dpkg/Vendor/Debian.pm w/scripts/Dpkg/Vendor/Debian.pm index 39ffbf065..06aa49ad6 100644
    --- i/scripts/Dpkg/Vendor/Debian.pm
    +++ w/scripts/Dpkg/Vendor/Debian.pm
    @@ -94,6 +94,10 @@ sub run_hook {
    }
    }

    +sub init_build_features {
    + my ($self, $use_feature, $builtin_feature) = @_;
    +}
    +
    sub set_build_features {
    my ($self, $flags) = @_;

    @@ -139,6 +143,8 @@ sub set_build_features {
    },
    );

    + $self->init_build_features(\%use_feature, \%builtin_feature);
    +
    ## Setup

    require Dpkg::BuildOptions;
    diff --git i/scripts/Dpkg/Vendor/Ubuntu.pm w/scripts/Dpkg/Vendor/Ubuntu.pm index df42580e2..9c77519d7 100644
    --- i/scripts/Dpkg/Vendor/Ubuntu.pm
    +++ w/scripts/Dpkg/Vendor/Ubuntu.pm
    @@ -109,17 +109,26 @@ sub run_hook {
    }

    # Override Debian default features.
    -sub set_build_features {
    - my ($self, $flags) = @_;
    +sub init_build_features {
    + my ($self, $use_feature, $builtin_feature) = @_;

    - $self->SUPER::set_build_features($flags);
    + $self->SUPER::init_build_features($use_feature, $builtin_feature);

    require Dpkg::Arch;