From ba03b50992ea4d8c6762955e3e531634a6a03cd3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:11:28 +0100 Subject: [PATCH] cmd --- cmd/__init__.py | 15 +++++++++++++++ cmd/debootstrap/__init__.py | 10 ++++++++++ cmd/squashfs/__init__.py | 14 ++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 cmd/__init__.py create mode 100644 cmd/debootstrap/__init__.py create mode 100644 cmd/squashfs/__init__.py diff --git a/cmd/__init__.py b/cmd/__init__.py new file mode 100644 index 0000000..9403d24 --- /dev/null +++ b/cmd/__init__.py @@ -0,0 +1,15 @@ +commands: list[str] = [] +packages: list[str] = [] + + +def need(command: str) -> None: + match command: + case 'debootstrap': + package = 'debootstrap' + case 'mksquashfs' | 'unsquashfs': + package = 'squashfs-tools' + case _: + package = None + if package: + if package not in packages: + packages.append(package) diff --git a/cmd/debootstrap/__init__.py b/cmd/debootstrap/__init__.py new file mode 100644 index 0000000..f716a3e --- /dev/null +++ b/cmd/debootstrap/__init__.py @@ -0,0 +1,10 @@ +from ... import cmd +from ... import ps + +cmd.need('debootstrap') + + +def debootstrap(input_mirror: str, output_root: str): + ps.run([ + 'debootstrap', + ]) diff --git a/cmd/squashfs/__init__.py b/cmd/squashfs/__init__.py new file mode 100644 index 0000000..8f4b788 --- /dev/null +++ b/cmd/squashfs/__init__.py @@ -0,0 +1,14 @@ +from ... import cmd +from ... import ps + +cmd.need('mksquashfs') + + +def mksquashfs(input_root: str, output_file: str): + ps.run([ + 'mksquashfs', + input_root, + output_file, + '-comp', 'zstd', + '-Xcompression-level', str(18), + ])