Skip to content

Commit 3e37a5b

Browse files
committed
feat: Support pathnames in contents.xml
Properly split pathnames from partitions.conf/.xml into a directory and a filename. Signed-off-by: Loïc Minier <[email protected]>
1 parent a034370 commit 3e37a5b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gen_contents.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-License-Identifier: BSD-3-Clause
44

55
import getopt
6+
import os
67
import sys
78

89
from xml.etree import ElementTree as ET
@@ -46,14 +47,19 @@ def UpdateMetaData(TemplateRoot, PartitionRoot):
4647
PartitionsSet.add((label, filename))
4748
print(f"PartitionsSet: {PartitionsSet}")
4849

49-
def _add_file_elements(parent_element, file_name_text, file_path_flavor=None):
50+
def _add_file_elements(parent_element, pathname, file_path_flavor=None):
5051
"""Helper function to add file_name and file_path sub-elements."""
52+
file_name_text = os.path.basename(pathname)
53+
file_path_text = os.path.dirname(pathname)
54+
if not file_path_text: # no directory, use explicit . as current dir
55+
file_path_text = "."
56+
5157
new_file_name = ET.SubElement(parent_element, "file_name")
5258
new_file_name.text = file_name_text
5359
new_file_path = ET.SubElement(parent_element, "file_path")
5460
if file_path_flavor:
5561
new_file_path.set("flavor", file_path_flavor)
56-
new_file_path.text = "."
62+
new_file_path.text = file_path_text
5763

5864
builds = TemplateRoot.findall('builds_flat/build')
5965
for build in builds:

0 commit comments

Comments
 (0)