From 1bf17ce890a4b3e7d76ea9b7125407e7e346c4b3 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: May 19 2022 15:11:41 +0000 Subject: [PATCH 1/2] comps-sync.py: Minor Python lint fixes --- diff --git a/comps-sync.py b/comps-sync.py index aaabd93..dc94db3 100755 --- a/comps-sync.py +++ b/comps-sync.py @@ -1,27 +1,28 @@ #!/usr/bin/python3 # Usage: ./comps-sync.py /path/to/comps-f37.xml.in # -# Can both remove packages from the manifest -# which are not mentioned in comps, and add packages from -# comps. +# Can both remove packages from the manifest which are not mentioned in comps, +# and add packages from comps. -import os, sys, subprocess, argparse, shlex, json, yaml, re +import argparse +import re +import sys +import yaml import libcomps def fatal(msg): - print >>sys.stderr, msg + print(msg, file = sys.stderr) sys.exit(1) def format_pkgtype(n): if n == libcomps.PACKAGE_TYPE_DEFAULT: return 'default' - elif n == libcomps.PACKAGE_TYPE_MANDATORY: + if n == libcomps.PACKAGE_TYPE_MANDATORY: return 'mandatory' - else: - assert False + assert False def write_manifest(fpath, pkgs, include=None): - with open(fpath, 'w') as f: + with open(fpath, 'w', encoding='UTF-8') as f: f.write("# DO NOT EDIT! This content is generated from comps-sync.py\n") if include is not None: f.write("include: {}\n".format(include)) @@ -39,11 +40,11 @@ args = parser.parse_args() print("Syncing packages common to all desktops:") base_pkgs_path = 'fedora-common-ostree-pkgs.yaml' -with open(base_pkgs_path) as f: +with open(base_pkgs_path, encoding='UTF-8') as f: manifest = yaml.safe_load(f) manifest_packages = set(manifest['packages']) -with open('comps-sync-exclude-list.yml') as f: +with open('comps-sync-exclude-list.yml', encoding='UTF-8') as f: doc = yaml.safe_load(f) comps_exclude_list = doc['exclude_list'] comps_include_list = doc['include_list'] @@ -137,11 +138,12 @@ for desktop in [ 'gnome-desktop', 'kde-desktop', 'xfce-desktop', print("Syncing packages for {}:".format(desktop)) manifest_path = '{}-pkgs.yaml'.format(desktop) - with open(manifest_path) as f: + with open(manifest_path, encoding='UTF-8') as f: manifest = yaml.safe_load(f) manifest_packages = set(manifest['packages']) - # Filter packages in the comps desktop group using the exclude_list + # Filter packages in the comps groups associated with a given desktop using + # the per group exclude_list comps_group_pkgs = set() comps_group_pkgs = set() for pkg in comps.groups_match(id=desktop)[0].packages: pkgname = pkg.name From 57505782a17e201dc703f4ebd36e123cc919c545 Mon Sep 17 00:00:00 2001 From: Timothée Ravier Date: May 19 2022 15:11:41 +0000 Subject: [PATCH 2/2] comps-sync.py: Support multiple comps groups for a desktop Enable fetching packages from multiple comps groups for each desktop. This is currently unused but this removes the constraints around having all base packages for a given desktop in a single comps group. This could also be used to get packages from other groups such as the input-methods group for example. --- diff --git a/comps-sync.py b/comps-sync.py index dc94db3..6bb7514 100755 --- a/comps-sync.py +++ b/comps-sync.py @@ -131,13 +131,23 @@ else: if (n_manifest_new > 0 or n_comps_new > 0) and args.save: write_manifest(base_pkgs_path, manifest_packages) +# List of comps groups used for each desktop +desktops_comps_groups = { + "gnome": ["gnome-desktop"], + "kde": ["kde-desktop"], + "xfce": ["xfce-desktop"], + "lxqt": ["lxqt-desktop"], + "deepin": ["deepin-desktop"], + "pantheon": ["pantheon-desktop"], + "mate": ["mate-desktop"] +} + # Generate treefiles for all desktops -for desktop in [ 'gnome-desktop', 'kde-desktop', 'xfce-desktop', - 'lxqt-desktop', 'deepin-desktop', 'pantheon-desktop', 'mate-desktop']: +for desktop, groups in desktops_comps_groups.items(): print() print("Syncing packages for {}:".format(desktop)) - manifest_path = '{}-pkgs.yaml'.format(desktop) + manifest_path = '{}-desktop-pkgs.yaml'.format(desktop) with open(manifest_path, encoding='UTF-8') as f: manifest = yaml.safe_load(f) manifest_packages = set(manifest['packages']) @@ -145,12 +155,15 @@ for desktop in [ 'gnome-desktop', 'kde-desktop', 'xfce-desktop', # Filter packages in the comps groups associated with a given desktop using # the per group exclude_list comps_group_pkgs = set() comps_group_pkgs = set() - for pkg in comps.groups_match(id=desktop)[0].packages: - pkgname = pkg.name - exclude_list = comps_desktop_exclude_list.get(desktop, set()) - if pkgname in exclude_list or is_exclude_listed(pkgname): - continue - comps_group_pkgs.add(pkg.name) + for group in groups: + for pkg in comps.groups_match(id=group)[0].packages: + pkgname = pkg.name + exclude_list = comps_desktop_exclude_list.get(group, set()) + if exclude_list is None: + exclude_list = set() + if pkgname in exclude_list or is_exclude_listed(pkgname): + continue + comps_group_pkgs.add(pkg.name) # Look for packages in the manifest but not in comps group comps_unknown = set()