summaryrefslogtreecommitdiffstats
path: root/tools/checkpackagelib/lib_patch.py
diff options
context:
space:
mode:
authorYann E. MORIN <yann.morin.1998@free.fr>2017-07-01 16:31:03 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-07-01 17:54:19 +0200
commite518b38936fb836bebf7f2274c6d6cdc704e119a (patch)
treee118c74782bd625a368167734ee7201b93955b68 /tools/checkpackagelib/lib_patch.py
parent27b7bd6ad04b34b9bbcce5fb9e29677bc2afc606 (diff)
downloadbuildroot-e518b38936fb836bebf7f2274c6d6cdc704e119a.tar.gz
buildroot-e518b38936fb836bebf7f2274c6d6cdc704e119a.zip
tools: move check-package out of support/scripts/
Move it to the top-level tools/ directory, so that it is easier to find for users. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Arnout Vandecappelle <arnout@mind.be> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'tools/checkpackagelib/lib_patch.py')
-rw-r--r--tools/checkpackagelib/lib_patch.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/checkpackagelib/lib_patch.py b/tools/checkpackagelib/lib_patch.py
new file mode 100644
index 0000000000..3e1dae5f98
--- /dev/null
+++ b/tools/checkpackagelib/lib_patch.py
@@ -0,0 +1,62 @@
+# See tools/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)]
OpenPOWER on IntegriCloud