MCPcopy Create free account
hub / github.com/OpenIPC/firmware / squashfs_metadata

Function squashfs_metadata

general/scripts/size_report.py:129–149  ·  view source on GitHub ↗

Run `unsquashfs -s` and parse out compression + on-disk byte total.

(path: Path)

Source from the content-addressed store, hash-verified

127
128
129def squashfs_metadata(path: Path) -> dict | None:
130 """Run `unsquashfs -s` and parse out compression + on-disk byte total."""
131 try:
132 out = subprocess.check_output(
133 ["unsquashfs", "-s", str(path)], text=True, stderr=subprocess.STDOUT
134 )
135 except (subprocess.CalledProcessError, FileNotFoundError) as e:
136 return {"error": str(e)}
137
138 info: dict = {"compressed_bytes": path.stat().st_size}
139 for line in out.splitlines():
140 m = re.match(r"\s*Compression\s+(\S+)", line)
141 if m:
142 info["compression"] = m.group(1)
143 m = re.match(r"\s*Block size\s+(\d+)", line)
144 if m:
145 info["block_size"] = int(m.group(1))
146 m = re.match(r"\s*Number of inodes\s+(\d+)", line)
147 if m:
148 info["inode_count"] = int(m.group(1))
149 return info
150
151
152def kernel_caps(flash_mb: str, vendor: str, has_ubi: bool) -> dict[str, int]:

Callers 1

build_reportFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected