|
@@ -49,6 +49,18 @@ class Ifdef(_CheckFunction):
|
|
|
text]
|
|
|
|
|
|
|
|
|
+def get_package_prefix_from_filename(filename):
|
|
|
+ """Return a tuple (pkgname, PKGNAME) with the package name derived from the file name"""
|
|
|
+ # Double splitext to support .mk.in
|
|
|
+ package = os.path.splitext(os.path.splitext(os.path.basename(filename))[0])[0]
|
|
|
+ # linux tools do not use LINUX_TOOL_ prefix for variables
|
|
|
+ package = package.replace("linux-tool-", "")
|
|
|
+ # linux extensions do not use LINUX_EXT_ prefix for variables
|
|
|
+ package = package.replace("linux-ext-", "")
|
|
|
+ package_upper = package.replace("-", "_").upper()
|
|
|
+ return package, package_upper
|
|
|
+
|
|
|
+
|
|
|
class Indent(_CheckFunction):
|
|
|
COMMENT = re.compile(r"^\s*#")
|
|
|
CONDITIONAL = re.compile(r"^\s*({})\s".format("|".join(start_conditional + end_conditional + continue_conditional)))
|
|
@@ -207,12 +219,10 @@ class RemoveDefaultPackageSourceVariable(_CheckFunction):
|
|
|
packages_that_may_contain_default_source = ["binutils", "gcc", "gdb"]
|
|
|
|
|
|
def before(self):
|
|
|
- package, _ = os.path.splitext(os.path.basename(self.filename))
|
|
|
- package_upper = package.replace("-", "_").upper()
|
|
|
- self.package = package
|
|
|
+ self.package, package_upper = get_package_prefix_from_filename(self.filename)
|
|
|
self.FIND_SOURCE = re.compile(
|
|
|
r"^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
|
|
|
- .format(package_upper, package, package_upper))
|
|
|
+ .format(package_upper, self.package, package_upper))
|
|
|
|
|
|
def check_line(self, lineno, text):
|
|
|
if self.FIND_SOURCE.search(text):
|
|
@@ -282,16 +292,10 @@ class TypoInPackageVariable(_CheckFunction):
|
|
|
VARIABLE = re.compile(r"^(define\s+)?([A-Z0-9_]+_[A-Z0-9_]+)")
|
|
|
|
|
|
def before(self):
|
|
|
- package, _ = os.path.splitext(os.path.basename(self.filename))
|
|
|
- package = package.replace("-", "_").upper()
|
|
|
- # linux tools do not use LINUX_TOOL_ prefix for variables
|
|
|
- package = package.replace("LINUX_TOOL_", "")
|
|
|
- # linux extensions do not use LINUX_EXT_ prefix for variables
|
|
|
- package = package.replace("LINUX_EXT_", "")
|
|
|
- self.package = package
|
|
|
- self.REGEX = re.compile(r"(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(package))
|
|
|
+ _, self.package = get_package_prefix_from_filename(self.filename)
|
|
|
+ self.REGEX = re.compile(r"(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(self.package))
|
|
|
self.FIND_VIRTUAL = re.compile(
|
|
|
- r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
|
|
|
+ r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(self.package))
|
|
|
self.virtual = []
|
|
|
|
|
|
def check_line(self, lineno, text):
|