comps-sync.py: Move code under main function

This commit is contained in:
Timothée Ravier 2023-09-27 18:29:36 +02:00
parent 4ca120676a
commit fd1056f739

View file

@ -154,39 +154,40 @@ def update_manifests_from_groups(comps, groups, path, desktop, save, comps_exclu
else: else:
write_manifest(path, manifest_packages, include="fedora-common-ostree.yaml") write_manifest(path, manifest_packages, include="fedora-common-ostree.yaml")
parser = argparse.ArgumentParser() def main():
parser.add_argument("--save", help="Write changes", action='store_true') parser = argparse.ArgumentParser()
parser.add_argument("src", help="Source path") parser.add_argument("--save", help="Write changes", action='store_true')
parser.add_argument("src", help="Source path")
args = parser.parse_args() args = parser.parse_args()
with open('comps-sync-exclude-list.yml', encoding='UTF-8') as f: with open('comps-sync-exclude-list.yml', encoding='UTF-8') as f:
doc = yaml.safe_load(f) doc = yaml.safe_load(f)
comps_exclude_list = doc['exclude_list'] comps_exclude_list = doc['exclude_list']
comps_exclude_list_groups = doc['exclude_list_groups'] comps_exclude_list_groups = doc['exclude_list_groups']
comps_desktop_exclude_list = doc['desktop_exclude_list'] comps_desktop_exclude_list = doc['desktop_exclude_list']
comps_exclude_list_all = [re.compile(x) for x in doc['exclude_list_all_regexp']] comps_exclude_list_all = [re.compile(x) for x in doc['exclude_list_all_regexp']]
# Parse comps, and build up a set of all packages so we can find packages not # Parse comps, and build up a set of all packages so we can find packages not
# listed in comps *at all*, beyond just the workstation environment. # listed in comps *at all*, beyond just the workstation environment.
comps = libcomps.Comps() comps = libcomps.Comps()
comps.fromxml_f(args.src) comps.fromxml_f(args.src)
# Parse the workstation-product environment to get the list of comps groups to # Parse the workstation-product environment to get the list of comps groups to
# get packages from. # get packages from.
groups = [] groups = []
for gid in comps.environments['workstation-product-environment'].group_ids: for gid in comps.environments['workstation-product-environment'].group_ids:
if gid.name in comps_exclude_list_groups: if gid.name in comps_exclude_list_groups:
continue continue
groups.append(gid.name) groups.append(gid.name)
# Always include the packages from the workstation-ostree-support group # Always include the packages from the workstation-ostree-support group
groups.append('workstation-ostree-support') groups.append('workstation-ostree-support')
update_manifests_from_groups(comps, groups, 'fedora-common-ostree-pkgs.yaml', "common", args.save, comps_exclude_list, comps_exclude_list_all) update_manifests_from_groups(comps, groups, 'fedora-common-ostree-pkgs.yaml', "common", args.save, comps_exclude_list, comps_exclude_list_all)
# List of comps groups used for each desktop # List of comps groups used for each desktop
desktops_comps_groups = { desktops_comps_groups = {
"gnome": ["gnome-desktop", "base-x"], "gnome": ["gnome-desktop", "base-x"],
"kde": ["kde-desktop", "base-x"], "kde": ["kde-desktop", "base-x"],
"xfce": ["xfce-desktop", "base-x"], "xfce": ["xfce-desktop", "base-x"],
@ -196,9 +197,12 @@ desktops_comps_groups = {
"sway": ["swaywm", "swaywm-extended"], "sway": ["swaywm", "swaywm-extended"],
"cinnamon": ["cinnamon-desktop", "base-x"], "cinnamon": ["cinnamon-desktop", "base-x"],
"budgie": ["budgie-desktop", "budgie-desktop-apps", "base-x"] "budgie": ["budgie-desktop", "budgie-desktop-apps", "base-x"]
} }
# 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()
update_manifests_from_groups(comps, groups, f'{desktop}-desktop-pkgs.yaml', desktop, args.save, comps_desktop_exclude_list, comps_exclude_list_all) update_manifests_from_groups(comps, groups, f'{desktop}-desktop-pkgs.yaml', desktop, args.save, comps_desktop_exclude_list, comps_exclude_list_all)
if __name__ == "__main__":
main()