[PATCHv3,1/1] utils/checkpackagelib: add function to check of the default package source variable

Message ID 1515879583-8269-1-git-send-email-jerzy.m.grzegorek@gmail.com
State Accepted
Headers show
Series
  • [PATCHv3,1/1] utils/checkpackagelib: add function to check of the default package source variable
Related show

Commit Message

Jerzy Grzegorek Jan. 13, 2018, 9:39 p.m.
Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com>
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
Changes v2 -> v3
 - add missing whitespaces after ',' (Ricardo Martincoski)
 - remove value returned by the check function (Ricardo Martincoski)

Changes v1 -> v2
 - remove unused variable (Ricardo Martincoski)
 - change warning url (Ricardo Martincoski)
 - add whitelist of packages (Ricardo Martincoski)

 utils/checkpackagelib/lib_mk.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Ricardo Martincoski Jan. 14, 2018, 11:52 p.m. | #1
Hello,

On Sat, Jan 13, 2018 at 07:39 PM, Jerzy Grzegorek wrote:

> Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com>
Reviewed-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[https://gitlab.com/RicardoMartincoski/buildroot/-/jobs/47905172]
Tested-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>

Note 1: the new warning added to check-package job in gitlab will be fixed by:
http://patchwork.ozlabs.org/patch/859399/
Note 2: the warnings already in the tree have fixes too:
http://patchwork.ozlabs.org/patch/860493/
http://patchwork.ozlabs.org/patch/860542/

Regards,
Ricardo
Thomas Petazzoni Jan. 15, 2018, 10:27 p.m. | #2
Hello,

On Sat, 13 Jan 2018 22:39:43 +0100, Jerzy Grzegorek wrote:
> Signed-off-by: Jerzy Grzegorek <jerzy.m.grzegorek@gmail.com>
> Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> Changes v2 -> v3
>  - add missing whitespaces after ',' (Ricardo Martincoski)
>  - remove value returned by the check function (Ricardo Martincoski)

Applied to master, thanks.

Thomas

Patch

diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py
index 817e809..a6cfeb6 100644
--- a/utils/checkpackagelib/lib_mk.py
+++ b/utils/checkpackagelib/lib_mk.py
@@ -99,6 +99,30 @@  class PackageHeader(_CheckFunction):
                         text]
 
 
+class RemoveDefaultPackageSourceVariable(_CheckFunction):
+    packages_that_may_contain_default_source = ["binutils", "gcc", "gdb"]
+    PACKAGE_NAME = re.compile("/([^/]+)\.mk")
+
+    def before(self):
+        package = self.PACKAGE_NAME.search(self.filename).group(1)
+        package_upper = package.replace("-", "_").upper()
+        self.package = package
+        self.FIND_SOURCE = re.compile(
+            "^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
+            .format(package_upper, package, package_upper))
+
+    def check_line(self, lineno, text):
+        if self.FIND_SOURCE.search(text):
+
+            if self.package in self.packages_that_may_contain_default_source:
+                return
+
+            return ["{}:{}: remove default value of _SOURCE variable "
+                    "({}#generic-package-reference)"
+                    .format(self.filename, lineno, self.url_to_manual),
+                    text]
+
+
 class SpaceBeforeBackslash(_CheckFunction):
     TAB_OR_MULTIPLE_SPACES_BEFORE_BACKSLASH = re.compile(r"^.*(  |\t)\\$")