From e11b92e57b7080f86cbf0f0842e1a3857d6eb228 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 16 Feb 2024 21:42:48 +0100 Subject: [PATCH] dbs --- cmd/debootstrap/__init__.py | 10 ---------- deb.py | 17 ----------------- deb/__init__.py | 20 ++++++++++++++++++++ ps/__init__.py | 4 ++-- 4 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 cmd/debootstrap/__init__.py delete mode 100644 deb.py create mode 100644 deb/__init__.py diff --git a/cmd/debootstrap/__init__.py b/cmd/debootstrap/__init__.py deleted file mode 100644 index a2ac674..0000000 --- a/cmd/debootstrap/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -import cmd -import ps - -cmd.need('debootstrap') - - -def debootstrap(input_mirror: str, output_root: str): - ps.run([ - 'debootstrap', - ]) diff --git a/deb.py b/deb.py deleted file mode 100644 index 05e72f0..0000000 --- a/deb.py +++ /dev/null @@ -1,17 +0,0 @@ -import subprocess - -BOOTSTRAP_ARCHITECTURE = 'amd64' -BOOTSTRAP_VARIANT = 'minbase' - - -def bootstrap(root_path: str, suite: str, mirror_location: str): - command = [ - 'debootstrap', - '--arch', BOOTSTRAP_ARCHITECTURE, - '--variant', BOOTSTRAP_VARIANT, - suite, - root_path, - mirror_location, - ] - completed_process = subprocess.run(command, capture_output=True) - return completed_process diff --git a/deb/__init__.py b/deb/__init__.py new file mode 100644 index 0000000..a773123 --- /dev/null +++ b/deb/__init__.py @@ -0,0 +1,20 @@ +import cmd +import ps + +cmd.need('debootstrap') + +BOOTSTRAP_ARCHITECTURE = 'amd64' +BOOTSTRAP_VARIANT = 'minbase' + + +def bootstrap(root_path: str, suite: str, mirror_location: str): + command = [ + ('debootstrap',), + ('--arch', BOOTSTRAP_ARCHITECTURE), + ('--variant', BOOTSTRAP_VARIANT), + (suite,), + (root_path,), + (mirror_location,), + ] + completed_process = ps.run(command) + return completed_process diff --git a/ps/__init__.py b/ps/__init__.py index c656369..2290983 100644 --- a/ps/__init__.py +++ b/ps/__init__.py @@ -17,12 +17,12 @@ def run(*tuples) -> subprocess.CompletedProcess: return subprocess.run(get_tuples_args(tuples), capture_output=False) -def run_line(*tuples, charset:str = txt.CHARSET) -> str: +def run_line(*tuples, charset: str = txt.CHARSET) -> str: lines = run_lines(*get_tuples_args(tuples), charset=charset) return lines[0] -def run_lines(*tuples, charset:str = txt.CHARSET) -> list[str]: +def run_lines(*tuples, charset: str = txt.CHARSET) -> list[str]: process = subprocess.run(get_tuples_args(tuples), capture_output=True) string = process.stdout.decode(charset) return string.rstrip().splitlines()