stages/erofs: Add exclude_paths support

Add the ability to exclude files and directories from the erofs
image. This uses the mkfs.erofs --exclude-regex feature, so simple
matches or regexes can be used.
This commit is contained in:
Brian C. Lane 2025-06-05 14:30:38 -07:00 committed by Achilleas Koutsou
parent 86c89a2421
commit a828ef95d6
3 changed files with 13 additions and 0 deletions

View file

@ -10,6 +10,7 @@ def main(inputs, output_dir, options):
source = inputs["tree"]["path"]
filename = options["filename"].lstrip("/")
compression = options.get("compression")
exclude_paths = options.get("exclude_paths")
target = os.path.join(output_dir, filename)
@ -29,6 +30,10 @@ def main(inputs, output_dir, options):
if cluster_size:
cmd += ["-C", f"{cluster_size}"]
if exclude_paths:
for e in exclude_paths:
cmd += ["--exclude-regex", e]
subprocess.run(cmd, check=True)
return 0

View file

@ -16,6 +16,13 @@
"description": "Filename for the output",
"type": "string"
},
"exclude_paths": {
"type": "array",
"description": "Regex of paths to exclude, can be files or directories",
"items": {
"type": "string"
}
},
"compression": {
"type": "object",
"additionalProperties": false,

View file

@ -16,6 +16,7 @@ TEST_INPUT = [
({"options": ["dedupe"]}, ["-E", "dedupe"]),
({"options": ["all-fragments", "force-inode-compact"]}, ["-E", "all-fragments,force-inode-compact"]),
({"cluster-size": 131072, "options": ["dedupe"]}, ["-E", "dedupe", "-C", "131072"]),
({"exclude_paths": ["boot/", "root/"]}, ["--exclude-regex", "boot/", "--exclude-regex", "root/"])
]