forked from Mirror/pmbootstrap
chroot: require explicit initialisation (MR 2252)
We currently lazily initialize the chroot's on first use, plus a few bonus calls to init. However, there are some instances where we actually don't want the chroot to be initialised (mostly to break recursion loops). Simplify the codebase by removing all of this, and just calling pmb.chroot.init() where it's needed. In addition, print a warning if init() is called multiple times for one chroot. This should help us catch these instances if they crop up again. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
22f805a325
commit
1d9bbd613e
11 changed files with 21 additions and 21 deletions
|
@ -9,7 +9,7 @@ from pmb.core.types import PathString, PmbArgs
|
|||
|
||||
|
||||
def user(args: PmbArgs, cmd, chroot: Chroot=Chroot.native(), working_dir: Path = Path("/"), output="log",
|
||||
output_return=False, check=None, env={}, auto_init=True):
|
||||
output_return=False, check=None, env={}):
|
||||
"""
|
||||
Run a command inside a chroot as "user". We always use the BusyBox
|
||||
implementation of 'su', because other implementations may override the PATH
|
||||
|
@ -17,7 +17,6 @@ def user(args: PmbArgs, cmd, chroot: Chroot=Chroot.native(), working_dir: Path =
|
|||
|
||||
:param env: dict of environment variables to be passed to the command, e.g.
|
||||
{"JOBS": "5"}
|
||||
:param auto_init: automatically initialize the chroot
|
||||
|
||||
See pmb.helpers.run_core.core() for a detailed description of all other
|
||||
arguments and the return value.
|
||||
|
@ -31,7 +30,7 @@ def user(args: PmbArgs, cmd, chroot: Chroot=Chroot.native(), working_dir: Path =
|
|||
flat_cmd = pmb.helpers.run_core.flat_cmd(cmd, env=env)
|
||||
cmd = ["busybox", "su", "pmos", "-c", flat_cmd]
|
||||
return pmb.chroot.root(args, cmd, chroot, working_dir, output,
|
||||
output_return, check, {}, auto_init,
|
||||
output_return, check, {},
|
||||
add_proxy_env_vars=False)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue