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

[lintian] 01/01: Warn if packages set CFLAGS if the value of DEB_BUILD_OPTIONS contains noopt. (Closes: #718640)



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

lamby pushed a commit to branch master
in repository lintian.

commit 2899dd8f4880b8082bffce8a7d2ba1cbe2c56431
Author: Chris Lamb <lamby@debian.org>
Date:   Sun Oct 29 10:41:02 2017 +0000

    Warn if packages set CFLAGS if the value of DEB_BUILD_OPTIONS contains noopt. (Closes: #718640)
---
 checks/rules.desc                         | 10 ++++++++++
 checks/rules.pm                           | 15 +++++++++++++++
 data/rules/rules-should-not-use-multiline |  6 ++++++
 debian/changelog                          |  3 +++
 4 files changed, 34 insertions(+)

diff --git a/checks/rules.desc b/checks/rules.desc
index 37731e6..483d0d4 100644
--- a/checks/rules.desc
+++ b/checks/rules.desc
@@ -272,3 +272,13 @@ Info: The <tt>debian/rules</tt> file sets one or more
  build time.
  .
  Please replace the assignment operator with <tt>?=</tt>.
+
+Tag: debian-rules-should-not-set-CFLAGS-from-noopt
+Severity: normal
+Certainty: certain
+Ref: dpkg-buildflags(1)
+Info: The <tt>debian/rules</tt> file for this package appears to set
+ <tt>CFLAGS</tt> if the value of <tt>DEB_BUILD_OPTIONS</tt> contains
+ <tt>noopt</tt>.
+ .
+ This has been obsoleted in favour of <tt>dpkg-buildflags</tt>.
diff --git a/checks/rules.pm b/checks/rules.pm
index f9e317c..cf34465 100644
--- a/checks/rules.pm
+++ b/checks/rules.pm
@@ -44,6 +44,10 @@ my $BAD_CONSTRUCT_IN_RULES
   = Lintian::Data->new('rules/rules-should-not-use', qr/\s*~~\s*/,
     sub { return qr/$_[1]/xs });
 
+my $BAD_MULTILINE_CONSTRUCT_IN_RULES
+  = Lintian::Data->new('rules/rules-should-not-use-multiline',
+    qr/\s*~~\s*/,sub { return qr/$_[1]/xsm });
+
 # Certain build tools must be listed in Build-Depends even if there are no
 # arch-specific packages because they're required in order to run the clean
 # rule.  (See Policy 7.6.)  The following is a list of package dependencies;
@@ -454,6 +458,17 @@ sub run {
         }
     }
 
+    $rules_fd = $rules->open;
+    my $sfd = Lintian::SlidingWindow->new($rules_fd);
+    my $block;
+    while ($block = $sfd->readwindow) {
+        foreach my $tag ($BAD_MULTILINE_CONSTRUCT_IN_RULES->all) {
+            my $regex = $BAD_MULTILINE_CONSTRUCT_IN_RULES->value($tag);
+            tag $tag if $block =~ m/$regex/;
+        }
+    }
+    close($rules_fd);
+
     return;
 }
 
diff --git a/data/rules/rules-should-not-use-multiline b/data/rules/rules-should-not-use-multiline
new file mode 100644
index 0000000..3763bae
--- /dev/null
+++ b/data/rules/rules-should-not-use-multiline
@@ -0,0 +1,6 @@
+# a list of forbidden multiline constructs in debian/rules
+# format is 
+#   tag ~~ regex (/xm)
+# Please sort by alphabetic sort of tags
+#
+debian-rules-should-not-set-CFLAGS-from-noopt ~~ ^ifn?eq\s+\(,\$\(findstring\s+noopt,\$\(DEB_BUILD_OPTIONS\)\)\)\n+\t+CFLAGS\s+\+=\s+-O[02]\n+else\n+\t+CFLAGS\s+\+=\s+-O[02]\n+endif$
diff --git a/debian/changelog b/debian/changelog
index d234f91..c3f2891 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,6 +15,9 @@ lintian (2.5.57) UNRELEASED; urgency=medium
     + [NT] Remove code handling named compat levels.
   * checks/files.desc:
     + [CL] Ignore embedded jQuery libraries for Doxygen.  (Closes: #736360)
+  * checks/rules.desc:
+    + [CL] Warn if packages set CFLAGS if the value of DEB_BUILD_OPTIONS
+      contains noopt.  (Closes: #718640)
 
   * commands/lintian.pm:
     + [NT] Have lintian resignal between various stages of the

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: