From patchwork Sat Oct 5 12:22:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerzy Grzegorek X-Patchwork-Id: 1172192 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lMdTqCqG"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46lm9Y1mfDz9sCJ for ; Sat, 5 Oct 2019 22:23:13 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B66A120444; Sat, 5 Oct 2019 12:23:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Mddb5LzHxIda; Sat, 5 Oct 2019 12:23:07 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id ACCBD241C8; Sat, 5 Oct 2019 12:23:07 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id C8AC41BF29F for ; Sat, 5 Oct 2019 12:23:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C095687881 for ; Sat, 5 Oct 2019 12:23:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MndPv6RUBZp3 for ; Sat, 5 Oct 2019 12:23:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id BA72087863 for ; Sat, 5 Oct 2019 12:23:04 +0000 (UTC) Received: by mail-lj1-f196.google.com with SMTP id m13so9085227ljj.11 for ; Sat, 05 Oct 2019 05:23:04 -0700 (PDT) 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; bh=rSnNLn2jV9e4qFKFYkVRLc//vRepkcc9xf5Nu5mSgPc=; b=lMdTqCqGB5+sDc1NCele/MjZ634sk5s3TzziQJdjaE/3ETyd9ox5FmyAsFR2fDGfRN iKxPYvfLN+cp+fAjMRIhOYrW1ugbGcsklJP6g/bZV4hQQE+iYedLHZ5pP+rJ8oYBfF9S gsX1Mg1+G2QlrmXP2uAgPhLmbGtsdaxMl/ddKOLgUYdAm2RZr0ld9Uwxz5oh37LiPQDh wqJH5zJDvqjo/s8BAqMYPTQpIzLXDLGTicy53spbm2RkUNTlghI3K3OlOt/WR06jvcPo nMhCt63vkzOVx8hGB6zIkS8b9J0oHfWJDx8YQ0YW1HP/n+FbGGyNmNAkiuvD/9capDxR awYw== 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; bh=rSnNLn2jV9e4qFKFYkVRLc//vRepkcc9xf5Nu5mSgPc=; b=VamMBA2igUMc0o0E7GeOvUHqZBfA2bLeYcSH3sEk9EE7w03JTzf2OHmQQ81ppdI5OX zQ7Rfs+IGa6mPw93iSKbe0JMv0sskm9qTwz6enxzms/Orvbk3HQ+wAeCxwbAYDDRe/Iv 4BnYjBNcdSQZzkPe8R+zz6Var4PqjAb3p09ulicqmJcNf68D/4LII6cIQWm1Rmtrscnf hZl1rud8LW/+no1jWHe0RpnzEtt3eQBghC/YB6CbEi1zYUlbAUPdvgFkbd7OsTmzYYgX oca9ceWJDiyawagIz/IhER+dQLarNz68SFltTYPZFdH/qJC1vXMUzxm6bicnvuoMJMqH Z4jA== X-Gm-Message-State: APjAAAXbNCHt5D3VUcyp+XzZAjeNKjJK0rzSW8uDXsJgjoi3IhwVEgjr go+4Q54Jp1xb02TGlGxt+md0IQhZ X-Google-Smtp-Source: APXvYqz7Ao4GP4XxjAkFavNFr8YOL1o/XMklxbDTJM9bX8UZzU9BWrzFSfJ+D1zwESI+6Moi4GsG/w== X-Received: by 2002:a2e:7212:: with SMTP id n18mr12346079ljc.91.1570278182792; Sat, 05 Oct 2019 05:23:02 -0700 (PDT) Received: from localhost.localdomain (user-5-173-241-167.play-internet.pl. [5.173.241.167]) by smtp.gmail.com with ESMTPSA id h10sm1856214ljb.14.2019.10.05.05.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2019 05:23:02 -0700 (PDT) From: Jerzy Grzegorek To: buildroot@busybox.net Date: Sat, 5 Oct 2019 14:22:24 +0200 Message-Id: <20191005122227.7297-11-jerzy.m.grzegorek@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191005122227.7297-1-jerzy.m.grzegorek@gmail.com> References: <20191005122227.7297-1-jerzy.m.grzegorek@gmail.com> Subject: [Buildroot] [PATCH v2 10/13] utils/checkpackagelib: CommentsMenusPackagesOrder: check the order of menu of menus X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jerzy Grzegorek , Ricardo Martincoski MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" At any level if the 'menu ...' line occurs for the first time a new state '-menu' is added and all arrays elements for that level are initialized. For the second and subsequent times only packages arrays elements are initialized. Because of this that condition must be checked before appending elements to arrays. Therefore array's first_menu element must exist for that level and therefore this array must have one more element than the others and in time of initialization the higher level element of this array is initialized. The menu of menus corresponds to menu of packages of lower level. The alphabetical order of menus at that level is checked until the first error occurs. Signed-off-by: Jerzy Grzegorek Cc: Ricardo Martincoski --- utils/checkpackagelib/lib_config.py | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py index 06d45bd6ec..97d256bb1c 100644 --- a/utils/checkpackagelib/lib_config.py +++ b/utils/checkpackagelib/lib_config.py @@ -64,11 +64,14 @@ class CommentsMenusPackagesOrder(_CheckFunction): def before(self): self.comment = [""] self.comments_order_checking = [False] + self.first_menu = [True, True] self.level = 0 + self.menu = [""] self.menu_of_packages = ["The top level menu"] self.new_package = "" self.package = [""] self.print_comment_warning = [True] + self.print_menu_warning = [True] self.print_package_warning = [True] self.state = "" @@ -91,11 +94,17 @@ class CommentsMenusPackagesOrder(_CheckFunction): try: self.comment[self.level] = "" self.comments_order_checking[self.level] = False + self.first_menu[self.level+1] = True + self.menu[self.level] = "" self.print_comment_warning[self.level] = True + self.print_menu_warning[self.level] = True except IndexError: self.comment.append("") self.comments_order_checking.append(False) + self.first_menu.append(True) + self.menu.append("") self.print_comment_warning.append(True) + self.print_menu_warning.append(True) self.initialize_package_level_elements(text) @@ -148,7 +157,33 @@ class CommentsMenusPackagesOrder(_CheckFunction): self.state += "-menu" - self.initialize_level_elements(text) + self.level = self.get_level() + + if self.first_menu[self.level]: + self.first_menu[self.level] = False + + self.initialize_level_elements(text) + else: + self.initialize_package_level_elements(text) + + new_menu = text[6: -2:] + + if self.menu[self.level] != "" and \ + self.print_menu_warning[self.level] and \ + new_menu < self.menu[self.level]: + self.print_menu_warning[self.level] = False + prefix = "{}:{}: ".format(self.filename, lineno) + spaces = " " * len(prefix) + return ["{prefix}Menus in: {menu},\n" + "{spaces}are not alphabetically ordered;\n" + "{spaces}correct order: '-', '_', digits, capitals, lowercase;\n" + "{spaces}first incorrect menu: {comment}" + .format(prefix=prefix, spaces=spaces, + menu=self.menu_of_packages[self.level-1], + comment=new_menu), + text] + + self.menu[self.level] = new_menu elif text.startswith("endif") or text.startswith("endmenu"): if self.state.endswith("-comment"):