From patchwork Sun Feb 19 22:17:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Martincoski X-Patchwork-Id: 729668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vRLrK3Pvqz9s7R for ; Mon, 20 Feb 2017 09:23:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ggABrD4f"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C000B80C94; Sun, 19 Feb 2017 22:23:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7namPjsPhVKd; Sun, 19 Feb 2017 22:23:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 20E738822F; Sun, 19 Feb 2017 22:23:26 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 2BA821C1650 for ; Sun, 19 Feb 2017 22:23:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 274A880C94 for ; Sun, 19 Feb 2017 22:23:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UpVWq7P0rmzf for ; Sun, 19 Feb 2017 22:23:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 465E58827C for ; Sun, 19 Feb 2017 22:23:18 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id s186so6169100qkb.1 for ; Sun, 19 Feb 2017 14:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=chBEK6kDDInG5UulH3DZ9LBABFYeqO+evx602vEWCGE=; b=ggABrD4fmFXaNVsKT9JQVT14C2VamIh9hGa4gCh5XDIzNu44Xd4vD+8Gtf+bZXTsXf J57Lbv9oIRY+C3n7XJmNuRUWasM/ifDnS3wmRmjM/kd17SpHs9iKZRHgzPMCyxot/7jN 6wyYfg/bNvecDyWlVpv+a8vHhghFbAZXYTNoHa+SaZ0POmY5wv06m0OsYeXGVsvSKUtG 0ngUesOpba7bmrCx53f//38wD7wcQJ0A60HEMmpTGOThM+r9vhDjOVMuwU2KhHE5gfPW ok4U+DeWKyl8wV0SC+v5XUflD1UKbRNLLA72+udoaZYzTyBoKadgwkj4mk/xr+JhFh/r e3eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=chBEK6kDDInG5UulH3DZ9LBABFYeqO+evx602vEWCGE=; b=i+QXOA40LU5BnWGcLSay47hKQPl7pJG5+ZiEgrz8ZnCgZMYBiH2YD9CR+RLLylzSJZ Hm15ORPd+8veJrVS2E/4LsQjjpshDR2mxb4uNUUXgmF1UvpchlP1hi8DLto498cwUNYF +A+BjJ05wifrNcKHxOSpr3sWJULYDqyiosTYIYkpQtM6MhDXYdXKExwy1ECC7apPRlBQ 5pyqNDAwDOHZEqCPeEronZ2fggPsz6JovPKrOgviYFySbrza1SPkD111RT6wHQIbGSZL FDUjvsu+GdwQcbDiXDnJCSEcLU01KUwt1yiENfwVvfrVAl5hsDL9W8vRa15y1o/jnwgm pBsA== X-Gm-Message-State: AMke39mNfUM88LjOrlcioJmsrDaFKV3eTuYAHWe3Fy9PK0o2oCQh5XwIf3l0NxOWZyN+aQ== X-Received: by 10.55.160.143 with SMTP id j137mr8858634qke.146.1487542997209; Sun, 19 Feb 2017 14:23:17 -0800 (PST) Received: from ultri3.home ([201.86.219.185]) by smtp.gmail.com with ESMTPSA id d127sm10970245qka.30.2017.02.19.14.23.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Feb 2017 14:23:15 -0800 (PST) From: Ricardo Martincoski To: buildroot@buildroot.org Date: Sun, 19 Feb 2017 19:17:20 -0300 Message-Id: <20170219221724.27298-6-ricardo.martincoski@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170219221724.27298-1-ricardo.martincoski@gmail.com> References: <20170219221724.27298-1-ricardo.martincoski@gmail.com> In-Reply-To: <20161231032110.11573-1-ricardo.martincoski@gmail.com> References: <20161231032110.11573-1-ricardo.martincoski@gmail.com> Cc: Thomas Petazzoni , Thomas De Schampheleire , Ricardo Martincoski Subject: [Buildroot] [PATCH v2 5/9] check-package: check *.patch files X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Warn when the name of the patch file does not start with number (apply order), see [1]. Warn when the patch was generated using git format-patch without -N, see [2]. Warn when the patch file has no SoB, see [3]. [1] http://nightly.buildroot.org/#_providing_patches [2] http://patchwork.ozlabs.org/patch/704753/ [3] http://nightly.buildroot.org/#_format_and_licensing_of_the_package_patches Signed-off-by: Ricardo Martincoski Cc: Thomas De Schampheleire Cc: Thomas Petazzoni --- Changes v1 -> v2: - do not warn for numbered subject if the patch was not generated with git (based on comments from Thomas DS and Thomas P); - use classes instead of functions to declare each check (Thomas DS); --- Notes: $ time support/scripts/check-package $(find package -type f) >/dev/null 2>/dev/null real 0m0.935s user 0m0.904s sys 0m0.028s ApplyOrder: support/scripts/check-package --include-only ApplyOrder \ $(find package -name '*.patch') 2>/dev/null | wc -l 16 (cd support/scripts/check-package-example && \ ../check-package --include-only ApplyOrder -vv package/*/*) package/package1/wrong-name.patch:0: use name -.patch (http://nightly.buildroot.org/#_providing_patches) 180 lines processed 1 warnings generated NumberedSubject: support/scripts/check-package --include-only NumberedSubject \ $(find package -name '*.patch') 2>/dev/null | wc -l 139 (cd support/scripts/check-package-example && \ ../check-package --include-only NumberedSubject -vv package/*/*) package/package1/0001-do-something.patch:4: generate your patches with 'git format-patch -N' Subject: [PATCH 25/39] do something 180 lines processed 1 warnings generated Sob: support/scripts/check-package --include-only Sob \ $(find package -name '*.patch') 2>/dev/null | wc -l 143 (cd support/scripts/check-package-example && \ ../check-package --include-only Sob -vv package/*/*) package/package1/0001-do-something.patch:0: missing Signed-off-by in the header (http://nightly.buildroot.org/#_format_and_licensing_of_the_package_patches) package/package1/wrong-name.patch:0: missing Signed-off-by in the header (http://nightly.buildroot.org/#_format_and_licensing_of_the_package_patches) 180 lines processed 2 warnings generated support/scripts/checkpackagelib_patch.py | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/support/scripts/checkpackagelib_patch.py b/support/scripts/checkpackagelib_patch.py index 131e42347..ee46efb70 100644 --- a/support/scripts/checkpackagelib_patch.py +++ b/support/scripts/checkpackagelib_patch.py @@ -3,5 +3,60 @@ # functions don't need to check for things already checked by running # "make package-dirclean package-patch". +import re + +from checkpackagebase import _CheckFunction # Notice: ignore 'imported but unused' from pyflakes for check functions. from checkpackagelib 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 -.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)]