From 2ec573ca79131a205a48d8d3d8f0659efdf3c649 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 8 Nov 2022 15:01:37 +0100 Subject: [PATCH] Add linkpac --disable-build option --- osc/commandline.py | 8 +++++++- osc/core.py | 24 +++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 56505197..48ce03c7 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -2867,6 +2867,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='link the specified revision.') @cmdln.option('-f', '--force', action='store_true', help='overwrite an existing link file if it is there.') + @cmdln.option('--disable-build', action='store_true', + help='disable building of the linked package') @cmdln.option('-d', '--disable-publish', action='store_true', help='disable publishing of the linked package') @cmdln.option('-N', '--new-package', action='store_true', @@ -2931,7 +2933,11 @@ Please submit there instead, or use --nodevelproject to force direct submission. print('Revision \'%s\' does not exist' % rev, file=sys.stderr) sys.exit(1) - link_pac(src_project, src_package, dst_project, dst_package, opts.force, rev, opts.cicount, opts.disable_publish, opts.new_package, vrev) + link_pac( + src_project, src_package, dst_project, dst_package, opts.force, rev, opts.cicount, + opts.disable_publish, opts.new_package, vrev, + disable_build=opts.disable_build, + ) @cmdln.option('--nosources', action='store_true', help='ignore source packages when copying build results to destination project') diff --git a/osc/core.py b/osc/core.py index 94f647a0..82222b5f 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5303,7 +5303,7 @@ def link_to_branch(apiurl, project, package): raise oscerr.OscIOError(None, 'no _link file inside project \'%s\' package \'%s\'' % (project, package)) -def link_pac(src_project, src_package, dst_project, dst_package, force, rev='', cicount='', disable_publish=False, missing_target=False, vrev=''): +def link_pac(src_project, src_package, dst_project, dst_package, force, rev='', cicount='', disable_publish=False, missing_target=False, vrev='', disable_build=False): """ create a linked package - "src" is the original package @@ -5332,14 +5332,24 @@ def link_pac(src_project, src_package, dst_project, dst_package, force, rev='', src_meta = show_package_meta(apiurl, src_project, src_package) dst_meta = replace_pkg_meta(src_meta, dst_package, dst_project) - if disable_publish: + if disable_build or disable_publish: meta_change = True root = ET.fromstring(''.join(dst_meta)) - elm = root.find('publish') - if not elm: - elm = ET.SubElement(root, 'publish') - elm.clear() - ET.SubElement(elm, 'disable') + + if disable_build: + elm = root.find('build') + if not elm: + elm = ET.SubElement(root, 'build') + elm.clear() + ET.SubElement(elm, 'disable') + + if disable_publish: + elm = root.find('publish') + if not elm: + elm = ET.SubElement(root, 'publish') + elm.clear() + ET.SubElement(elm, 'disable') + dst_meta = ET.tostring(root, encoding=ET_ENCODING) if meta_change: