Package: dpkg Version: 1.20.7.1 Severity: normal Tags: patch Dear Maintainer,
In Ubuntu, we mostly use live images and no longer have a use for udebs. Thus we are trying to build Ubuntu without udebs. Whilst we could set DEB_BUILD_PROFILES it sbuild, it would result in locally built packages with dpkg-buildpackage try to build udebs, even when primary archive doesn't build them. To avoid this discrepancy it would be nice to have a vendor hook, that allows to set deb-build-profiles, similar to the deb-build-options hook. I've implemented that, but I do not know perl. perl critic reports issues, but if i fix them, unrelated tests start failing. So I'm at a loss as to how to implement this idea correctly and without destroying the ci. Any reviews and advise would be highly appreciated. Regards, Dimitri.
diff -Nru dpkg-1.20.7.1ubuntu2/debian/changelog dpkg-1.20.7.1ubuntu3/debian/changelog --- dpkg-1.20.7.1ubuntu2/debian/changelog 2021-01-28 09:00:33.000000000 +0000 +++ dpkg-1.20.7.1ubuntu3/debian/changelog 2021-02-18 19:58:48.000000000 +0000 @@ -1,3 +1,11 @@ +dpkg (1.20.7.1ubuntu3) hirsute; urgency=medium + + * scripts/Dpkg/Vendor/Ubuntu.pm: set 'noudeb' build profile by + default. Override this by exporting DEB_BUILD_PROFILE='!noudeb' which + will be stripped, and thus building with udebs. LP: #1884836 + + -- Dimitri John Ledkov <x...@ubuntu.com> Thu, 18 Feb 2021 19:58:48 +0000 + dpkg (1.20.7.1ubuntu2) hirsute; urgency=medium * Dpkg::Vendor::Debian: Add new lto feature in new optimize area, taken diff -Nru dpkg-1.20.7.1ubuntu2/scripts/Dpkg/BuildProfiles.pm dpkg-1.20.7.1ubuntu3/scripts/Dpkg/BuildProfiles.pm --- dpkg-1.20.7.1ubuntu2/scripts/Dpkg/BuildProfiles.pm 2019-11-05 11:59:03.000000000 +0000 +++ dpkg-1.20.7.1ubuntu3/scripts/Dpkg/BuildProfiles.pm 2021-02-18 19:58:46.000000000 +0000 @@ -30,6 +30,7 @@ use List::Util qw(any); use Dpkg::Build::Env; +use Dpkg::Vendor qw(run_vendor_hook); my $cache_profiles; my @build_profiles; @@ -63,6 +64,7 @@ @build_profiles = split ' ', Dpkg::Build::Env::get('DEB_BUILD_PROFILES'); } $cache_profiles = 1; + run_vendor_hook('update-buildprofiles', \@build_profiles); return @build_profiles; } @@ -79,7 +81,8 @@ $cache_profiles = 1; @build_profiles = @profiles; - Dpkg::Build::Env::set('DEB_BUILD_PROFILES', join ' ', @profiles); + run_vendor_hook('update-buildprofiles', \@build_profiles); + Dpkg::Build::Env::set('DEB_BUILD_PROFILES', join ' ', @build_profiles); } =item @profiles = parse_build_profiles($string) diff -Nru dpkg-1.20.7.1ubuntu2/scripts/Dpkg/Vendor/Default.pm dpkg-1.20.7.1ubuntu3/scripts/Dpkg/Vendor/Default.pm --- dpkg-1.20.7.1ubuntu2/scripts/Dpkg/Vendor/Default.pm 2021-01-09 06:04:59.000000000 +0000 +++ dpkg-1.20.7.1ubuntu3/scripts/Dpkg/Vendor/Default.pm 2021-02-18 19:58:46.000000000 +0000 @@ -130,6 +130,12 @@ the default values set for the various build flags. $flags is a Dpkg::BuildFlags object. +=item update-buildprofiles ($build_profiles_ref) + +The hook is called in Dpkg::BuildProfiles to allow the vendor to +override the default values set. $build_profiles_ref is a array ref to +Dpkg::BuildProfiles object. + =item builtin-system-build-paths () The hook is called by dpkg-genbuildinfo to determine if the current path @@ -180,6 +186,8 @@ my ($textref, $ch_info) = @params; } elsif ($hook eq 'update-buildflags') { my $flags = shift @params; + } elsif ($hook eq 'update-buildprofiles') { + my $build_profiles_ref = shift @params; } elsif ($hook eq 'builtin-system-build-paths') { return (); } elsif ($hook eq 'build-tainted-by') { diff -Nru dpkg-1.20.7.1ubuntu2/scripts/Dpkg/Vendor/Ubuntu.pm dpkg-1.20.7.1ubuntu3/scripts/Dpkg/Vendor/Ubuntu.pm --- dpkg-1.20.7.1ubuntu2/scripts/Dpkg/Vendor/Ubuntu.pm 2021-01-12 11:45:46.000000000 +0000 +++ dpkg-1.20.7.1ubuntu3/scripts/Dpkg/Vendor/Ubuntu.pm 2021-02-18 19:58:46.000000000 +0000 @@ -125,6 +125,14 @@ } # Per https://wiki.ubuntu.com/DistCompilerFlags $flags->prepend('LDFLAGS', '-Wl,-Bsymbolic-functions'); + } elsif ($hook eq 'update-buildprofiles') { + my $build_profiles_ref = shift @params; + unless(grep $_ =~ /^!?noudeb$/, @$build_profiles_ref) { + unshift(@$build_profiles_ref, 'noudeb'); + } else { + # Strip otherwise invalid profile name + @$build_profiles_ref = grep { $_ ne "!noudeb" } @$build_profiles_ref; + } } else { return $self->SUPER::run_hook($hook, @params); } diff -Nru dpkg-1.20.7.1ubuntu2/scripts/dpkg-buildpackage.pl dpkg-1.20.7.1ubuntu3/scripts/dpkg-buildpackage.pl --- dpkg-1.20.7.1ubuntu2/scripts/dpkg-buildpackage.pl 2021-01-12 11:45:46.000000000 +0000 +++ dpkg-1.20.7.1ubuntu3/scripts/dpkg-buildpackage.pl 2021-02-18 19:58:46.000000000 +0000 @@ -432,7 +432,7 @@ $build_opts->export(); } -set_build_profiles(@build_profiles) if @build_profiles; +set_build_profiles(@build_profiles); my $changelog = changelog_parse(); my $ctrl = Dpkg::Control::Info->new(); diff -Nru dpkg-1.20.7.1ubuntu2/scripts/t/Dpkg_BuildProfiles.t dpkg-1.20.7.1ubuntu3/scripts/t/Dpkg_BuildProfiles.t --- dpkg-1.20.7.1ubuntu2/scripts/t/Dpkg_BuildProfiles.t 2019-11-05 11:59:03.000000000 +0000 +++ dpkg-1.20.7.1ubuntu3/scripts/t/Dpkg_BuildProfiles.t 2021-02-18 19:58:46.000000000 +0000 @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 10; BEGIN { use_ok('Dpkg::BuildProfiles', qw(parse_build_profiles @@ -26,6 +26,9 @@ # TODO: Add actual test cases. +# Check stock things +$ENV{DEB_VENDOR} = 'Debian'; + my $formula; $formula = [ ]; @@ -58,4 +61,16 @@ is_deeply([ get_build_profiles() ], [ qw(nocheck stage1) ], 'get active build profiles explicitly set'); +# Check Ubuntu vendor hook +$ENV{DEB_VENDOR} = 'Ubuntu'; + +set_build_profiles(qw(nocheck stage1)); +is_deeply([ get_build_profiles() ], [ qw(noudeb nocheck stage1) ], + 'get active build profiles explicitly set'); + +set_build_profiles(qw(!noudeb nocheck stage1)); +is_deeply([ get_build_profiles() ], [ qw(nocheck stage1) ], + 'get active build profiles explicitly set'); + + 1;