Compare commits
10 commits
a5ca3a6044
...
282e2ac7a1
Author | SHA1 | Date | |
---|---|---|---|
282e2ac7a1 | |||
3ce03d17c1 | |||
4414a9a712 | |||
959107c245 | |||
73dc9598b7 | |||
0a035f2cd6 | |||
7d0ffb8a65 | |||
2648c2e6ba | |||
d23bbdd7c9 | |||
df2537dd6d |
9 changed files with 56 additions and 22 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
/tmp
|
/tmp
|
||||||
|
/.venv
|
||||||
/.vscode
|
/.vscode
|
||||||
/dist
|
/dist
|
||||||
|
|
|
@ -32,4 +32,8 @@ requires-python = ">= 3.10"
|
||||||
path = "rwx/__init__.py"
|
path = "rwx/__init__.py"
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
|
line-length = 80
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
ignore = ["COM812", "D203", "D213", "ISC001"]
|
||||||
select = ["ALL"]
|
select = ["ALL"]
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
"""Read Write eXecute."""
|
"""Read Write eXecute."""
|
||||||
|
|
||||||
__version__ = "0.0.1"
|
__version__ = "0.0.1"
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
|
|
||||||
|
"""Entry point."""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import fs
|
import fs
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
file_path = Path(__file__).resolve()
|
file_path = Path(__file__).resolve()
|
||||||
root_path = file_path.parent
|
root_path = file_path.parent
|
||||||
|
|
|
@ -6,10 +6,14 @@ rwx.cmd.need("mksquashfs")
|
||||||
|
|
||||||
|
|
||||||
def mksquashfs(input_root: str, output_file: str):
|
def mksquashfs(input_root: str, output_file: str):
|
||||||
ps.run([
|
ps.run(
|
||||||
"mksquashfs",
|
[
|
||||||
input_root,
|
"mksquashfs",
|
||||||
output_file,
|
input_root,
|
||||||
"-comp", "zstd",
|
output_file,
|
||||||
"-Xcompression-level", str(18),
|
"-comp",
|
||||||
])
|
"zstd",
|
||||||
|
"-Xcompression-level",
|
||||||
|
str(18),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
|
@ -17,8 +17,13 @@ MODULES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def make_image(image_format: str, image_path: str, modules: list[str],
|
def make_image(
|
||||||
memdisk_path: str, pubkey_path: str | None = None) -> None:
|
image_format: str,
|
||||||
|
image_path: str,
|
||||||
|
modules: list[str],
|
||||||
|
memdisk_path: str,
|
||||||
|
pubkey_path: str | None = None,
|
||||||
|
) -> None:
|
||||||
args = [
|
args = [
|
||||||
("grub-mkimage",),
|
("grub-mkimage",),
|
||||||
("--compress", COMPRESSION),
|
("--compress", COMPRESSION),
|
||||||
|
@ -29,6 +34,6 @@ def make_image(image_format: str, image_path: str, modules: list[str],
|
||||||
if pubkey_path:
|
if pubkey_path:
|
||||||
args.append(("--pubkey", pubkey_path))
|
args.append(("--pubkey", pubkey_path))
|
||||||
args.extend(modules)
|
args.extend(modules)
|
||||||
if modules := MODULES.get(image_format, None):
|
if modules := MODULES.get(image_format):
|
||||||
args.extend(modules)
|
args.extend(modules)
|
||||||
ps.run(*args)
|
ps.run(*args)
|
||||||
|
|
|
@ -16,13 +16,17 @@ def get_file_logger(name: str) -> logging.Logger:
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
#
|
#
|
||||||
return logger
|
return logger
|
||||||
def get_stream_logger() -> logging.Logger:
|
|
||||||
|
|
||||||
|
def get_stream_logger(level: int) -> logging.Logger:
|
||||||
out_handler = logging.StreamHandler(stream=sys.stdout)
|
out_handler = logging.StreamHandler(stream=sys.stdout)
|
||||||
out_handler.setLevel(logging.INFO)
|
out_handler.setLevel(level)
|
||||||
#
|
#
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.addHandler(out_handler)
|
logger.addHandler(out_handler)
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(level)
|
||||||
#
|
#
|
||||||
return logger
|
return logger
|
||||||
stream = get_stream_logger()
|
|
||||||
|
|
||||||
|
stream = get_stream_logger(logging.INFO)
|
||||||
|
|
|
@ -15,12 +15,18 @@ class SphinxProject(Project):
|
||||||
wipe(output_root)
|
wipe(output_root)
|
||||||
arguments: list[str] = [
|
arguments: list[str] = [
|
||||||
"-E",
|
"-E",
|
||||||
"-j", "2",
|
"-j",
|
||||||
"-b", "html",
|
"2",
|
||||||
"-D", f"project={self.name}",
|
"-b",
|
||||||
"-D", "master_doc={}".format("index"),
|
"html",
|
||||||
"-D", "html_theme={}".format("sphinx_rtd_theme"),
|
"-D",
|
||||||
"-c", self.root,
|
f"project={self.name}",
|
||||||
|
"-D",
|
||||||
|
"master_doc={}".format("index"),
|
||||||
|
"-D",
|
||||||
|
"html_theme={}".format("sphinx_rtd_theme"),
|
||||||
|
"-c",
|
||||||
|
self.root,
|
||||||
# "-C",
|
# "-C",
|
||||||
path.join(self.root, self.name),
|
path.join(self.root, self.name),
|
||||||
path.join(output_root, self.name),
|
path.join(output_root, self.name),
|
||||||
|
|
|
@ -14,7 +14,9 @@ def get_tuples_args(tuples) -> list[str]:
|
||||||
|
|
||||||
|
|
||||||
def run(*tuples) -> subprocess.CompletedProcess:
|
def run(*tuples) -> subprocess.CompletedProcess:
|
||||||
return subprocess.run(get_tuples_args(tuples), capture_output=False)
|
return subprocess.run(
|
||||||
|
get_tuples_args(tuples), capture_output=False, check=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def run_line(*tuples, charset: str = txt.CHARSET) -> str:
|
def run_line(*tuples, charset: str = txt.CHARSET) -> str:
|
||||||
|
@ -23,6 +25,8 @@ def run_line(*tuples, charset: str = txt.CHARSET) -> str:
|
||||||
|
|
||||||
|
|
||||||
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)
|
process = subprocess.run(
|
||||||
|
get_tuples_args(tuples), capture_output=True, check=True
|
||||||
|
)
|
||||||
string = process.stdout.decode(charset)
|
string = process.stdout.decode(charset)
|
||||||
return string.rstrip().splitlines()
|
return string.rstrip().splitlines()
|
||||||
|
|
Loading…
Add table
Reference in a new issue