Compare commits

..

No commits in common. "3393f0990742dda006ded747dae2e50319356af2" and "8c896c9074f1a9b1f17f4ed56092d6d3fbd1c127" have entirely different histories.

7 changed files with 12 additions and 38 deletions

View file

@ -1,5 +1,3 @@
"""Wrap SquashFS commands."""
import ps
import rwx.cmd
@ -7,8 +5,7 @@ import rwx.cmd
rwx.cmd.need("mksquashfs")
def mksquashfs(input_root: str, output_file: str) -> None:
"""Make a SquashFS bootable image file."""
def mksquashfs(input_root: str, output_file: str):
ps.run(
[
"mksquashfs",

View file

@ -1,5 +1,3 @@
"""Wrap Debian commands."""
import cmd
import ps
@ -10,8 +8,7 @@ BOOTSTRAP_ARCHITECTURE = "amd64"
BOOTSTRAP_VARIANT = "minbase"
def bootstrap(root_path: str, suite: str, mirror_location: str) -> None:
"""Boostrap a base operating filesystem."""
def bootstrap(root_path: str, suite: str, mirror_location: str):
command = [
("debootstrap",),
("--arch", BOOTSTRAP_ARCHITECTURE),

View file

@ -1,5 +1,2 @@
"""Handle errors."""
class Error(Exception):
"""Parent class for all errors."""
class Exception(Exception):
pass

View file

@ -23,7 +23,7 @@ def empty_file(path: str) -> None:
def get_mount_uuid(path: str) -> str:
"""Return the filesystem UUID of a mountpoint path."""
"""Return the UUID of provided mountpoint path."""
return ps.run_line(
("findmnt",),
("--noheadings",),
@ -32,8 +32,7 @@ def get_mount_uuid(path: str) -> str:
)
def get_path_mount(path: str) -> str:
"""Return the mountpoint path of an arbitrary path."""
def get_path_mount(path: str):
return ps.run_line(
("stat",),
("--format", "%m"),
@ -41,13 +40,11 @@ def get_path_mount(path: str) -> str:
)
def get_path_uuid(path: str) -> str:
"""Return the filesystem UUID of an arbitrary path."""
def get_path_uuid(path: str):
return get_mount_uuid(get_path_mount(path))
def make_directory(path: str) -> None:
"""Make a directory (and its parents) from a path."""
def make_directory(path: str):
os.makedirs(path, exist_ok=True)
@ -56,16 +53,15 @@ def read_file(file_path: str):
return file_object.read()
def read_file_lines(file_path: str, charset: str = CHARSET):
def read_file_lines(file_path: str, charset=CHARSET):
return read_file_text(file_path).split(os.linesep)
def read_file_text(file_path: str, charset: str = CHARSET):
def read_file_text(file_path: str, charset=CHARSET):
return read_file(file_path).decode(charset)
def wipe(path: str) -> None:
"""Wipe provided path, whether directory or file."""
def wipe(path: str):
try:
shutil.rmtree(path)
except NotADirectoryError:
@ -74,7 +70,6 @@ def wipe(path: str) -> None:
pass
def write(file_path: str, text: str, charset: str = CHARSET) -> None:
"""Write text into a file."""
def write(file_path: str, text: str, charset=CHARSET):
with open(file_path, "bw") as file_object:
file_object.write(text.encode(charset))

View file

@ -1,5 +1,3 @@
"""Wrap GRUB commands."""
import cmd
import ps
@ -26,7 +24,6 @@ def make_image(
memdisk_path: str,
pubkey_path: str | None = None,
) -> None:
"""Make a binary bootable image."""
args = [
("grub-mkimage",),
("--compress", COMPRESSION),

View file

@ -1,13 +1,8 @@
"""Handle projects."""
from os import path
class Project:
"""Parent class for any type of project."""
def __init__(self, file_path: str) -> None:
"""Set file, root & name."""
self.file: str = path.realpath(file_path)
self.root: str = path.dirname(self.file)
self.name: str = path.basename(self.root)

View file

@ -9,14 +9,10 @@ from rwx.prj import Project
class SphinxProject(Project):
"""Child class for a project based on Sphinx."""
def __init__(self, file_path: str) -> None:
"""Call the parent constructor."""
super().__init__(file_path)
def build(self) -> None:
"""Build the project."""
output_root: str = path.join(self.root, "out")
wipe(output_root)
arguments: list[str] = [