Kaynağa Gözat

Dpkg::Vendor::Debian: Add a timeless feature in the reproducible area

This will add approproriate options to warn about __TIME__, __DATE__ and
__TIMESTAMP__ macros.

Closes: #762683

Signed-off-by: Guillem Jover <guillem@debian.org>
Paul Wise 11 yıl önce
ebeveyn
işleme
8ac9b317f6
3 değiştirilmiş dosya ile 15 ekleme ve 0 silme
  1. 2 0
      debian/changelog
  2. 7 0
      man/dpkg-buildflags.1
  3. 6 0
      scripts/Dpkg/Vendor/Debian.pm

+ 2 - 0
debian/changelog

@@ -46,6 +46,8 @@ dpkg (1.17.14) UNRELEASED; urgency=low
   * Pass DEB_BUILD_OPTIONS to dpkg-buildflags in buildflags.mk, required to
     get noopt to work at all, for example.
   * Add a new dpkg-buildflags reproducible feature area:
+    - Add a new timeless feature, disabled by default, which will add
+      «-Wdate-time» to CPPFLAGS.
     Thanks to Paul Wise <pabs@debian.org>. Closes: #762683
 
   [ Raphaël Hertzog ]

+ 7 - 0
man/dpkg-buildflags.1

@@ -343,6 +343,13 @@ The compile-time options detailed below can be used to help improve
 build reproducibility or provide additional warning messages during
 compilation. Except as noted below, these are enabled by default for
 architectures that support them.
+.TP
+.B timeless
+This setting (disabled by default) adds
+.B \-Wdate\-time
+to \fBCPPFLAGS\fP.
+This will cause warnings when the \fB__TIME__\fP, \fB__DATE__\fP and
+\fB__TIMESTAMP__\fP macros are used.
 .
 .SH ENVIRONMENT
 There are 2 sets of environment variables doing the same operations, the

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

@@ -151,11 +151,17 @@ sub _add_reproducible_flags {
 
     # Default feature states.
     my %use_feature = (
+        timeless => 0,
     );
 
     # Adjust features based on user or maintainer's desires.
     $self->_parse_feature_area('reproducible', \%use_feature);
 
+    # Warn when the __TIME__, __DATE__ and __TIMESTAMP__ macros are used.
+    if ($use_feature{timeless}) {
+       $flags->append('CPPFLAGS', '-Wdate-time');
+    }
+
     # Store the feature usage.
     while (my ($feature, $enabled) = each %use_feature) {
        $flags->set_feature('reproducible', $feature, $enabled);