From b63f3ba772b03ad8a43623048967b75b068d223f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 6 Aug 2021 09:57:25 +0200 Subject: [PATCH] fix buildinfo inconsistency We need to send local _service files together with build description files to get a valid answer. Old OBS instances can run into an error state now, since the cpio post is not supported there. But this is better then the wrong answer. osc buildinfo did not list buildtime service depencies when call in local working directory, where a build description file exist. It did work outside of the directory when no local build description was send. --- osc/commandline.py | 7 +++++-- osc/core.py | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index 76eb7e5d15..f8ad87a768 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -6038,7 +6038,7 @@ def do_buildinfo(self, subcmd, opts, *args): wd = os.curdir args = slash_split(args) - project = package = repository = arch = build_descr = None + project = package = repository = arch = build_descr = service_data = None if len(args) <= 3: if not is_package_dir('.'): raise oscerr.WrongArgs('Incorrect number of arguments (Note: \'.\' is no package wc)') @@ -6048,6 +6048,8 @@ def do_buildinfo(self, subcmd, opts, *args): else: project = store_read_project('.') package = store_read_package('.') + if os.path.exists('_service'): + service_data = open('_service', 'rb').read() repository, arch, build_descr = self.parse_repoarchdescr(args, alternative_project=opts.alternative_project, ignore_descr=True, multibuild_package=opts.multibuild_package) elif len(args) == 4 or len(args) == 5: project = args[0] @@ -6084,7 +6086,8 @@ def do_buildinfo(self, subcmd, opts, *args): project, package, repository, arch, specfile=build_descr_data, debug=opts.debug, - addlist=opts.extra_pkgs))) + addlist=opts.extra_pkgs, + servicefile=service_data))) def do_buildconfig(self, subcmd, opts, *args): diff --git a/osc/core.py b/osc/core.py index 1ddb9538ed..0b8913b406 100644 --- a/osc/core.py +++ b/osc/core.py @@ -6200,7 +6200,7 @@ def get_dependson(apiurl, project, repository, arch, packages=None, reverse=None f = http_GET(u) return f.read() -def get_buildinfo(apiurl, prj, package, repository, arch, specfile=None, addlist=None, debug=None): +def get_buildinfo(apiurl, prj, package, repository, arch, specfile=None, addlist=None, debug=None, servicefile=None): query = [] if addlist: for i in addlist: @@ -6210,8 +6210,19 @@ def get_buildinfo(apiurl, prj, package, repository, arch, specfile=None, addlist u = makeurl(apiurl, ['build', prj, repository, arch, package, '_buildinfo'], query=query) + post_body=specfile + if servicefile: + if specfile == None: + print('error - application need to send also the build description file when sending a _service file') + sys.exit(1) + from .util import cpio + cpio = cpio.CpioWrite() + cpio.add(b'buildinfo.spec', specfile) + cpio.add(b'_service', servicefile) + post_body = cpio.get() + if specfile: - f = http_POST(u, data=specfile) + f = http_POST(u, data=post_body) else: f = http_GET(u) return f.read()