From 2f5421cb2c0afd0e14800997a8d1a688a3f91d3d Mon Sep 17 00:00:00 2001 From: Jerzy Grzegorek Date: Sat, 13 Jan 2018 22:39:43 +0100 Subject: [PATCH] utils/checkpackagelib: add function to check of the default package source variable Signed-off-by: Jerzy Grzegorek Cc: Ricardo Martincoski Cc: Thomas Petazzoni Reviewed-by: Ricardo Martincoski Tested-by: Ricardo Martincoski Signed-off-by: Thomas Petazzoni --- utils/checkpackagelib/lib_mk.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py index 817e80923e..a6cfeb6d15 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)\\$") -- 2.30.2