Просмотр исходного кода

Dpkg::Vendor::Debian: Add fixdebugpath to reproducible feature

This feature normalizes the path stored in debug symbols, so that
these symbols can be built reproducibly regardless of the location
of the build in the larger filesystem.

It defaults to off, but should be enabled by systems trying to
generate reproducible packages.

[guillem@debian.org:
 - Add additional build flags.
 - Rename feature name.
 - Import Cwd module with require instead of use. ]

Closes: #819194
Signed-off-by: Guillem Jover <guillem@debian.org>
Daniel Kahn Gillmor лет назад: 10
Родитель
Сommit
eb58be2f27
3 измененных файлов с 26 добавлено и 0 удалено
  1. 2 0
      debian/changelog
  2. 10 0
      man/dpkg-buildflags.1
  3. 14 0
      scripts/Dpkg/Vendor/Debian.pm

+ 2 - 0
debian/changelog

@@ -119,6 +119,8 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
       version 1.0 non-native source packages.
     - Include upstream orig tarball signatures in source packages.
       See #759478.
+    - Add fixdebugpath to reproducible feature in Dpkg::Vendor::Debian.
+      Thanks to Daniel Kahn Gillmor <dkg@fifthhorseman.net>. Closes: #819194
   * Build system:
     - Fix building development documentation.
     - Remove unused UA_LIBS variable.

+ 10 - 0
man/dpkg-buildflags.1

@@ -381,6 +381,16 @@ to \fBCPPFLAGS\fP.
 This will cause warnings when the \fB__TIME__\fP, \fB__DATE__\fP and
 \fB\%__TIMESTAMP__\fP macros are used.
 .
+.TP
+.B fixdebugpath
+This setting (disabled by default) adds
+.BI %\-fdebug\-path\-map= BUILDPATH =.
+to \fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBOBJCFLAGS\fP, \fBOBJCXXFLAGS\fP,
+\fBGCJFLAGS\fP, \fBFFLAGS\fP and \fBFCFLAGS\fP where \fBBUILDPATH\fP is
+set to the top-level directory of the package being built.
+This has the effect of removing the build path from any generated debug
+symbols.
+.
 .SH ENVIRONMENT
 There are 2 sets of environment variables doing the same operations, the
 first one (DEB_\fIflag\fP_\fIop\fP) should never be used within

+ 14 - 0
scripts/Dpkg/Vendor/Debian.pm

@@ -158,6 +158,7 @@ sub _add_reproducible_flags {
     # Default feature states.
     my %use_feature = (
         timeless => 1,
+        fixdebugpath => 0,
     );
 
     # Adjust features based on user or maintainer's desires.
@@ -168,6 +169,19 @@ sub _add_reproducible_flags {
        $flags->append('CPPFLAGS', '-Wdate-time');
     }
 
+    # Avoid storing the build path in the debug symbols.
+    if ($use_feature{fixdebugpath}) {
+        require Cwd;
+        my $map = '-fdebug-prefix-map=' . Cwd::cwd() . '=.';
+        $flags->append('CFLAGS', $map);
+        $flags->append('CXXFLAGS', $map);
+        $flags->append('OBJCFLAGS', $map);
+        $flags->append('OBJCXXFLAGS', $map);
+        $flags->append('FFLAGS', $map);
+        $flags->append('FCFLAGS', $map);
+        $flags->append('GCJFLAGS', $map);
+    }
+
     # Store the feature usage.
     while (my ($feature, $enabled) = each %use_feature) {
        $flags->set_feature('reproducible', $feature, $enabled);