4747 "https://gitlab.com/cip-project/cip-kernel/cip-kernel-config/-/raw/master/{branch}/{config}" # noqa
4848CROS_CONFIG_URL = \
4949 "https://chromium.googlesource.com/chromiumos/third_party/kernel/+archive/refs/heads/{branch}/chromeos/config.tar.gz" # noqa
50- LEGACY_CONFIG = [
51- 'config/core/build-configs.yaml' ,
52- '/etc/kernelci/core/build-configs.yaml' ,
53- ]
5450FW_GIT = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" # noqa
5551
5652# TODO: find a way to automatically fetch this information
@@ -153,7 +149,8 @@ class KBuild():
153149 if node, jobname and params are provided, create new build object
154150 if jsonobj is provided, load class from serialized json
155151 '''
156- def __init__ (self , node = None , jobname = None , params = None , jsonobj = None , apiconfig = None ):
152+ def __init__ (self , node = None , jobname = None , params = None , jsonobj = None , apiconfig = None ,
153+ fragment_configs = None ):
157154 # Retrieve and store API token for future use
158155 self ._api_token = os .environ .get ('KCI_API_TOKEN' )
159156 if not self ._api_token :
@@ -169,6 +166,7 @@ def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig
169166 if isinstance (self ._defconfig , str ) and '+' in self ._defconfig :
170167 self ._defconfig = self ._defconfig .split ('+' )
171168 self ._fragments = params ['fragments' ]
169+ self ._fragment_configs = fragment_configs or {}
172170 if 'coverage' in self ._fragments :
173171 self ._coverage = True
174172 else :
@@ -221,6 +219,7 @@ def __init__(self, node=None, jobname=None, params=None, jsonobj=None, apiconfig
221219 self ._compiler = jsonobj ['compiler' ]
222220 self ._defconfig = jsonobj ['defconfig' ]
223221 self ._fragments = jsonobj ['fragments' ]
222+ self ._fragment_configs = jsonobj .get ('fragment_configs' , {})
224223 self ._cross_compile = jsonobj ['cross_compile' ]
225224 self ._cross_compile_compat = jsonobj ['cross_compile_compat' ]
226225 self ._steps = jsonobj ['steps' ]
@@ -554,40 +553,16 @@ def extract_config(self, frag):
554553 txt += c + '\n '
555554 return txt
556555
557- def add_legacy_fragment (self , fragname ):
558- """ Add legacy config fragment from build-configs.yaml """
559- buffer = ''
560- yml = None
561- for cfg_path in LEGACY_CONFIG :
562- if not os .path .exists (cfg_path ):
563- continue
564- with open (cfg_path , 'r' ) as cfgfile :
565- content = cfgfile .read ()
566- yml = yaml .safe_load (content )
567- break
568-
569- if not yml :
570- print (f"No suitable config file found in { LEGACY_CONFIG } " )
571- self .submit_failure (f"No suitable config file found in { LEGACY_CONFIG } " )
572- sys .exit (1 )
573-
574- print (f"Searching for fragment { fragname } in { cfg_path } " )
575- if 'fragments' in yml :
576- frag = yml ['fragments' ]
577- else :
578- print ("No fragments section in config file" )
579- self .submit_failure ("No fragments section in config file" )
580- sys .exit (1 )
581-
582- if fragname in frag :
583- txt = self .extract_config (frag [fragname ])
584- buffer += txt
585- else :
586- print (f"Fragment { fragname } not found" )
587- self .submit_failure (f"Fragment { fragname } not found" )
556+ def add_fragment (self , fragname ):
557+ """ Get config fragment from passed fragment_configs """
558+ if fragname not in self ._fragment_configs :
559+ print (f"Fragment { fragname } not found in fragment_configs" )
560+ self .submit_failure (f"Fragment { fragname } not found in fragment_configs" )
588561 sys .exit (1 )
589562
590- return buffer
563+ frag = self ._fragment_configs [fragname ]
564+ print (f"Using fragment { fragname } from inline configs" )
565+ return self .extract_config (frag )
591566
592567 def _parse_fragments (self , firmware = False ):
593568 """ Parse fragments kbuild config and create config fragments """
@@ -601,8 +576,8 @@ def _parse_fragments(self, firmware=False):
601576 elif fragment .startswith ("CONFIG_" ):
602577 content = fragment + '\n '
603578 else :
604- # TODO: implement 'path' option properly
605- content = self .add_legacy_fragment (fragment )
579+ # Use fragment configs passed from scheduler
580+ content = self .add_fragment (fragment )
606581
607582 fragfile = os .path .join (self ._fragments_dir , f"{ num } .config" )
608583 with open (fragfile , 'w' ) as f :
0 commit comments