comps-sync.py: Use new functions for desktop specific manifests

This commit is contained in:
Timothée Ravier 2023-09-27 16:01:16 +02:00
parent 044096449c
commit db352bcf69

View file

@ -192,72 +192,34 @@ desktops_comps_groups = {
# Generate treefiles for all desktops # Generate treefiles for all desktops
for desktop, groups in desktops_comps_groups.items(): for desktop, groups in desktops_comps_groups.items():
print() print()
print(f'Syncing packages for {desktop}:')
manifest_path = f'{desktop}-desktop-pkgs.yaml' manifest_path = f'{desktop}-desktop-pkgs.yaml'
manifest_packages = load_packages_from_manifest(manifest_path) manifest_packages = load_packages_from_manifest(manifest_path)
# Filter packages in the comps desktop group using the exclude_list
comps_group_pkgs = {} comps_group_pkgs = {}
for arch in ARCHES:
filtered = comps.arch_filter([arch])
for group in groups: for group in groups:
for pkg in filtered.groups_match(id=group)[0].packages:
pkgname = pkg.name
exclude_list = comps_desktop_exclude_list.get(group, set()) exclude_list = comps_desktop_exclude_list.get(group, set())
if pkgname in exclude_list or is_exclude_listed(pkgname, comps_exclude_list_all): comps_group_pkgs = load_packages_from_comps_group(comps_group_pkgs, comps, group, exclude_list, comps_exclude_list_all)
continue
if pkgname in comps_group_pkgs:
comps_group_pkgs[pkgname].add(arch)
else:
comps_group_pkgs[pkgname] = set([arch])
comps_unknown = set() (comps_unknown, pkgs_added) = compare_comps_manifest_package_lists(comps_group_pkgs, manifest_packages)
for arch in manifest_packages:
for pkg in manifest_packages[arch]:
if arch == "all":
if pkg in comps_group_pkgs and set(comps_group_pkgs[pkg]) == set(ARCHES):
continue
else:
if pkg in comps_group_pkgs and arch in comps_group_pkgs[pkg]:
continue
comps_unknown.add((pkg, arch))
# Look for packages in the manifest but not in comps at all
n_manifest_new = len(comps_unknown) n_manifest_new = len(comps_unknown)
if n_manifest_new == 0: n_comps_new = len(pkgs_added)
print(" - All manifest packages are already listed in comps.") print(f'Syncing packages for {desktop}:\t+{n_comps_new}, -{n_manifest_new}')
else: if n_manifest_new != 0:
print(f' - {n_manifest_new} packages not in {ws_env_name}:')
for (pkg, arch) in sorted(comps_unknown, key = lambda x: x[0]): for (pkg, arch) in sorted(comps_unknown, key = lambda x: x[0]):
print(f' {pkg} (arch: {arch})')
manifest_packages[arch].remove(pkg) manifest_packages[arch].remove(pkg)
print(f' - {pkg} (arches: {arch})')
if n_comps_new != 0:
# Look for packages in comps but not in the manifest for pkg in sorted(pkgs_added):
desktop_pkgs_added = {} (req, groups, arches) = pkgs_added[pkg]
for (pkg, parches) in comps_group_pkgs.items(): if set(ARCHES) == arches:
if set(ARCHES) == set(parches):
if pkg not in manifest_packages['all']:
desktop_pkgs_added[pkg] = parches
manifest_packages['all'].add(pkg) manifest_packages['all'].add(pkg)
print(' + {} ({}, groups: {}, arches: all)'.format(pkg, format_pkgtype(req), ', '.join(groups)))
else: else:
for arch in parches: for arch in arches:
if pkg not in manifest_packages[arch]:
manifest_packages[arch].add(pkg) manifest_packages[arch].add(pkg)
if pkg not in desktop_pkgs_added: print(' + {} ({}, groups: {}, arches: {})'.format(pkg, format_pkgtype(req), ', '.join(groups), ', '.join(arches)))
desktop_pkgs_added[pkg] = set([arch])
else:
desktop_pkgs_added[pkg].add(arch)
n_comps_new = len(desktop_pkgs_added)
if n_comps_new == 0:
print(" - All comps packages are already listed in manifest.")
else:
print(f' - {n_comps_new} packages not in {desktop} manifest:')
for pkg in sorted(desktop_pkgs_added):
arches = desktop_pkgs_added[pkg]
print(' {} (arches: {})'.format(pkg, ', '.join(arches)))
# Update manifest # Update manifest
if (n_manifest_new > 0 or n_comps_new > 0) and args.save: if (n_manifest_new > 0 or n_comps_new > 0) and args.save: