diff options
author | Ricardo Martincoski <ricardo.martincoski@gmail.com> | 2017-04-19 15:06:21 -0300 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2017-04-20 22:29:41 +0200 |
commit | 7b394c4926dcb860a356eeb46b1f1f5d807041f7 (patch) | |
tree | 0b61db0b8f7433dc1c2619ab3f0353201c84bcd0 /support/scripts/checkpackagelib/lib_patch.py | |
parent | 33481124c7913fbdaee327afd97fd8ba138434e6 (diff) | |
download | buildroot-7b394c4926dcb860a356eeb46b1f1f5d807041f7.tar.gz buildroot-7b394c4926dcb860a356eeb46b1f1f5d807041f7.zip |
check-package: move parts to subdirectory
Currently the check-package script uses many files in the same
directory. This commit keeps the main script in support/scripts/ and
moves the rest into a subdirectory.
The modules were previously prefixed to make it easy to identify which
script they belong to. This is no longer needed when using a
subdirectory, so the prefix is removed.
Note: if this commit is checked out and the script is run, and later on
a previous version is checked out, the file
support/scripts/checkpackagelib/__init__.pyc needs to be manually
removed to prevent Python interpreter to look for checkpackagelib
package when only the checkpackagelib module is available.
Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support/scripts/checkpackagelib/lib_patch.py')
-rw-r--r-- | support/scripts/checkpackagelib/lib_patch.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/support/scripts/checkpackagelib/lib_patch.py b/support/scripts/checkpackagelib/lib_patch.py new file mode 100644 index 0000000000..c191d262e2 --- /dev/null +++ b/support/scripts/checkpackagelib/lib_patch.py @@ -0,0 +1,62 @@ +# See support/scripts/checkpackagelib/readme.txt before editing this file. +# The format of the patch files is tested during the build, so below check +# functions don't need to check for things already checked by running +# "make package-dirclean package-patch". + +import re + +from base import _CheckFunction +# Notice: ignore 'imported but unused' from pyflakes for check functions. +from lib import NewlineAtEof + + +class ApplyOrder(_CheckFunction): + APPLY_ORDER = re.compile("/\d{1,4}-[^/]*$") + + def before(self): + if not self.APPLY_ORDER.search(self.filename): + return ["{}:0: use name <number>-<description>.patch " + "({}#_providing_patches)" + .format(self.filename, self.url_to_manual)] + + +class NumberedSubject(_CheckFunction): + NUMBERED_PATCH = re.compile("Subject:\s*\[PATCH\s*\d+/\d+\]") + + def before(self): + self.git_patch = False + self.lineno = 0 + self.text = None + + def check_line(self, lineno, text): + if text.startswith("diff --git"): + self.git_patch = True + return + if self.NUMBERED_PATCH.search(text): + self.lineno = lineno + self.text = text + + def after(self): + if self.git_patch and self.text: + return ["{}:{}: generate your patches with 'git format-patch -N'" + .format(self.filename, self.lineno), + self.text] + + +class Sob(_CheckFunction): + SOB_ENTRY = re.compile("^Signed-off-by: .*$") + + def before(self): + self.found = False + + def check_line(self, lineno, text): + if self.found: + return + if self.SOB_ENTRY.search(text): + self.found = True + + def after(self): + if not self.found: + return ["{}:0: missing Signed-off-by in the header " + "({}#_format_and_licensing_of_the_package_patches)" + .format(self.filename, self.url_to_manual)] |