diff --git a/acbs/base.py b/acbs/base.py index 7c9ba95..02c152e 100644 --- a/acbs/base.py +++ b/acbs/base.py @@ -47,6 +47,12 @@ def __init__(self, name: str, deps: List[str], location: str, source_uri: List[A self.script_location = location # extra exported variables from spec self.exported: Dict[str, str] = {} + # modifiers to be applied to the source file/folder (only available in autobuild4) + self.modifiers: str = '' + + def is_in_stage2(modifiers: str) -> bool: + return '+stage2' in modifiers.lower() + def __repr__(self) -> str: return f'' diff --git a/acbs/main.py b/acbs/main.py index 9463dfe..dd29ee2 100644 --- a/acbs/main.py +++ b/acbs/main.py @@ -93,15 +93,13 @@ def __install_logger(self, str_verbosity=logging.INFO, '%(asctime)s:%(levelname)s:%(message)s')) logger.addHandler(log_file_handler) - def set_modifiers(self, p: str) -> str: - del os.environ['ABMODIFIERS'] + def strip_modifiers(self, p: str) -> Tuple[str, str]: if ':' in p: results = p.split(':', 1) if len(p) == 2: p, m = results - os.environ['ABMODIFIERS'] = m - return p - return p + return p, m + return p, '' def build(self) -> None: packages = [] @@ -114,12 +112,13 @@ def build(self) -> None: logging.info('Searching and resolving dependencies...') acbs.pm.reorder_mode = self.reorder for n, i in enumerate(self.build_queue): - i = self.set_modifiers(i) + i, modifiers = self.set_modifiers(i) if not validate_package_name(i): raise ValueError(f'Invalid package name: `{i}`') logging.debug(f'Finding {i}...') print(f'[{n + 1}/{len(self.build_queue)}] {i:30}\r', end='', flush=True) - package = find_package(i, self.tree_dir, stage2=self.stage2) + scoped_stage2 = ACBSPackageInfo.is_in_stage2(modifiers) | self.stage2 + package = find_package(i, self.tree_dir, stage2=scoped_stage2) if not package: raise RuntimeError(f'Could not find package {i}') packages.extend(package) @@ -268,7 +267,8 @@ def build_sequential(self, build_timings, packages: List[ACBSPackageInfo]): start = time.monotonic() task_name = f'{task.name} ({task.bin_arch} @ {task.epoch + ":" if task.epoch else ""}{task.version}-{task.rel})' try: - invoke_autobuild(task, build_dir, self.stage2) + scoped_stage2 = ACBSPackageInfo.is_in_stage2(task.modifiers) | stage2 + invoke_autobuild(task, build_dir, scoped_stage2) check_artifact(task.name, build_dir) except Exception: # early printing of build summary before exploding diff --git a/acbs/utils.py b/acbs/utils.py index a085181..02c9c46 100644 --- a/acbs/utils.py +++ b/acbs/utils.py @@ -199,6 +199,8 @@ def invoke_autobuild(task: ACBSPackageInfo, build_dir: str, stage2: bool): env_dict.update({'PKGREL': task.rel, 'PKGVER': task.version, 'PKGEPOCH': task.epoch or '0'}) env_dict.update(task.exported) + if task.modifiers: + env_dict['ABMODIFIERS'] = task.modifiers defines_file = 'defines' if stage2 and os.path.exists(os.path.join(build_dir, 'autobuild', 'defines.stage2')): defines_file = 'defines.stage2'