Allow specifying environment variables independently

This commit adds changes to allow specifying enviornment variables independently for each package. This is helpful to avoid influence of one env variable meant for a specific package on another which might result in changed behavior when it builds.
This commit is contained in:
Waqar Ahmed
2021-06-06 18:27:51 +05:00
parent 7cf19855f4
commit b3ad84f58a
3 changed files with 7 additions and 4 deletions

View File

@@ -181,6 +181,9 @@ sources:
repo: https://github.com/truenas/linux
branch: SCALE-v5.10-stable
batch_priority: 0
env:
CONFIG_DEBUG_INFO: "Y"
CONFIG_LOCALVERSION: "+truenas"
predepscmd:
- "apt install -y flex bison dwarves libssl-dev"
# We remove git files because kernel makefile tries to interact with git for determining version

View File

@@ -19,8 +19,7 @@ class BuildPackageMixin:
env={
**os.environ,
**APT_ENV,
'CONFIG_DEBUG_INFO': 'Y', # Build kernel with debug symbols
'CONFIG_LOCALVERSION': '+truenas',
**self.env,
}
)
@@ -71,7 +70,7 @@ class BuildPackageMixin:
predep_cmd = predep_entry['command']
skip_cmd = False
for env_var in predep_entry['env_checks']:
if os.environ.get(env_var['key']) != env_var['value']:
if all(f(env_var['key']) != env_var['value'] for f in (os.environ.get, self.env.get)):
self.logger.debug(
'Skipping %r predep command because %r does not match %r',
predep_cmd, env_var['key'], env_var['value']

View File

@@ -26,7 +26,7 @@ class Package(BootstrapMixin, BuildPackageMixin, BuildCleanMixin, OverlayMixin):
def __init__(
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,
buildcmd=None, tmpfs=True, tmpfs_size=12, batch_priority=100
buildcmd=None, tmpfs=True, tmpfs_size=12, batch_priority=100, env=None,
):
self.name = name
self.branch = branch
@@ -53,6 +53,7 @@ class Package(BootstrapMixin, BuildPackageMixin, BuildCleanMixin, OverlayMixin):
self.logger = logger
self.children = set()
self.batch_priority = batch_priority
self.env = env or {}
def __eq__(self, other):
return other == self.name if isinstance(other, str) else self.name == other.name