config: Allow a default repo to be specified for patches
Signed-off-by: Paul Barker <pbarker@konsulko.com> [Jan: style fix] Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
2260189fda
commit
b107a60118
@ -83,5 +83,6 @@ Added
|
||||
~~~~~
|
||||
|
||||
- ``defaults`` key can now be used to set a default value for the repository
|
||||
property ``refspec``. This default value will be used if the appropriate
|
||||
property is not defined for a given repository.
|
||||
property ``refspec`` and the repository patch property ``repo``. These
|
||||
default values will be used if the appropriate properties are not defined
|
||||
for a given repository or patch.
|
||||
|
@ -326,6 +326,16 @@ Configuration reference
|
||||
Sets the default ``refspec`` property applied to all repositories that
|
||||
do not override this.
|
||||
|
||||
* ``patches``: dict [optional]
|
||||
This key can contain default values for some repository patch
|
||||
properties. If a default value is set for a patch property it may
|
||||
still be overridden by setting the same property to a different value
|
||||
in a given patch.
|
||||
|
||||
* ``repo``: string [optional]
|
||||
Sets the default ``repo`` property applied to all repository
|
||||
patches that do not override this.
|
||||
|
||||
* ``machine``: string [optional]
|
||||
Contains the value of the ``MACHINE`` variable that is written into the
|
||||
``local.conf``. Can be overwritten by the ``KAS_MACHINE`` environment
|
||||
|
@ -83,6 +83,15 @@ CONFIGSCHEMA = {
|
||||
'refspec': {
|
||||
'type': 'string',
|
||||
},
|
||||
'patches': {
|
||||
'type': 'object',
|
||||
'additionalProperties': False,
|
||||
'properties': {
|
||||
'repo': {
|
||||
'type': 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -164,7 +173,7 @@ CONFIGSCHEMA = {
|
||||
{
|
||||
'type': 'object',
|
||||
'additionalProperties': False,
|
||||
'required': ['repo', 'path'],
|
||||
'required': ['path'],
|
||||
'properties': {
|
||||
'repo': {
|
||||
'type': 'string'
|
||||
|
19
kas/repos.py
19
kas/repos.py
@ -25,6 +25,7 @@
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
from urllib.parse import urlparse
|
||||
from .context import get_context
|
||||
@ -87,15 +88,23 @@ class Repo:
|
||||
str(laydict[x]).lower() not in
|
||||
['disabled', 'excluded', 'n', 'no', '0', 'false'],
|
||||
layers_dict))
|
||||
default_patch_repo = repo_defaults.get('patches', {}).get('repo', None)
|
||||
patches_dict = repo_config.get('patches', {})
|
||||
patches = list(
|
||||
{
|
||||
patches = []
|
||||
for p in sorted(patches_dict):
|
||||
if not patches_dict[p]:
|
||||
continue
|
||||
this_patch = {
|
||||
'id': p,
|
||||
'repo': patches_dict[p]['repo'],
|
||||
'repo': patches_dict[p].get('repo', default_patch_repo),
|
||||
'path': patches_dict[p]['path'],
|
||||
}
|
||||
for p in sorted(patches_dict)
|
||||
if patches_dict[p])
|
||||
if this_patch['repo'] is None:
|
||||
logging.error('No repo specified for patch entry "%s" and no '
|
||||
'default repo specified.', p)
|
||||
sys.exit(1)
|
||||
patches.append(this_patch)
|
||||
|
||||
url = repo_config.get('url', None)
|
||||
name = repo_config.get('name', name)
|
||||
typ = repo_config.get('type', 'git')
|
||||
|
Loading…
Reference in New Issue
Block a user