mirror of
https://github.com/truenas/scale-build.git
synced 2025-12-24 21:07:00 +00:00
Allow conditional consideration of specified sources for building/checkout
This commit is contained in:
@@ -7,7 +7,10 @@ _VERS = '22.12-MASTER'
|
|||||||
|
|
||||||
|
|
||||||
def get_env_variable(key, _type, default_value=None):
|
def get_env_variable(key, _type, default_value=None):
|
||||||
value = environ.get(key)
|
return get_normalized_value(environ.get(key), _type, default_value)
|
||||||
|
|
||||||
|
|
||||||
|
def get_normalized_value(value, _type, default_value=None):
|
||||||
if value:
|
if value:
|
||||||
if _type == bool:
|
if _type == bool:
|
||||||
if value.isdigit():
|
if value.isdigit():
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ from .clean import BuildCleanMixin
|
|||||||
from .git import GitPackageMixin
|
from .git import GitPackageMixin
|
||||||
from .overlay import OverlayMixin
|
from .overlay import OverlayMixin
|
||||||
from .utils import (
|
from .utils import (
|
||||||
DEPENDS_SCRIPT_PATH, gather_build_time_dependencies, normalize_build_depends, normalize_bin_packages_depends
|
DEPENDS_SCRIPT_PATH, gather_build_time_dependencies, get_normalized_build_constraint_value,
|
||||||
|
get_normalized_specified_build_constraint_value, normalize_build_depends, normalize_bin_packages_depends,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -25,12 +26,14 @@ class Package(BootstrapMixin, BuildPackageMixin, BuildCleanMixin, GitPackageMixi
|
|||||||
self, name, branch, repo, prebuildcmd=None, kernel_module=False, explicit_deps=None,
|
self, name, branch, repo, prebuildcmd=None, kernel_module=False, explicit_deps=None,
|
||||||
generate_version=True, predepscmd=None, deps_path=None, subdir=None, deoptions=None, jobs=None,
|
generate_version=True, predepscmd=None, deps_path=None, subdir=None, deoptions=None, jobs=None,
|
||||||
buildcmd=None, tmpfs=True, tmpfs_size=12, batch_priority=100, env=None, identity_file_path=None,
|
buildcmd=None, tmpfs=True, tmpfs_size=12, batch_priority=100, env=None, identity_file_path=None,
|
||||||
|
build_constraints=None,
|
||||||
):
|
):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.branch = branch
|
self.branch = branch
|
||||||
self.origin = repo
|
self.origin = repo
|
||||||
self.prebuildcmd = prebuildcmd or []
|
self.prebuildcmd = prebuildcmd or []
|
||||||
self.buildcmd = buildcmd or []
|
self.buildcmd = buildcmd or []
|
||||||
|
self.build_constraints = build_constraints or []
|
||||||
self.kernel_module = kernel_module
|
self.kernel_module = kernel_module
|
||||||
self.explicit_deps = set(explicit_deps or set())
|
self.explicit_deps = set(explicit_deps or set())
|
||||||
self.generate_version = generate_version
|
self.generate_version = generate_version
|
||||||
@@ -158,3 +161,11 @@ class Package(BootstrapMixin, BuildPackageMixin, BuildCleanMixin, GitPackageMixi
|
|||||||
@property
|
@property
|
||||||
def pkglist_hash_file_path(self):
|
def pkglist_hash_file_path(self):
|
||||||
return os.path.join(HASH_DIR, f'{self.name}.pkglist')
|
return os.path.join(HASH_DIR, f'{self.name}.pkglist')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def to_build(self):
|
||||||
|
return all(
|
||||||
|
get_normalized_build_constraint_value(constraint) == get_normalized_specified_build_constraint_value(
|
||||||
|
constraint
|
||||||
|
) for constraint in self.build_constraints
|
||||||
|
) if self.build_constraints else True
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
|
from scale_build.config import get_env_variable, get_normalized_value
|
||||||
|
|
||||||
|
|
||||||
|
CONSTRAINT_MAPPING = {
|
||||||
|
'boolean': bool,
|
||||||
|
'integer': int,
|
||||||
|
'string': str,
|
||||||
|
}
|
||||||
DEPENDS_SCRIPT_PATH = './scripts/parse_deps.pl'
|
DEPENDS_SCRIPT_PATH = './scripts/parse_deps.pl'
|
||||||
|
|
||||||
|
|
||||||
@@ -23,3 +31,11 @@ def gather_build_time_dependencies(packages, deps, deps_list):
|
|||||||
packages, deps, packages[dep].install_dependencies | packages[dep].build_dependencies
|
packages, deps, packages[dep].install_dependencies | packages[dep].build_dependencies
|
||||||
))
|
))
|
||||||
return deps
|
return deps
|
||||||
|
|
||||||
|
|
||||||
|
def get_normalized_specified_build_constraint_value(value_schema):
|
||||||
|
return get_env_variable(value_schema['name'], CONSTRAINT_MAPPING[value_schema['type']])
|
||||||
|
|
||||||
|
|
||||||
|
def get_normalized_build_constraint_value(value_schema):
|
||||||
|
return get_normalized_value(value_schema['value'], CONSTRAINT_MAPPING[value_schema['type']])
|
||||||
|
|||||||
@@ -90,6 +90,27 @@ MANIFEST_SCHEMA = {
|
|||||||
'type': 'array',
|
'type': 'array',
|
||||||
'items': [{'type': 'string'}],
|
'items': [{'type': 'string'}],
|
||||||
},
|
},
|
||||||
|
'build_constraints': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': [{
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'name': {'type': 'string'},
|
||||||
|
'value': {
|
||||||
|
'anyOf': [
|
||||||
|
{'type': 'string'},
|
||||||
|
{'type': 'integer'},
|
||||||
|
{'type': 'boolean'},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'type': {
|
||||||
|
'type': 'string',
|
||||||
|
'enum': ['bool', 'string', 'integer'],
|
||||||
|
},
|
||||||
|
'required': ['name', 'value', 'type'],
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
},
|
||||||
'buildcmd': {
|
'buildcmd': {
|
||||||
'type': 'array',
|
'type': 'array',
|
||||||
'items': [{'type': 'string'}],
|
'items': [{'type': 'string'}],
|
||||||
|
|||||||
@@ -4,4 +4,7 @@ from .manifest import get_manifest
|
|||||||
|
|
||||||
|
|
||||||
def get_packages():
|
def get_packages():
|
||||||
return [Package(**pkg) for pkg in get_manifest()['sources']]
|
return [
|
||||||
|
pkg for pkg in map(lambda p: Package(**p), get_manifest()['sources'])
|
||||||
|
if pkg.to_build
|
||||||
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user