embdgen.core.utils.FakeRoot

class embdgen.core.utils.FakeRoot.FakeRoot(savefile: Path, parent: FakeRoot | None = None)[source]

Bases: object

Encapsulate usage of fakeroot command line tool

This allows file operations, that are usually only possible with root rights (e.g setting owner/group and creating device nodes). The files are created on the filesystem just like normal files and the attributes, that cannot be set directly are recorded in a state database. This can be used to create e.g. device nodes, that are later read by an archive tool or by a filesystem creator, where creating files with these attributes is allowed.

This class provides the run-method with the same syntax as subprocess run and automatically wraps all executions into fakeroot.

A fakeroot can import the state file of another fakeroot without modifying it.

property savefile: Path
run(args: List[str | Path], **kwargs)[source]

Run a process in fakeroot. This is a wrapper for subprocess.run and works exactly the same with two exceptions: 1. args can only be passed in as a list 2. check defaults to true

copy(src: Path, dest: Path) None[source]

Copy a file or a directory tree from src to dest.

dest is always a directory and created if it does not exist. The copying is done under fakeroot, to preserve all attributes. Symlinks in src (or if src is a symlink) are preserved in dest with the same target. Files are either hardlinked, if possible, or copied.

embdgen.core.utils.FakeRoot.copy_recursive(src_: Path, dest_: Path)[source]
embdgen.core.utils.FakeRoot.copy_main() int[source]