2017-07-01 18:07:00 +02:00
|
|
|
# See utils/checkpackagelib/readme.txt before editing this file.
|
2017-02-19 23:17:17 +01:00
|
|
|
# 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".
|
|
|
|
|
2018-11-04 05:12:05 +01:00
|
|
|
import os
|
2017-02-19 23:17:20 +01:00
|
|
|
import re
|
|
|
|
|
2018-08-11 05:48:27 +02:00
|
|
|
from checkpackagelib.base import _CheckFunction
|
|
|
|
from checkpackagelib.lib import NewlineAtEof # noqa: F401
|
2021-12-26 19:49:16 +01:00
|
|
|
from checkpackagelib.tool import NotExecutable # noqa: F401
|
2017-02-19 23:17:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ApplyOrder(_CheckFunction):
|
2020-08-12 16:28:59 +02:00
|
|
|
APPLY_ORDER = re.compile(r"\d{1,4}-[^/]*$")
|
2017-02-19 23:17:20 +01:00
|
|
|
|
|
|
|
def before(self):
|
2018-11-04 05:12:05 +01:00
|
|
|
if not self.APPLY_ORDER.match(os.path.basename(self.filename)):
|
2017-02-19 23:17:20 +01:00
|
|
|
return ["{}:0: use name <number>-<description>.patch "
|
|
|
|
"({}#_providing_patches)"
|
|
|
|
.format(self.filename, self.url_to_manual)]
|
|
|
|
|
|
|
|
|
|
|
|
class NumberedSubject(_CheckFunction):
|
2020-08-12 16:28:59 +02:00
|
|
|
NUMBERED_PATCH = re.compile(r"Subject:\s*\[PATCH\s*\d+/\d+\]")
|
2017-02-19 23:17:20 +01:00
|
|
|
|
|
|
|
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):
|
2020-08-12 16:28:59 +02:00
|
|
|
SOB_ENTRY = re.compile(r"^Signed-off-by: .*$")
|
2017-02-19 23:17:20 +01:00
|
|
|
|
|
|
|
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)]
|
2023-04-03 16:41:04 +02:00
|
|
|
|
|
|
|
class Upstream(_CheckFunction):
|
|
|
|
UPSTREAM_ENTRY = re.compile(r"^Upstream: .*$")
|
|
|
|
|
|
|
|
def before(self):
|
|
|
|
self.found = False
|
|
|
|
|
|
|
|
def check_line(self, lineno, text):
|
|
|
|
if self.found:
|
|
|
|
return
|
|
|
|
if self.UPSTREAM_ENTRY.search(text):
|
|
|
|
self.found = True
|
|
|
|
|
|
|
|
def after(self):
|
|
|
|
if not self.found:
|
|
|
|
return ["{}:0: missing Upstream in the header "
|
|
|
|
"({}#_additional_patch_documentation)"
|
|
|
|
.format(self.filename, self.url_to_manual)]
|