From eece7ac2724b1289a3069095a286884db0cc90b3 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Feb 14 2022 13:17:12 +0000 Subject: [PATCH 1/2] cli: allow to edit-chroot modules --- diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py index dfb8cbe..a92f3eb 100644 --- a/cli/copr_cli/main.py +++ b/cli/copr_cli/main.py @@ -659,8 +659,8 @@ class Commands(object): ownername=owner, projectname=copr, chrootname=chroot, comps=args.upload_comps, delete_comps=args.delete_comps, additional_packages=args.packages, additional_repos=args.repos, - bootstrap=args.bootstrap, bootstrap_image=args.bootstrap_image, - isolation=args.isolation, + additional_modules=args.modules, bootstrap=args.bootstrap, + bootstrap_image=args.bootstrap_image, isolation=args.isolation, ) print("Edit chroot operation was successful.") @@ -674,9 +674,9 @@ class Commands(object): project_chroot = self.client.project_chroot_proxy.get( ownername=owner, projectname=copr, chrootname=chroot ) - fields = ["additional_packages", "additional_repos", "comps_name", "delete_after_days", - "isolation", "mock_chroot", "ownername", "projectname", "with_opts", - "without_opts"] + fields = ["additional_packages", "additional_repos", "additional_modules", + "comps_name", "delete_after_days", "isolation", "mock_chroot", + "ownername", "projectname", "with_opts", "without_opts"] printer = get_printer(args.output_format, fields) printer.add_data(project_chroot) printer.finish() @@ -1404,6 +1404,8 @@ def setup_parser(): help="space separated string of package names to be added to buildroot") parser_edit_chroot.add_argument("--repos", help="space separated string of additional repo urls for chroot") + parser_edit_chroot.add_argument("--modules", + help="comma separated list of modules that will be enabled or disabled in the given chroot, e.g. 'module1:stream,!module2:stream'") parser_edit_chroot.add_argument("--isolation", choices=["simple", "nspawn", "default"], default="unchanged", help="Choose the isolation method for running commands in buildroot.") diff --git a/frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_project_chroots.py b/frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_project_chroots.py index f7664ff..c03e4a0 100644 --- a/frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_project_chroots.py +++ b/frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_project_chroots.py @@ -17,6 +17,7 @@ def to_dict(project_chroot): "comps_name": project_chroot.comps_name, "additional_repos": project_chroot.repos_list, "additional_packages": project_chroot.buildroot_pkgs_list, + "additional_modules": project_chroot.module_toggle, "with_opts": str_to_list(project_chroot.with_opts), "without_opts": str_to_list(project_chroot.without_opts), "delete_after_days": project_chroot.delete_after_days, @@ -31,6 +32,7 @@ def to_build_config_dict(project_chroot): "repos": config["repos"], "additional_repos": BuildConfigLogic.generate_additional_repos(project_chroot), "additional_packages": (project_chroot.buildroot_pkgs or "").split(), + "additional_modules": project_chroot.module_toggle, "enable_net": project_chroot.copr.enable_net, "with_opts": str_to_list(project_chroot.with_opts), "without_opts": str_to_list(project_chroot.without_opts), @@ -46,6 +48,7 @@ def rename_fields(input): replace = { "additional_repos": "repos", "additional_packages": "buildroot_pkgs", + "additional_modules": "module_toggle", } output = input.copy() for from_name, to_name in replace.items(): @@ -90,11 +93,13 @@ def edit_project_chroot(ownername, projectname, chrootname): if not form.validate_on_submit(): raise InvalidForm(form) - buildroot_pkgs = repos = comps_xml = comps_name = with_opts = without_opts = None + buildroot_pkgs = repos = module_toggle = comps_xml = comps_name = with_opts = without_opts = None if "buildroot_pkgs" in data: buildroot_pkgs = form.buildroot_pkgs.data if "repos" in data: repos = form.repos.data + if "module_toggle" in data: + module_toggle = form.module_toggle.data if "with_opts" in data: with_opts = form.with_opts.data if "without_opts" in data: @@ -106,7 +111,7 @@ def edit_project_chroot(ownername, projectname, chrootname): CoprChrootsLogic.remove_comps(flask.g.user, chroot) CoprChrootsLogic.update_chroot( flask.g.user, chroot, buildroot_pkgs, repos, comps=comps_xml, comps_name=comps_name, - with_opts=with_opts, without_opts=without_opts, + with_opts=with_opts, without_opts=without_opts, module_toggle=module_toggle, bootstrap=form.bootstrap.data, bootstrap_image=form.bootstrap_image.data, isolation=form.isolation.data) diff --git a/frontend/dump.rdb b/frontend/dump.rdb new file mode 100644 index 0000000..3e2a702 Binary files /dev/null and b/frontend/dump.rdb differ diff --git a/python/copr/v3/proxies/project_chroot.py b/python/copr/v3/proxies/project_chroot.py index 6251a41..ec64b05 100644 --- a/python/copr/v3/proxies/project_chroot.py +++ b/python/copr/v3/proxies/project_chroot.py @@ -49,7 +49,7 @@ class ProjectChrootProxy(BaseProxy): # pylint: disable=too-many-arguments def edit(self, ownername, projectname, chrootname, additional_packages=None, additional_repos=None, - comps=None, delete_comps=False, with_opts=None, without_opts=None, + additional_modules=None, comps=None, delete_comps=False, with_opts=None, without_opts=None, bootstrap=None, bootstrap_image=None, isolation=None): """ Edit a chroot configuration in a project @@ -59,6 +59,7 @@ class ProjectChrootProxy(BaseProxy): :param str chrootname: :param list additional_packages: buildroot packages for the chroot :param list additional_repos: buildroot additional additional_repos + :param list additional_modules: additional modules for the chroot :param str comps: file path to the comps.xml file :param bool delete_comps: if True, current comps.xml will be removed :param list with_opts: Mock --with option @@ -83,6 +84,7 @@ class ProjectChrootProxy(BaseProxy): data = { "additional_repos": additional_repos, "additional_packages": additional_packages, + "additional_modules": additional_modules, "delete_comps": delete_comps, "with_opts": with_opts, "without_opts": without_opts, From a82d31f67be1a9739751966788143797a2dc302d Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Feb 14 2022 13:17:12 +0000 Subject: [PATCH 2/2] cli: add edit-chroot --rpmbuild-with and --rpmbuild-without --- diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py index a92f3eb..729ec72 100644 --- a/cli/copr_cli/main.py +++ b/cli/copr_cli/main.py @@ -651,7 +651,6 @@ class Commands(object): :param args: argparse arguments provided by the user """ - if args.bootstrap_image: args.bootstrap = 'image' owner, copr, chroot = self.parse_chroot_path(args.coprchroot) @@ -659,8 +658,10 @@ class Commands(object): ownername=owner, projectname=copr, chrootname=chroot, comps=args.upload_comps, delete_comps=args.delete_comps, additional_packages=args.packages, additional_repos=args.repos, - additional_modules=args.modules, bootstrap=args.bootstrap, - bootstrap_image=args.bootstrap_image, isolation=args.isolation, + additional_modules=args.modules, with_opts=' '.join(args.rpmbuild_with), + without_opts=' '.join(args.rpmbuild_without), bootstrap=args.bootstrap, + bootstrap_image=args.bootstrap_image, + isolation=args.isolation, ) print("Edit chroot operation was successful.") @@ -1406,6 +1407,10 @@ def setup_parser(): help="space separated string of additional repo urls for chroot") parser_edit_chroot.add_argument("--modules", help="comma separated list of modules that will be enabled or disabled in the given chroot, e.g. 'module1:stream,!module2:stream'") + parser_edit_chroot.add_argument("--rpmbuild-with", action='append', default=[], + help="rpmbuild --with option, can be set multiple times") + parser_edit_chroot.add_argument("--rpmbuild-without", action='append', default=[], + help="rpmbuild --without options, can be set multiple times") parser_edit_chroot.add_argument("--isolation", choices=["simple", "nspawn", "default"], default="unchanged", help="Choose the isolation method for running commands in buildroot.")