124124 ])
125125]
126126
127+ # OOT kernel module specs to match the `last-known-kernel` with kernel-headers `version`
128+ oot_kmodule_matching_groups = [
129+ frozenset ([
130+ "SPECS/fwctl/fwctl.spec" ,
131+ "SPECS/iser/iser.spec" ,
132+ "SPECS/isert/isert.spec" ,
133+ "SPECS/knem/knem.spec" ,
134+ "SPECS/mft_kernel/mft_kernel.spec" ,
135+ "SPECS/mlnx-nfsrdma/mlnx-nfsrdma.spec" ,
136+ "SPECS/mlnx-ofa_kernel/mlnx-ofa_kernel.spec" ,
137+ "SPECS/srp/srp.spec" ,
138+ "SPECS/xpmem/xpmem.spec"
139+ ])
140+ ]
141+
127142def check_spec_tags (base_path : str , tags : List [str ], groups : List [FrozenSet ]) -> Set [FrozenSet ]:
128143 """Returns spec sets which violate matching rules for given tags. """
129144 err_groups = set ()
@@ -141,6 +156,21 @@ def check_spec_tags(base_path: str, tags: List[str], groups: List[FrozenSet]) ->
141156 return err_groups
142157
143158
159+ def check_oot_kmodules (base_path : str , tag : str , groups : List [FrozenSet ]) -> Set [FrozenSet ]:
160+ """Returns OOT kernel modules which violate matching with kernel-headers version. """
161+ err_groups = set ()
162+
163+ kernel_headers_spec = Spec .from_file (path .join (base_path , "SPECS/kernel-headers/kernel-headers.spec" ))
164+ kernel_headers_version = get_tag_value (kernel_headers_spec , 'version' )
165+
166+ for group in groups :
167+ for spec_filename in group :
168+ parsed_spec = Spec .from_file (path .join (base_path , spec_filename ))
169+ tag_value = get_tag_value (parsed_spec , tag )
170+ if tag_value != kernel_headers_version :
171+ err_groups .add (spec_filename )
172+ return err_groups
173+
144174def check_mstflintver_match_groups (base_path : str ) -> Set [FrozenSet ]:
145175 return check_spec_tags (base_path , ['mstflintver' ], mstflintver_matching_groups )
146176
@@ -153,16 +183,23 @@ def check_version_release_match_groups(base_path: str) -> Set[FrozenSet]:
153183def check_version_match_groups (base_path : str ) -> Set [FrozenSet ]:
154184 return check_spec_tags (base_path , ['epoch' , 'version' ], version_matching_groups )
155185
186+ def check_oot_kmodule_matching_groups (base_path : str ) -> Set [FrozenSet ]:
187+ return check_oot_kmodules (base_path , 'last-known-kernel' , oot_kmodule_matching_groups )
156188
157189def check_matches (base_path : str ):
158190 version_match_errors = check_version_match_groups (base_path )
159191 version_release_match_errors = check_version_release_match_groups (base_path )
160192 sdkver_match_errors = check_sdkver_match_groups (base_path )
161193 mstflintver_match_errors = check_mstflintver_match_groups (base_path )
194+ oot_kmodule_match_errors = check_oot_kmodule_matching_groups (base_path )
162195
163196 printer = pprint .PrettyPrinter ()
164197
165- if len (version_match_errors ) or len (version_release_match_errors ) or len (sdkver_match_errors ) or len (mstflintver_match_errors ):
198+ if len (version_match_errors ) or \
199+ len (version_release_match_errors ) or \
200+ len (sdkver_match_errors ) or \
201+ len (mstflintver_match_errors ) or \
202+ len (oot_kmodule_match_errors ):
166203 print ('The current repository state violates a spec entanglement rule!' )
167204
168205 if len (version_match_errors ):
@@ -182,13 +219,19 @@ def check_matches(base_path: str):
182219 '\n Please update the following sets of specs to have the same "sdkver" global variables:' )
183220 for e in sdkver_match_errors :
184221 printer .pprint (e )
185-
222+
186223 if len (mstflintver_match_errors ):
187224 print (
188225 '\n Please update the following sets of specs to have the same "mstflintver" global variables:' )
189226 for e in mstflintver_match_errors :
190227 printer .pprint (e )
191-
228+
229+ if len (oot_kmodule_match_errors ):
230+ print (
231+ '\n Please update the following sets of specs to match the "last-known-kernel" global variable with kernel-headers "version":' )
232+ for e in oot_kmodule_match_errors :
233+ printer .pprint (e )
234+
192235 sys .exit (1 )
193236
194237
0 commit comments