PR#3555: fix include path

Merges #3555
https://pagure.io/koji/pull-request/3555

Fixes: #3553
https://pagure.io/koji/issue/3553
kiwi plugin include processor doesn't construct include paths correctly
This commit is contained in:
Tomas Kopecek 2022-11-10 13:21:45 +01:00
commit 07536056e8

View file

@ -197,16 +197,20 @@ class KiwiCreateImageTask(BaseBuildTask):
for inc_node in image.getElementsByTagName('include'):
path = inc_node.getAttribute('from')
if path.startswith('this://'):
path = koji.util.joinpath(desc_path, path[7:])
path = koji.util.joinpath(os.path.dirname(desc_path), path[7:])
else:
# we want to reject other protocols, e.g. file://, https://
# reachingoutside of repo
raise koji.GenericError(f"Unhandled include protocol in include path: {path}.")
inc = xml.dom.minidom.parse(path) # nosec
# every included xml has image root element again
for node in inc.getElementsByTagName('image').childNodes:
if node.nodeName != 'repository':
image.appendChild(node)
try:
for node in list(inc.getElementsByTagName('image')[0].childNodes):
if node.nodeName != 'repository':
image.appendChild(node)
except IndexError:
raise koji.GenericError("Included file needs to contain <image> tag.")
image.removeChild(inc_node)
# remove remaining old repos
for old_repo in image.getElementsByTagName('repository'):