mirror of
https://github.com/truenas/scale-build.git
synced 2025-12-24 21:07:00 +00:00
Add build environment variables when building packages
This commit is contained in:
@@ -16,7 +16,17 @@ class BuildPackageMixin:
|
||||
exception = CallError if exception_message else None
|
||||
run(
|
||||
f'chroot {self.dpkg_overlay} /bin/bash -c "{command}"', shell=True, logger=self.logger,
|
||||
exception=exception, exception_msg=exception_message
|
||||
exception=exception, exception_msg=exception_message, env={
|
||||
**os.environ,
|
||||
# When logging in as 'su root' the /sbin dirs get dropped out of PATH
|
||||
'PATH': f'{os.environ["PATH"]}:/sbin:/usr/sbin:/usr/local/sbin',
|
||||
'LC_ALL': 'C', # Makes some perl scripts happy during package builds
|
||||
'LANG': 'C',
|
||||
'DEB_BUILD_OPTIONS': f'parallel={os.cpu_count()}', # Passed along to WAF for parallel build,
|
||||
'CONFIG_DEBUG_INFO': 'N', # Build kernel with debug symbols
|
||||
'CONFIG_LOCALVERSION': '+truenas',
|
||||
'DEBIAN_FRONTEND': 'noninteractive', # Never go full interactive on any packages
|
||||
}
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
@@ -10,6 +10,7 @@ from scale_build.utils.variables import GIT_LOG_PATH, HASH_DIR, LOG_DIR, SOURCES
|
||||
|
||||
from .binary_package import BinaryPackage
|
||||
from .bootstrap import BootstrapMixin
|
||||
from .build import BuildPackageMixin
|
||||
from .clean import BuildCleanMixin
|
||||
from .overlay import OverlayMixin
|
||||
from .utils import DEPENDS_SCRIPT_PATH, get_install_deps, normalize_build_depends, normalize_bin_packages_depends
|
||||
@@ -18,7 +19,7 @@ from .utils import DEPENDS_SCRIPT_PATH, get_install_deps, normalize_build_depend
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Package(BootstrapMixin, BuildCleanMixin, OverlayMixin):
|
||||
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,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
@@ -11,7 +12,8 @@ def run(*args, **kwargs):
|
||||
check = kwargs.pop('check', True)
|
||||
shell = kwargs.pop('shell', False)
|
||||
logger = kwargs.pop('logger', None)
|
||||
proc = subprocess.Popen(args, stdout=kwargs['stdout'], stderr=kwargs['stderr'], shell=shell)
|
||||
env = kwargs.pop('env', None) or os.environ
|
||||
proc = subprocess.Popen(args, stdout=kwargs['stdout'], stderr=kwargs['stderr'], shell=shell, env=env)
|
||||
stdout, stderr = proc.communicate()
|
||||
cp = subprocess.CompletedProcess(args, proc.returncode, stdout=stdout, stderr=stderr)
|
||||
if logger:
|
||||
|
||||
Reference in New Issue
Block a user