summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/check-package32
1 files changed, 27 insertions, 5 deletions
diff --git a/utils/check-package b/utils/check-package
index a87a74decc..d2457c706c 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -4,6 +4,7 @@
from __future__ import print_function
import argparse
import inspect
+import os
import re
import sys
@@ -24,6 +25,9 @@ def parse_args():
parser.add_argument("files", metavar="F", type=str, nargs="*",
help="list of files")
+ parser.add_argument("--br2-external", "-b", dest='intree_only', action="store_false",
+ help="do not apply the pathname filters used for intree files")
+
parser.add_argument("--manual-url", action="store",
default="http://nightly.buildroot.org/",
help="default: %(default)s")
@@ -41,12 +45,21 @@ def parse_args():
CONFIG_IN_FILENAME = re.compile("/Config\.\S*$")
-FILE_IS_FROM_A_PACKAGE = re.compile("package/[^/]*/")
+DO_CHECK_INTREE = re.compile("|".join([
+ "package/",
+ ]))
+DO_NOT_CHECK_INTREE = re.compile("|".join([
+ "package/doc-asciidoc\.mk$",
+ "package/pkg-\S*\.mk$",
+ ]))
def get_lib_from_filename(fname):
- if FILE_IS_FROM_A_PACKAGE.search(fname) is None:
- return None
+ if flags.intree_only:
+ if DO_CHECK_INTREE.match(fname) is None:
+ return None
+ if DO_NOT_CHECK_INTREE.match(fname):
+ return None
if CONFIG_IN_FILENAME.search(fname):
return checkpackagelib.lib_config
if fname.endswith(".hash"):
@@ -117,7 +130,16 @@ def __main__():
global flags
flags = parse_args()
- if len(flags.files) == 0:
+ if flags.intree_only:
+ # change all paths received to be relative to the base dir
+ base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+ files_to_check = [os.path.relpath(os.path.abspath(f), base_dir) for f in flags.files]
+ # move current dir so the script find the files
+ os.chdir(base_dir)
+ else:
+ files_to_check = flags.files
+
+ if len(files_to_check) == 0:
print("No files to check style")
sys.exit(1)
@@ -125,7 +147,7 @@ def __main__():
total_warnings = 0
total_lines = 0
- for fname in flags.files:
+ for fname in files_to_check:
nwarnings, nlines = check_file_using_lib(fname)
total_warnings += nwarnings
total_lines += nlines