From 07536056e868e5277565fd3e4ef9308352979aca Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Nov 10 2022 12:21:45 +0000 Subject: 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 --- diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py index b70a13a..bc216c2 100644 --- a/plugins/builder/kiwi.py +++ b/plugins/builder/kiwi.py @@ -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 tag.") + image.removeChild(inc_node) # remove remaining old repos for old_repo in image.getElementsByTagName('repository'):