mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-07 13:48:43 +02:00
Fix kiwi builds where the project does not define a path
In that case, the packages to setup the build environment are taken from the repositories defined in the kiwi file. Osc did not take into account that the build config must match this path. So it cannot just get the build config like with normal builds, but must use a different path. This led to build errors on some projects like CentOS 7 which rely on 'Order' statements from the project config. The OBS backend already had support for this: the 'path' parameter can be used to overwrite the project path in the _buildconfig query. We now use this to provide the correct path if we detect this case. (The detection is currently a heuristic because OBS does not provide us with a clear indicator.)
This commit is contained in:
21
osc/build.py
21
osc/build.py
@@ -498,6 +498,22 @@ def check_trusted_projects(apiurl, projects):
|
||||
config['api_host_options'][apiurl]['trusted_prj'] = trusted
|
||||
conf.config_set_option(apiurl, 'trusted_prj', ' '.join(trusted))
|
||||
|
||||
def get_kiwipath_from_buildinfo(apiurl, bi_filename, prj, repo):
|
||||
bi = Buildinfo(bi_filename, apiurl, 'kiwi')
|
||||
# If the project does not have a path defined we need to get the config
|
||||
# via the repositories in the kiwi file. Unfortunately the buildinfo
|
||||
# does not include a hint if this is the case, so we rely on a heuristic
|
||||
# here: if the path list contains our own repo, it probably does not
|
||||
# come from the kiwi file and thus a path is defined in the config.
|
||||
# It is unlikely that our own repo is included in the kiwi file, as it
|
||||
# contains no packages.
|
||||
myprp = prj + '/' + repo
|
||||
if myprp in bi.pathes:
|
||||
return None
|
||||
kiwipath = bi.pathes
|
||||
kiwipath.insert(0, myprp)
|
||||
return kiwipath
|
||||
|
||||
def main(apiurl, opts, argv):
|
||||
|
||||
repo = argv[0]
|
||||
@@ -779,8 +795,11 @@ def main(apiurl, opts, argv):
|
||||
# maybe we should check for errors before saving the file
|
||||
bi_file.write(bi_text)
|
||||
bi_file.flush()
|
||||
kiwipath = None
|
||||
if build_type == 'kiwi':
|
||||
kiwipath = get_kiwipath_from_buildinfo(apiurl, bi_filename, prj, repo)
|
||||
print('Getting buildconfig from server and store to %s' % bc_filename)
|
||||
bc = get_buildconfig(apiurl, prj, repo)
|
||||
bc = get_buildconfig(apiurl, prj, repo, kiwipath)
|
||||
if not bc_file:
|
||||
bc_file = open(bc_filename, 'w')
|
||||
bc_file.write(bc)
|
||||
|
@@ -6105,8 +6105,12 @@ def get_buildinfo(apiurl, prj, package, repository, arch, specfile=None, addlist
|
||||
return f.read()
|
||||
|
||||
|
||||
def get_buildconfig(apiurl, prj, repository):
|
||||
u = makeurl(apiurl, ['build', prj, repository, '_buildconfig'])
|
||||
def get_buildconfig(apiurl, prj, repository, path=None):
|
||||
query = []
|
||||
if path:
|
||||
for prp in path:
|
||||
query.append('path=%s' % quote_plus(prp))
|
||||
u = makeurl(apiurl, ['build', prj, repository, '_buildconfig'], query=query)
|
||||
f = http_GET(u)
|
||||
return f.read()
|
||||
|
||||
|
Reference in New Issue
Block a user