Skip to content

Commit

Permalink
Merge pull request #109 from desultory/dev
Browse files Browse the repository at this point in the history
add kernel image reading for arch
  • Loading branch information
desultory authored Nov 1, 2024
2 parents 978899b + f57915a commit 0b14d73
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 158 deletions.
15 changes: 9 additions & 6 deletions src/ugrd/generator_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from zenlib.util import pretty_print

__version__ = "1.3.5"
__version__ = "1.3.7"
__author__ = "desultory"


Expand All @@ -21,6 +21,7 @@ def get_subpath(path: Path, subpath: Union[Path, str]) -> Path:

class GeneratorHelpers:
"""Mixin class for the InitramfsGenerator class."""

def _get_out_path(self, path: Union[Path, str]) -> Path:
"""Takes a filename, if the out_dir is relative, returns the path relative to the tmpdir.
If the out_dir is absolute, returns the path relative to the out_dir."""
Expand Down Expand Up @@ -147,7 +148,7 @@ def _symlink(self, source: Union[Path, str], target: Union[Path, str]) -> None:
self.logger.debug("Creating symlink: %s -> %s" % (target, source))
symlink(source, target)

def _run(self, args: list[str], timeout=15) -> CompletedProcess:
def _run(self, args: list[str], timeout=15, fail_silent=False, fail_hard=True) -> CompletedProcess:
"""Runs a command, returns the CompletedProcess object"""
cmd_args = [str(arg) for arg in args]
self.logger.debug("Running command: %s" % " ".join(cmd_args))
Expand All @@ -157,10 +158,12 @@ def _run(self, args: list[str], timeout=15) -> CompletedProcess:
raise RuntimeError("[%ds] Command timed out: %s" % (timeout, [str(arg) for arg in cmd_args])) from e

if cmd.returncode != 0:
self.logger.error("Failed to run command: %s" % " ".join(cmd.args))
self.logger.error("Command output:\n%s" % cmd.stdout.decode())
self.logger.error("Command error:\n%s" % cmd.stderr.decode())
raise RuntimeError("Failed to run command: %s" % " ".join(cmd.args))
if not fail_silent:
self.logger.error("Failed to run command: %s" % " ".join(cmd.args))
self.logger.error("Command output:\n%s" % cmd.stdout.decode())
self.logger.error("Command error:\n%s" % cmd.stderr.decode())
if fail_hard:
raise RuntimeError("Failed to run command: %s" % " ".join(cmd.args))

return cmd

Expand Down
Loading

0 comments on commit 0b14d73

Please sign in to comment.