From patchwork Mon Feb 6 07:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1738038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=rUKa/7PH; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P9HZs0f60z23r4 for ; Mon, 6 Feb 2023 18:15:01 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pOviI-0002fs-WF; Mon, 06 Feb 2023 07:14:54 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pOviF-0002fP-MY for kernel-team@lists.ubuntu.com; Mon, 06 Feb 2023 07:14:51 +0000 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9CEF13F2F8 for ; Mon, 6 Feb 2023 07:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675667690; bh=xLJDT9XYFNlV/jLsQ/4Ds3K23rrab9y2lKY+GLsqDF4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rUKa/7PH8mrV0UKN0v52xkprWrLWPs/gaf0RBsiXRsK8Ovts/qQGOiY/HdQsy7nfH QGmvZ2iJqun++Kc5bPLU2V14hHvh/s0HIjR9GDRGH5QhajoW9J5ZORqSIu0ak+cow7 TH/I7Nq2FGKb0Uqrfg8exd5HomPJ+v4+aItcyjkMNBWW2OPrrhmvgt061EyVPSRw35 3TsL0kL0p3A4IvFUlSowMtC/IbyNUvB0XtHcXVv0ztI86C1I3h7KbN7oixEFPwJw/g IbTzOrCrx7tW+QFh4s/N/6VfkZAzNAkTLZ7E4vMD9lse4RZyjEtPrNTP0HsHItI9if zt2fukBFlXfiQ== Received: by mail-ed1-f69.google.com with SMTP id w3-20020a056402268300b00487e0d9b53fso7118853edd.10 for ; Sun, 05 Feb 2023 23:14:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xLJDT9XYFNlV/jLsQ/4Ds3K23rrab9y2lKY+GLsqDF4=; b=raiPXuqz8kfBBa+GTi4t1Gg2IMA6Hb1ajeF6TDYwfC7kXW3E9FaV9iBFvYp3dL42Q/ fpV4//1TICEIic+g/HVfN/BEqs9Rl7GGpwhaXF0WQuI+XjFDt33oF5OAiaYLHdMUc7hD W33QcpA8KupzUR/t+CHfLoNW+OLJKHz1M4CI6kOZG5bwWYKmxTOh3wcu9hmEcDk2jNfR eSs1Yjr/lKRKt+z1Eopd63Tsldm8Dua7iUXhA6pJRtOX3qmhIjLMx1K9frWA+3ewe30Z JQwaocPtihnG09jEq1TZ6wmlFqErPKfF0LKDe3EO+HYoq7XzZJW5eWxSbzfxUGmlsQd0 wBPQ== X-Gm-Message-State: AO0yUKVvT5fJ0TBjmLPtEwT8vLMcaE3c6dGNX34gT2Dy7Z/aCwo8/TcO MTLhbzCNYRSbExqu2bubMBSB6kLO/sQcBwZI/FlmsePXgBbKgW73SLGrqpHSHE/caJD4o4LdgzL f5ZVdKcWE4gmHenkpdSTl29Wij+s6UAdokiS7H3ENAg== X-Received: by 2002:a17:907:3f83:b0:88a:d760:19ac with SMTP id hr3-20020a1709073f8300b0088ad76019acmr22357089ejc.1.1675667690424; Sun, 05 Feb 2023 23:14:50 -0800 (PST) X-Google-Smtp-Source: AK7set9FszoMyPhG6m3BtfrdxVgROzV3jyJICxD6HBmaN7pA+HaKjHz5LIQfmIYvvxxXzt/PVhWk5A== X-Received: by 2002:a17:907:3f83:b0:88a:d760:19ac with SMTP id hr3-20020a1709073f8300b0088ad76019acmr22357078ejc.1.1675667690232; Sun, 05 Feb 2023 23:14:50 -0800 (PST) Received: from gollum.fritz.box ([194.191.244.86]) by smtp.gmail.com with ESMTPSA id l2-20020a170906a40200b0084d35ffbc20sm5084180ejz.68.2023.02.05.23.14.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 23:14:49 -0800 (PST) From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [Unstable/Lunar][PATCH v2 1/2] UBUNTU: [Packaging] annotations: Handle single-line annoation rules Date: Mon, 6 Feb 2023 08:14:47 +0100 Message-Id: <20230206071448.713716-2-juerg.haefliger@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206071448.713716-1-juerg.haefliger@canonical.com> References: <20230206071448.713716-1-juerg.haefliger@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" The old annotations file allowed single-line rules such as: CONFIG_FOO policy<'amd64': 'n'> note The new annotations parser doesn't support that, so add it. Signed-off-by: Juerg Haefliger --- debian/scripts/misc/kconfig/annotations.py | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index df3bf11e7320..cb73232b01e7 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -56,8 +56,8 @@ class Annotation(Config): # Convert multiple spaces to single space to simplifly parsing data = re.sub(r' *', ' ', data) - # Handle includes (recursively) for line in data.splitlines(): + # Handle includes (recursively) m = re.match(r'^include\s+"?([^"]*)"?', line) if m: self.include.append(m.group(1)) @@ -65,24 +65,28 @@ class Annotation(Config): include_data = self._load(include_fname) self._parse_body(include_data) else: - # Skip empty, non-policy and non-note lines - if re.match('.* policy<', line) or re.match('.* note<', line): + # Handle policy and note lines + if re.match(r'.* (policy|note)<', line): try: - # Parse single policy or note rule conf = line.split(' ')[0] if conf in self.config: entry = self.config[conf] else: entry = {'policy': {}} - m = re.match(r'.*policy<(.*)>', line) + + match = False + m = re.match(r'.* policy<(.*?)>', line) if m: + match = True entry['policy'] |= literal_eval(m.group(1)) - else: - m = re.match(r'.*note<(.*?)>', line) - if m: - entry['note'] = "'" + m.group(1).replace("'", '') + "'" - else: - raise Exception('syntax error') + + m = re.match(r'.* note<(.*?)>', line) + if m: + match = True + entry['note'] = "'" + m.group(1).replace("'", '') + "'" + + if not match: + raise Exception('syntax error') self.config[conf] = entry except Exception as e: raise Exception(str(e) + f', line = {line}') From patchwork Mon Feb 6 07:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1738040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=suNfgVJ0; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P9HZt3sLTz23y3 for ; Mon, 6 Feb 2023 18:15:02 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pOviK-0002gb-7x; Mon, 06 Feb 2023 07:14:56 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pOviH-0002fQ-3L for kernel-team@lists.ubuntu.com; Mon, 06 Feb 2023 07:14:53 +0000 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7B0F83F194 for ; Mon, 6 Feb 2023 07:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675667691; bh=VtnZm2vWyAX2nMyrsMJZSfEo2ccqqxPEcl2pE3CfLvA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=suNfgVJ0lCsdI9Z4M7TYI6PkqaAiEQvUL3m/i4RfmBLg1BIsDYeO6AV0R4MIZ+S1g J+UTVnYiscSm8JlWhJ5+WF4h8rFuQBp+qDcihLy7fR7OlcWj9qvH6FYJ4eonw+jVMJ a1mIJ8ObfPnyjnmDygGb1g+PrpcAR9lg284ax8Wm1h8Ga3/bEwJmjWwTAvOcrQ4qPj PO7vU/lK+EgX5zQZRl0K5790fFP5nYjmQuaig0/LDXPtU4cHHHR8MebQO4jMT7QT9T U2tIXD5wnzHEoNnIkK8Hi+Ci9bIA+ZFeFZJl6rUremErXLFoIq2gqX+TJ3qbEXeUw+ iRKhDIAOlxLDQ== Received: by mail-ej1-f72.google.com with SMTP id p16-20020a170906499000b0088c5a527c89so8039781eju.23 for ; Sun, 05 Feb 2023 23:14:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VtnZm2vWyAX2nMyrsMJZSfEo2ccqqxPEcl2pE3CfLvA=; b=ne4aSG22p1vcb1BiwGbLUpQTWFEaVVP5RVt3oFUKp9WkBPrVLIwr+aXXKOzRSqXYhY KaKXflRVkfN2gxTNggFmXoO0fusuIxiUcw+lpOQt3W0Shbl/7UWbivJI7vhIeEyESTwu yejgaOHuu3ad+f0rhlrueXlqBvFN7W+0WFjJr6ulIqeHO43j7Y4ds1fpo9NuuUAEsaQP BkHxTvjzzwcef/kR1GbSS6mTlNSwhKasGZQWpjPAbUl6P4jgr8GHHzCVTKjxr+fabq2N n3HMTGeNVXh7ktxUjNqGi4tobEWhdbAZfK30riy7XpHkryp8HF3SopyzM+bRE4OHRYA8 SDaQ== X-Gm-Message-State: AO0yUKVfyQuHctCFWh2IAXC3zSrPaJ7FupKN/RCgxariKQRjCsKqE+B/ WqbKko7OSWASjIhnzZ/bRuOKtoWBRKf5DutP3djbFIHWil/cWyqMOBlPcRtIptDWr94VgxXlC9j 2LqREvVFxJHmBmtfasnvCK4+CWcrBvMGveRznzJlXqg== X-Received: by 2002:a17:907:2bc2:b0:878:7189:a457 with SMTP id gv2-20020a1709072bc200b008787189a457mr18430976ejc.51.1675667691207; Sun, 05 Feb 2023 23:14:51 -0800 (PST) X-Google-Smtp-Source: AK7set9ZekQa0du215jZAlOwqkk70dYcuC/VrpnxfaWrOD4s9pouxylLP/gM3r90D2PksDe+Uoq1Xw== X-Received: by 2002:a17:907:2bc2:b0:878:7189:a457 with SMTP id gv2-20020a1709072bc200b008787189a457mr18430965ejc.51.1675667690952; Sun, 05 Feb 2023 23:14:50 -0800 (PST) Received: from gollum.fritz.box ([194.191.244.86]) by smtp.gmail.com with ESMTPSA id l2-20020a170906a40200b0084d35ffbc20sm5084180ejz.68.2023.02.05.23.14.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Feb 2023 23:14:50 -0800 (PST) From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [Unstable/Lunar][PATCH v2 2/2] UBUNTU: [Packaging] annotations: Preserve single-line annotation rules Date: Mon, 6 Feb 2023 08:14:48 +0100 Message-Id: <20230206071448.713716-3-juerg.haefliger@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206071448.713716-1-juerg.haefliger@canonical.com> References: <20230206071448.713716-1-juerg.haefliger@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" Currently, rules with notes are written out as separate lines, i. e., one line for the policy and one line for the note, followed by an empty line. The parser now supports single line rules so preserve that style when writting out the rules. Signed-off-by: Juerg Haefliger --- debian/scripts/misc/kconfig/annotations.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index cb73232b01e7..dd9c05fbb8e4 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -82,6 +82,7 @@ class Annotation(Config): m = re.match(r'.* note<(.*?)>', line) if m: + entry['oneline'] = match match = True entry['note'] = "'" + m.group(1).replace("'", '') + "'" @@ -284,11 +285,16 @@ class Annotation(Config): if 'policy' in new_val: val = dict(sorted(new_val['policy'].items())) line = f"{conf : <47} policy<{val}>" - tmp.write(line + "\n") if 'note' in new_val: val = new_val['note'] - line = f"{conf : <47} note<{val}>" - tmp.write(line + "\n\n") + if new_val.get('oneline', False): + # Single line + line += f' note<{val}>' + else: + # Separate policy and note lines, + # followed by an empty line + line += f'\n{conf : <47} note<{val}>\n' + tmp.write(line + "\n") # Replace annotations with the updated version tmp.flush()