From patchwork Tue Feb 7 10:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1738824 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=GLTLRTqg; 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 4P9zNf2FCxz23jB for ; Tue, 7 Feb 2023 21:08:33 +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 1pPKth-0007oU-0b; Tue, 07 Feb 2023 10:08:21 +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 1pPKtf-0007oK-DT for kernel-team@lists.ubuntu.com; Tue, 07 Feb 2023 10:08:19 +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-0.canonical.com (Postfix) with ESMTPS id 370863F194 for ; Tue, 7 Feb 2023 10:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675764499; bh=BifoqKce+PTa0QTJEzmJt3WDaZwu3qVCNkCUaCVA1jk=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=GLTLRTqge/xDgTUpB9t+C2jNoKq4hAdA+89+Yg4DAStRlYUZ9L2UNeF8hkVCLfYMI ptZPgCsesHeksZs0BDW/ttv9kFbv4RhyTTpMfbfwQRIplJ0Zn7Dl6sVAvqm7RVpI0p O1we7XGjj7dHCtybaGifNbGcXDM7YVVgXQ2H1gcD0wso7uG/gmFqohD6/NeDwZ0b+Y voNrVfiIxNlX5eLYPmYOgUNzKKouJjrt4RifCGEdTIgIxNVbYAwYB5rEQ3gGjSkE6J XD47EADPiBcpI1VoQK5q2nxqb3siWHDE8/A5huzgN4OTYiD+uJBJ6QszFh9gbPLSed EdPkkDZLicOCQ== Received: by mail-ed1-f69.google.com with SMTP id cb24-20020a0564020b7800b004aab5e79e6bso3254398edb.23 for ; Tue, 07 Feb 2023 02:08:19 -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:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BifoqKce+PTa0QTJEzmJt3WDaZwu3qVCNkCUaCVA1jk=; b=Ts6i3omZVWLbZAvJmZ/DcdTW4gtgVVnfQlBwdC8oSJAHgT+AN6X6r3I0vz+yHEd9MU +gtpnZUZdrSLGhUUNahmD3eJeer5FEv1EXE/WQjdSON+bAMX+//xqCkJmGipNKupPFqj Hyo7jaIMlwuxC+QmhsTfDsbgVCX7J2fXdIVUot2lE6D0ld2nC83PMY1xAfAaehBQ88xU J6z6SPV4zDcUuAkocYUApq76s8XbeoKXcVdeavx5nGQHPE76u9rrYECoKeSAHz1uVjw0 lsH1cLV+Dq7NJa98v6PkF3vrpCCKayPb53M3/RikNfo4O49NJ3Bsen8lTt/R5AjlrUIn islA== X-Gm-Message-State: AO0yUKWoT0ZoRM/G+KyrfnzTxUoVvRlkgc9ZZkb8RhfMo/sZEL51N7Vd tlxRGIiyp1M+Ecig7BV+RnqqgTHimqA6s3xljriZRsMhYetLpDNqTJu6rJXJ3OloU+aByaWXgEa SLT4SCMcHWLO09Ggg8NSNhjS0IF8TLb70BH3TcD3/eQ5AirY= X-Received: by 2002:a05:6402:321b:b0:4aa:cf80:44af with SMTP id g27-20020a056402321b00b004aacf8044afmr1333107eda.7.1675764498919; Tue, 07 Feb 2023 02:08:18 -0800 (PST) X-Google-Smtp-Source: AK7set/TuabAd4yDEkFRQ1kszTieUpMPTv1H4ZwuMLKECUwwTU6DpBh8+P3gG6SFLMcS8++1RFgWEA== X-Received: by 2002:a05:6402:321b:b0:4aa:cf80:44af with SMTP id g27-20020a056402321b00b004aacf8044afmr1333097eda.7.1675764498715; Tue, 07 Feb 2023 02:08:18 -0800 (PST) Received: from gollum.fritz.box ([194.191.244.86]) by smtp.gmail.com with ESMTPSA id j29-20020a508a9d000000b004aac83d6554sm994841edj.47.2023.02.07.02.08.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 02:08:18 -0800 (PST) From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [Unstable/Lunar][PATCH] UBUNTU: [Packaging] annotations: Check validity of FLAVOUR_DEP Date: Tue, 7 Feb 2023 11:08:17 +0100 Message-Id: <20230207100817.960389-1-juerg.haefliger@canonical.com> X-Mailer: git-send-email 2.34.1 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" FLAVOUR_DEP is used to map flavors from the main annotations file to flavors from includes. Currently, there is no check that any of the listed flavors exists or is valid so the resulting behavior is (probably) undefined/unexpected. Add a sanity check to verify the FLAVOUR_DEP flavors. Signed-off-by: Juerg Haefliger --- debian/scripts/misc/kconfig/annotations.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index 113ce53eb4e0..1711257bd7ab 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -57,8 +57,17 @@ class Annotation(Config): line = re.sub(r' +', ' ', line) line = line.strip() - # Ignore empty lines and comments - if not line or line.startswith('#'): + # Ignore empty lines + if not line: + continue + + # Catpure flavors of included files + if line.startswith('# FLAVOUR: '): + self.include_flavour += line.split(' ')[2:] + continue + + # Ignore comments + if line.startswith('#'): continue # Handle includes (recursively) @@ -112,6 +121,7 @@ class Annotation(Config): self.flavour_dep = {} self.include = [] self.header = '' + self.include_flavour = [] # Parse header (only main header will considered, headers in includes # will be treated as comments) @@ -133,6 +143,13 @@ class Annotation(Config): # Parse body (handle includes recursively) self._parse_body(data) + # Sanity check: Verify that all FLAVOUR_DEP flavors are valid + for src, tgt in self.flavour_dep.items(): + if src not in self.flavour: + raise Exception(f'Invalid source flavour in FLAVOUR_DEP: {src}') + if tgt not in self.include_flavour: + raise Exception(f'Invalid target flavour in FLAVOUR_DEP: {tgt}') + def _remove_entry(self, config: str): if self.config[config]: del self.config[config]