[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Dpkg::Vendor::Ubuntu: Respect options env when override features



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;
     my $arch = Dpkg::Arch::get_host_arch();
 
     if (any { $_ eq $arch } qw(amd64 arm64 ppc64el s390x)) {
-        $flags->set_feature('optimize', 'lto', 1);
+        $use_feature->{optimize}{lto} = 1;
     }
+}
+
+sub set_build_features {
+    my ($self, $flags) = @_;
+
+    $self->SUPER::set_build_features($flags);
+
+    require Dpkg::Arch;
+    my $arch = Dpkg::Arch::get_host_arch();
 
     if ($arch eq 'ppc64el' && $flags->get_option_value('optimize-level') != 0) {
         $flags->set_option_value('optimize-level', 3);

Reply to: