Skip to content

Commit

Permalink
cooker: Add overridden distro configuration for poky
Browse files Browse the repository at this point in the history
- Add function to get the overridden distro configuration if it exists
- Add rule in schema to allow to add a new entry in menu

Signed-off-by: Ever ATILANO <[email protected]>
Reviewed-by: Yoann Congal <[email protected]>
  • Loading branch information
Ever ATILANO authored and pboettch committed Feb 23, 2023
1 parent 77992fa commit ed0a53b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cooker/cooker-menu-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,25 @@

"notes": {
"$ref": "#/definitions/notes"
},

"override_distro": {
"type": "object",
"properties": {
"base_directory": {
"type": "string",
"minLength": 1
},
"build_script": {
"type": "string",
"minLength": 1
},
"template_conf": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": false
}
},
"required": ["sources", "builds"],
Expand Down
11 changes: 11 additions & 0 deletions cooker/cooker.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ def __init__(self, config, menu):
self.distro = distros[name.lower()]
except:
fatal_error('base-distribution {} is unknown, please add a `base-distribution.py` file next your menu.'.format(name))

# Update distro if custom distro is defined in menu
self.update_override_distro()

def init(self, menu_name, layer_dir=None, build_dir=None, dl_dir=None, sstate_dir=None):
""" cooker-command 'init': (re)set the configuration file """
Expand Down Expand Up @@ -766,6 +769,14 @@ def shell(self, build_names: List[str]):
if not CookerCall.os.replace_process(shell, [shell, '-c', ". {} {}; {}".format(init_script, build_dir, shell)]):
fatal_error('could not run interactive shell for {} with {}', build_names[0], shell)

def update_override_distro(self):
""" update distro values from menu file if exists """
override_distro = self.menu.get("override_distro", {})
if override_distro:
self.distro.BASE_DIRECTORY = override_distro.get("base_directory", self.distro.BASE_DIRECTORY)
self.distro.BUILD_SCRIPT = override_distro.get("build_script", self.distro.BUILD_SCRIPT)
# Template conf must be a tuple
self.distro.TEMPLATE_CONF = (override_distro.get("template_conf", self.distro.TEMPLATE_CONF),)

class CookerCall:
"""
Expand Down

0 comments on commit ed0a53b

Please sign in to comment.