1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-12 16:56:15 +01:00

Add linkpac --disable-build option

This commit is contained in:
Daniel Mach 2022-11-08 15:01:37 +01:00
parent 6ddb8e4122
commit 2ec573ca79
2 changed files with 24 additions and 8 deletions

View File

@ -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')

View File

@ -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: