diff --git a/osc/commandline.py b/osc/commandline.py index 76eb7e5d15..2000c110be 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] @@ -6056,6 +6058,8 @@ def do_buildinfo(self, subcmd, opts, *args): arch = args[3] if len(args) == 5: build_descr = args[4] + if os.path.exists('_service'): + service_data = open('_service', 'rb').read() else: raise oscerr.WrongArgs('Too many arguments.') @@ -6084,7 +6088,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..329394abe6 100644 --- a/osc/core.py +++ b/osc/core.py @@ -24,6 +24,7 @@ import shlex import hashlib import platform +from .util import cpio try: @@ -6200,7 +6201,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 +6211,18 @@ 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 is None: + e.osc_msg = 'error - application need to send also the build description file when sending a _service file' + raise + 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()