Skip to content

Commit fb9e7ee

Browse files
committed
Generate full availability report for the components
1 parent 7a5b455 commit fb9e7ee

File tree

1 file changed

+75
-21
lines changed

1 file changed

+75
-21
lines changed

jobs.py

Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class RebuildContext:
6666
missing_packages: dict = field(default_factory=lambda: collections.defaultdict(set))
6767
unresolvable_components: set = field(default_factory=set)
6868
prerel_abi_blocked_components: set = field(default_factory=set)
69+
component_availability: dict = field(default_factory=dict)
6970

7071

7172
def _query_packages_by_deps(sack_getter, deps, excluded_components):
@@ -486,31 +487,45 @@ def check_bcond_build(component, bcond_config, number_of_resolved, ctx):
486487
return ready_to_rebuild
487488

488489

490+
def extract_bcond_identifier(s):
491+
non_empty_parts = [p for p in s.split(':') if p]
492+
return non_empty_parts[1] if len(non_empty_parts) >= 2 else None
493+
494+
489495
def check_bcond_builds(component, number_of_resolved, ctx):
490496
"""
491497
Check all bcond builds for a component that isn't ready for regular build.
492-
498+
493499
Args:
494500
component: Name of the component to check
495501
number_of_resolved: Number of packages in regular build (for comparison)
496502
ctx: RebuildContext with shared data and state
497-
503+
498504
Prints any bcond build identifiers that are ready to rebuild.
505+
506+
Returns:
507+
tuple: (buildable_bconds, non_buildable_bconds)
499508
"""
500509
from bconds import bcond_cache_identifier
501-
502-
if component not in CONFIG['bconds']:
503-
return
504-
505-
for bcond_config in CONFIG['bconds'][component]:
506-
bcond_config['id'] = bcond_cache_identifier(component, bcond_config)
507-
log(f'• {component} not ready and {bcond_config["id"]} bcond found, will check that one')
508-
509-
ready_to_rebuild = check_bcond_build(component, bcond_config, number_of_resolved, ctx)
510-
511-
if ready_to_rebuild:
512-
if should_print_component(component, ctx.components_done):
513-
print(bcond_config['id'])
510+
511+
buildable_bconds = []
512+
non_buildable_bconds = []
513+
514+
if component in CONFIG['bconds']:
515+
for bcond_config in CONFIG['bconds'][component]:
516+
bcond_config['id'] = bcond_cache_identifier(component, bcond_config)
517+
log(f'• {component} not ready and {bcond_config["id"]} bcond found, will check that one')
518+
519+
ready_to_rebuild = check_bcond_build(component, bcond_config, number_of_resolved, ctx)
520+
521+
if ready_to_rebuild:
522+
if should_print_component(component, ctx.components_done):
523+
print(bcond_config['id'])
524+
buildable_bconds.append(extract_bcond_identifier(bcond_config['id']))
525+
else:
526+
non_buildable_bconds.append(extract_bcond_identifier(bcond_config['id']))
527+
528+
return sorted(buildable_bconds), sorted(non_buildable_bconds)
514529

515530

516531
def should_print_component(component, components_done):
@@ -526,20 +541,30 @@ def should_print_component(component, components_done):
526541
def process_component(component, ctx):
527542
"""
528543
Process a single component: check regular build and bcond builds if needed.
529-
544+
Stores availability data in ctx.component_availability.
545+
530546
Args:
531547
component: Name of the component to process
532548
ctx: RebuildContext with shared data and state
533-
549+
534550
Prints the component or bcond identifier if ready to rebuild.
535551
"""
536552
ready_to_rebuild, number_of_resolved = check_regular_build(component, ctx)
537-
553+
availability = {
554+
'can_build_regular': ready_to_rebuild,
555+
'buildable_bconds': [],
556+
'non_buildable_bconds': [],
557+
}
558+
538559
if ready_to_rebuild:
539560
if should_print_component(component, ctx.components_done):
540561
print(component)
541562
else:
542-
check_bcond_builds(component, number_of_resolved, ctx)
563+
buildable_bconds, non_buildable_bconds = check_bcond_builds(component, number_of_resolved, ctx)
564+
availability['buildable_bconds'] = buildable_bconds
565+
availability['non_buildable_bconds'] = non_buildable_bconds
566+
567+
ctx.component_availability[component] = availability
543568

544569

545570
def assemble_component_info(component, count, ctx):
@@ -596,7 +621,6 @@ def generate_reports(ctx):
596621
log('\nThe 20 most commonly last-blocking small combinations of components are:')
597622
for components_tuple, count in ctx.blocker_counter['combinations'].most_common(20):
598623
log(f'{count:>5} {", ".join(components_tuple)}')
599-
600624
report_data['most_commonly_last_blocking_combinations'].append({
601625
'components': list(components_tuple),
602626
'count': count
@@ -610,6 +634,35 @@ def generate_reports(ctx):
610634
log('\nReport saved to commonly-needed-report.json')
611635

612636

637+
def generate_component_availability_report(ctx):
638+
"""
639+
Generate and save full component availability report.
640+
Creates component-availability-report.json with per-component data.
641+
642+
Args:
643+
ctx: RebuildContext with component availability data
644+
"""
645+
646+
report_data = {}
647+
for component in ctx.components:
648+
availability = ctx.component_availability.get(component, {})
649+
650+
report_data[component] = {
651+
'was_already_built': component in ctx.components_done,
652+
'is_resolvable': component not in ctx.unresolvable_components,
653+
'prerel_abi_compatible': component not in ctx.prerel_abi_blocked_components,
654+
'can_build_regular': availability.get('can_build_regular', False),
655+
'buildable_bconds': availability.get('buildable_bconds'),
656+
'non_buildable_bconds': availability.get('non_buildable_bconds'),
657+
'blocked_by': sorted(ctx.loop_detector.get(component, [])),
658+
'blocks_count': ctx.blocker_counter['general'].get(component, 0)
659+
}
660+
661+
with open('component-availability-report.json', 'w') as f:
662+
json.dump(report_data, f, indent=2, sort_keys=True)
663+
log('Full component availability report saved to component-availability-report.json')
664+
665+
613666
def main():
614667
"""
615668
Main entry point for rebuild analysis.
@@ -638,8 +691,9 @@ def main():
638691

639692
for component in components_to_process:
640693
process_component(component, ctx)
641-
694+
642695
generate_reports(ctx)
696+
generate_component_availability_report(ctx)
643697

644698

645699
if __name__ == '__main__':

0 commit comments

Comments
 (0)