summaryrefslogtreecommitdiff
path: root/tools/net/ynl/lib
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-03-16 02:03:51 +0300
committerJakub Kicinski <kuba@kernel.org>2023-03-17 07:22:44 +0300
commitcfab77c0b54583816faac5f9abdf588c13895a9d (patch)
treec685a68f1745c443da27948d0fa02410290b58b2 /tools/net/ynl/lib
parent4e16b6a748df52800c90f3ab181aef8129bd332f (diff)
downloadlinux-cfab77c0b54583816faac5f9abdf588c13895a9d.tar.xz
ynl: make the tooling check the license
The (only recently documented) expectation is that all specs are under a certain license, but we don't actually enforce it. What's worse we then go ahead and assume the license was right, outputting the expected license into generated files. Fixes: 37d9df224d1e ("ynl: re-license uniformly under GPL-2.0 OR BSD-3-Clause") Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net/ynl/lib')
-rw-r--r--tools/net/ynl/lib/nlspec.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
index e01a72d06638..d04450c2a44a 100644
--- a/tools/net/ynl/lib/nlspec.py
+++ b/tools/net/ynl/lib/nlspec.py
@@ -274,6 +274,7 @@ class SpecFamily(SpecElement):
Attributes:
proto protocol type (e.g. genetlink)
+ license spec license (loaded from an SPDX tag on the spec)
attr_sets dict of attribute sets
msgs dict of all messages (index by name)
@@ -283,6 +284,13 @@ class SpecFamily(SpecElement):
"""
def __init__(self, spec_path, schema_path=None):
with open(spec_path, "r") as stream:
+ prefix = '# SPDX-License-Identifier: '
+ first = stream.readline().strip()
+ if not first.startswith(prefix):
+ raise Exception('SPDX license tag required in the spec')
+ self.license = first[len(prefix):]
+
+ stream.seek(0)
spec = yaml.safe_load(stream)
self._resolution_list = []