Skip to content

Commit

Permalink
main: properly handles stage2 modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
liushuyu committed Jan 7, 2024
1 parent c04d03e commit 1d6ea0d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions acbs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'<ACBSPackageInfo {self.name}: deps: {self.deps} ; uri: {self.source_uri}>'
Expand Down
16 changes: 8 additions & 8 deletions acbs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions acbs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 1d6ea0d

Please sign in to comment.