Skip to content

Commit d4f4281

Browse files
authored
fix: prepare-sysimg: skip empty lines in input extra_excludes pattern file (#88)
This PR fixes an issue caused by prepare-sysimg command doesn't skip empty lines from the input extra excludes glob patterns file.
1 parent b9bd6e9 commit d4f4281

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/ota_image_builder/cmds/prepare_sysimg.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def _load_extra_patterns_from_file(_f: str) -> list[str]:
7272

7373
_res = []
7474
for _line in _pattern_f.read_text().splitlines():
75+
_line = _line.strip()
76+
if _line.startswith(("#", "//")) or not _line:
77+
continue # skip empty line or commented out lines
78+
7579
for _pa in BACKWARD_COMPAT_PA:
7680
if _pa.match(_line):
7781
break
@@ -110,6 +114,9 @@ def _process_cleanup(self) -> None:
110114
self._delete_one_entry(path)
111115

112116
for entry in self._extra_ignore_patterns:
117+
if not (entry := entry.strip()):
118+
continue # skip empty lines!
119+
113120
if entry.startswith("/"):
114121
entry = entry.lstrip("/")
115122
if not GLOB_SPECIAL_CHARS.search(entry): # for exact matching
@@ -125,7 +132,7 @@ def _process_cleanup(self) -> None:
125132
def _prepare_image(self) -> None:
126133
for entry in DEFAULT_IGNORE_DIRS_SHOULD_PRESERVED:
127134
entry_path = self._rootfs_dir / entry.lstrip("/")
128-
entry_path.mkdir(exist_ok=True)
135+
entry_path.mkdir(exist_ok=True, parents=True)
129136

130137
def prepare(self) -> None:
131138
"""Prepare the system rootfs image."""

0 commit comments

Comments
 (0)