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

Bug#832099: lintian: please check for unnecessary SOURCE_DATE_EPOCH assignments



Source: lintian
Version: 2.5.45
Severity: wishlist
Tags: patch
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Hi,

Attached is the following:

  commit 3b10f7dbaecedb0a458c25cc0b8615b489d424af
  Author: Chris Lamb <lamby@debian.org>
  Date:   Fri Jul 22 10:54:02 2016 +0100
  
      c/rules: Check for unnecessary SOURCE_DATE_EPOCH assignments
      
      As of dpkg 1.18.8, this is no longer necessary as dpkg exports this
      variable if it is not already set (#759999). This should encourage
      removing some duplicated code from a lot of our rules files.
      
      Signed-off-by: Chris Lamb <lamby@debian.org>
  
   checks/rules.desc                         | 8 ++++++++
   checks/rules.pm                           | 2 ++
   t/tests/rules-general/debian/debian/rules | 2 ++
   t/tests/rules-general/desc                | 3 ++-
   t/tests/rules-general/tags                | 7 ++++---
   5 files changed, 18 insertions(+), 4 deletions(-)



Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby@debian.org / chris-lamb.co.uk
       `-
From 3b10f7dbaecedb0a458c25cc0b8615b489d424af Mon Sep 17 00:00:00 2001
From: Chris Lamb <lamby@debian.org>
Date: Fri, 22 Jul 2016 10:54:02 +0100
Subject: [PATCH] c/rules: Check for unnecessary SOURCE_DATE_EPOCH assignments

As of dpkg 1.18.8, this is no longer necessary as dpkg exports this
variable if it is not already set (#759999). This should encourage
removing some duplicated code from a lot of our rules files.

Signed-off-by: Chris Lamb <lamby@debian.org>
---
 checks/rules.desc                         | 8 ++++++++
 checks/rules.pm                           | 2 ++
 t/tests/rules-general/debian/debian/rules | 2 ++
 t/tests/rules-general/desc                | 3 ++-
 t/tests/rules-general/tags                | 7 ++++---
 5 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/checks/rules.desc b/checks/rules.desc
index 25c565b..13bf4c2 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -248,3 +248,11 @@ Info: The source package does not have both a build-arch and a build-indep
  .
  Please consider adding both the build-arch and build-indep targets.
 
+Tag: unnecessary-source-date-epoch-assignment
+Severity: normal
+Certainty: certain
+Info: There is an assignment to a <tt>SOURCE_DATE_EPOCH</tt> variable in the
+  <tt>debian/rules</tt> file.  As of dpkg 1.18.8, this is no longer necessary
+  as dpkg exports this variable if it is not already set.
+  .
+  Consider removing this assignment.
diff --git a/checks/rules.pm b/checks/rules.pm
index bd3a141..ce77909 100644
--- a/checks/rules.pm
+++ b/checks/rules.pm
@@ -226,6 +226,8 @@ sub run {
             # rather well.
             my ($var, $value) = ($1, $2);
             $variables{$var} = $value;
+            tag 'unnecessary-source-date-epoch-assignment', "line $."
+                if $var eq "SOURCE_DATE_EPOCH";
         }
 
         # Keep track of whether this portion of debian/rules may be optional
diff --git a/t/tests/rules-general/debian/debian/rules b/t/tests/rules-general/debian/debian/rules
index cddbc03..121305a 100755
--- a/t/tests/rules-general/debian/debian/rules
+++ b/t/tests/rules-general/debian/debian/rules
@@ -2,6 +2,8 @@
 
 DEB_AUTO_UPDATE_DEBIAN_CONTROL = yes
 
+export SOURCE_DATE_EPOCH = $(shell date -d "$$(dpkg-parsechangelog -SDate)" +%s)
+
 %:
 	dh $@
 
diff --git a/t/tests/rules-general/desc b/t/tests/rules-general/desc
index 1f41c20..cab329e 100644
--- a/t/tests/rules-general/desc
+++ b/t/tests/rules-general/desc
@@ -7,4 +7,5 @@ Test-For:
  debian-rules-should-not-automatically-update-control
  debian-rules-should-not-use-DEB_BUILD_OPTS
  debian-rules-should-not-use-pwd
- debian-rules-should-not-use-underscore-variable
\ No newline at end of file
+ debian-rules-should-not-use-underscore-variable
+ unnecessary-source-date-epoch-assignment
diff --git a/t/tests/rules-general/tags b/t/tests/rules-general/tags
index 3e7351b..6675064 100644
--- a/t/tests/rules-general/tags
+++ b/t/tests/rules-general/tags
@@ -1,5 +1,6 @@
 E: rules-general source: clean-should-be-satisfied-by-build-depends debhelper
 E: rules-general source: debian-rules-should-not-automatically-update-control line 3
-W: rules-general source: debian-rules-should-not-use-DEB_BUILD_OPTS line 10
-W: rules-general source: debian-rules-should-not-use-pwd line 10
-W: rules-general source: debian-rules-should-not-use-underscore-variable line 11
+W: rules-general source: debian-rules-should-not-use-DEB_BUILD_OPTS line 12
+W: rules-general source: debian-rules-should-not-use-pwd line 12
+W: rules-general source: debian-rules-should-not-use-underscore-variable line 13
+W: rules-general source: unnecessary-source-date-epoch-assignment line 5
-- 
2.8.1


Reply to: