Skip to content

Commit

Permalink
fix buildinfo inconsistency
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adrianschroeter committed Aug 6, 2021
1 parent e5dda83 commit b63f3ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 5 additions & 2 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand All @@ -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]
Expand Down Expand Up @@ -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):
Expand Down
15 changes: 13 additions & 2 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit b63f3ba

Please sign in to comment.