This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=f556025da2f01dbea051a61de55edb0ace9f48ed

commit f556025da2f01dbea051a61de55edb0ace9f48ed
Author: Guillem Jover <[email protected]>
AuthorDate: Mon Jun 5 01:51:48 2023 +0200

    Dpkg::Vendor::Debian: Move lfs from future to abi area and create an alias
    
    For the same reason we have moved the time64 feature from the future
    to the abi feature area to make the name more clear and pass the test
    of time once these start to be enabled by default on some architectures.
    Do the same for the old lfs feature, but add a backwards compatibility
    alias so that existing users of this interface do not break.
    
    Suggested-by: Steve Langasek <[email protected]>
---
 man/dpkg-buildflags.pod       | 34 +++++++++++++++++++++++-----------
 scripts/Dpkg/Vendor/Debian.pm | 23 ++++++++++++++---------
 scripts/t/Dpkg_BuildFlags.t   | 39 ++++++++++++++++++++++++++++++++++++++-
 3 files changed, 75 insertions(+), 21 deletions(-)

diff --git a/man/dpkg-buildflags.pod b/man/dpkg-buildflags.pod
index 83f6719e7..9f8d7449e 100644
--- a/man/dpkg-buildflags.pod
+++ b/man/dpkg-buildflags.pod
@@ -334,34 +334,46 @@ Thus disabling everything in the B<hardening> area and 
enabling only
 
     export DEB_BUILD_MAINT_OPTIONS=hardening=-all,+format,+fortify
 
-=head2 future
+=head2 abi
 
 Several compile-time options (detailed below) can be used to enable features
-that should be enabled by default, but cannot due to backwards compatibility
-reasons.
+that can change the ABI of a package, but cannot be enabled by default due to
+backwards compatibility reasons unless coordinated or checked individually.
 
 =over
 
 =item B<lfs>
 
-This setting (since dpkg 1.19.0; disabled by default) enables
+This setting (since dpkg 1.22.0; disabled by default) enables
 Large File Support on 32-bit architectures where their ABI does
 not include LFS by default, by adding
 B<-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64> to B<CPPFLAGS>.
 
-=head2 abi
-
-Several compile-time options (detailed below) can be used to enable features
-that can change the ABI of a package, but cannot be enabled by default due to
-backwards compatibility reasons unless coordinated or checked individually.
+When this feature is enabled it will override the value from the same
+feature in the B<future> feature area.
 
 =item B<time64>
 
 This setting (since dpkg 1.22.0; disabled by default) enables 64-bit time_t
 support on 32-bit architectures where their ABI does not include it by
 default, by adding B<-D_TIME_BITS=64> to B<CPPFLAGS>.
-This setting automatically enables the B<lfs> feature in the B<future> area
-as it requires it.
+This setting automatically enables the B<lfs> feature as it requires it.
+
+=back
+
+=head2 future
+
+Several compile-time options (detailed below) can be used to enable features
+that should be enabled by default, but cannot due to backwards compatibility
+reasons.
+
+=over
+
+=item B<lfs>
+
+This setting (since dpkg 1.19.0; disabled by default) is now an alias
+for the B<lfs> feature in the B<abi> area, use that instead.
+The feature from the B<abi> area overrides this setting.
 
 =back
 
diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm
index ec4ae2f73..5f6ec0b3f 100644
--- a/scripts/Dpkg/Vendor/Debian.pm
+++ b/scripts/Dpkg/Vendor/Debian.pm
@@ -106,9 +106,13 @@ sub set_build_features {
     # Default feature states.
     my %use_feature = (
         future => {
+            # XXX: Should start a deprecation cycle at some point.
             lfs => 0,
         },
         abi => {
+            # XXX: This is set to undef so that we can handle the alias from
+            # the future feature area.
+            lfs => undef,
             time64 => 0,
         },
         qa => {
@@ -220,17 +224,20 @@ sub set_build_features {
             $use_feature{abi}{time64} = 0;
         } elsif ($libc eq 'gnu') {
             # On glibc 64-bit time_t support requires LFS.
-            $use_feature{future}{lfs} = 1;
+            $use_feature{abi}{lfs} = 1;
         }
     }
 
-    ## Area: future
-
-    if ($use_feature{future}{lfs}) {
+    # XXX: Handle lfs alias from future abi feature area.
+    $use_feature{abi}{lfs} //= $use_feature{future}{lfs};
+    if ($use_feature{abi}{lfs}) {
         if ($abi_bits != 32) {
-            $use_feature{future}{lfs} = 0;
+            $use_feature{abi}{lfs} = 0;
         }
     }
+    # XXX: Once the feature is set in the abi area, we always override the
+    # one in the future area.
+    $use_feature{future}{lfs} = $use_feature{abi}{lfs};
 
     ## Area: reproducible
 
@@ -392,15 +399,13 @@ sub _add_build_flags {
     $flags->append($_, $default_flags) foreach @compile_flags;
     $flags->append('DFLAGS', $default_d_flags);
 
-    ## Area: future
+    ## Area: abi
 
-    if ($flags->use_feature('future', 'lfs')) {
+    if ($flags->use_feature('abi', 'lfs')) {
         $flags->append('CPPFLAGS',
                        '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
     }
 
-    ## Area: abi
-
     if ($flags->use_feature('abi', 'time64')) {
         $flags->append('CPPFLAGS', '-D_TIME_BITS=64');
     }
diff --git a/scripts/t/Dpkg_BuildFlags.t b/scripts/t/Dpkg_BuildFlags.t
index 6ccdfe7fb..d12ccc065 100644
--- a/scripts/t/Dpkg_BuildFlags.t
+++ b/scripts/t/Dpkg_BuildFlags.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 34;
+use Test::More tests => 40;
 
 BEGIN {
     $ENV{DEB_BUILD_ARCH} = 'amd64';
@@ -24,6 +24,21 @@ BEGIN {
     use_ok('Dpkg::BuildFlags');
 }
 
+sub test_has_flag
+{
+    my ($bf, $flag, $optflag) = @_;
+
+    my $value = $bf->get($flag);
+    ok($value =~ m/$optflag/, "$flag contains $optflag: $value");
+}
+
+sub test_has_noflag
+{
+    my ($bf, $flag, $optflag) = @_;
+
+    my $value = $bf->get($flag);
+    ok($value !~ m/$optflag/, "$flag does not contain $optflag: $value");
+}
 my $bf = Dpkg::BuildFlags->new();
 
 ok($bf->has('CPPFLAGS'), 'CPPFLAGS is present');
@@ -89,6 +104,7 @@ my %known_features = (
         lfs
     ) ],
     abi => [ qw(
+        lfs
         time64
     ) ],
     hardening => [ qw(
@@ -131,4 +147,25 @@ foreach my $area (sort keys %known_features) {
               "supported features for area $area");
 }
 
+# Test lfs alias from abi to future, we need a 32-bit arch that does does
+# not currently have this flag built-in.
+$ENV{DEB_BUILD_ARCH} = 'i386';
+$ENV{DEB_HOST_ARCH} = 'i386';
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'future=+lfs';
+$bf = Dpkg::BuildFlags->new();
+test_has_flag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'abi=+lfs';
+$bf = Dpkg::BuildFlags->new();
+test_has_flag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'future=-lfs abi=+lfs';
+$bf = Dpkg::BuildFlags->new();
+test_has_flag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
+
+$ENV{DEB_BUILD_MAINT_OPTIONS} = 'future=+lfs abi=-lfs';
+$bf = Dpkg::BuildFlags->new();
+test_has_noflag($bf, 'CPPFLAGS', '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64');
+
 # TODO: Add more test cases.

-- 
Dpkg.Org's dpkg

Reply via email to