From 4c5d0cf18a4833e16ea0d791b34bdab2bbee6fdf Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 8 Nov 2022 15:34:55 +0100 Subject: [PATCH] Add branch --disable-build option --- osc/commandline.py | 8 ++++++-- osc/core.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 48ce03c7..d303cff0 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3539,6 +3539,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='specify the used block strategy for new repositories') @cmdln.option('--add-repositories-rebuild', metavar='add_repositories_rebuild', help='specify the used rebuild strategy for new repositories') + @cmdln.option('--disable-build', action='store_true', + help='disable building of the branched package') def do_branch(self, subcmd, opts, *args): """ Branch a package @@ -3608,7 +3610,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. add_repositories_rebuild=opts.add_repositories_rebuild, extend_package_names=opts.extend_package_names, missingok=opts.new_package, - maintenance=opts.maintenance) + maintenance=opts.maintenance, + disable_build=opts.disable_build) except oscerr.NotMissing as e: print('NOTE: Package target exists already via project links, link will point to given project.') print(' A submission will initialize a new instance.') @@ -3625,7 +3628,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. extend_package_names=opts.extend_package_names, missingok=False, maintenance=opts.maintenance, - newinstance=opts.new_package) + newinstance=opts.new_package, + disable_build=opts.disable_build) if exists: print('Using existing branch project: %s' % targetprj, file=sys.stderr) diff --git a/osc/core.py b/osc/core.py index 82222b5f..9cdf4890 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5576,7 +5576,7 @@ def attribute_branch_pkg(apiurl, attribute, maintained_update_project_attribute, return r -def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, linkrev=None, target_project=None, target_package=None, return_existing=False, msg='', force=False, noaccess=False, add_repositories=False, add_repositories_block=None, add_repositories_rebuild=None, extend_package_names=False, missingok=False, maintenance=False, newinstance=False): +def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, linkrev=None, target_project=None, target_package=None, return_existing=False, msg='', force=False, noaccess=False, add_repositories=False, add_repositories_block=None, add_repositories_rebuild=None, extend_package_names=False, missingok=False, maintenance=False, newinstance=False, disable_build=False): """ Branch a package (via API call) """ @@ -5636,6 +5636,20 @@ def branch_pkg(apiurl, src_project, src_package, nodevelproject=False, rev=None, data = {} for i in root.findall('data'): data[i.get('name')] = i.text + + if disable_build: + target_meta = show_package_meta(apiurl, data["targetproject"], data["targetpackage"]) + root = ET.fromstring(b''.join(target_meta)) + + elm = root.find('build') + if not elm: + elm = ET.SubElement(root, 'build') + elm.clear() + ET.SubElement(elm, 'disable') + + target_meta = ET.tostring(root, encoding=ET_ENCODING) + edit_meta('pkg', path_args=(data["targetproject"], data["targetpackage"]), data=target_meta) + return (False, data.get('targetproject', None), data.get('targetpackage', None), data.get('sourceproject', None), data.get('sourcepackage', None))