mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-24 13:05:09 +03:00
helpers: mount: don't shell out to create dirs
Since we are already root in the namespace, we can directly manipulate files without spawning a shell and running sudo. Simplify this logic. Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
This commit is contained in:
parent
a707a3003d
commit
8856887ece
1 changed files with 3 additions and 8 deletions
|
@ -5,7 +5,6 @@ from pathlib import Path, PurePath
|
|||
import pmb.helpers
|
||||
from pmb.core import Chroot
|
||||
from pmb.types import PathString
|
||||
import pmb.helpers.run
|
||||
from pmb.init import sandbox
|
||||
|
||||
|
||||
|
@ -40,13 +39,9 @@ def bind(
|
|||
return
|
||||
|
||||
# Check/create folders
|
||||
for path in [source, destination]:
|
||||
if os.path.exists(path):
|
||||
continue
|
||||
if create_folders:
|
||||
pmb.helpers.run.root(["mkdir", "-p", path])
|
||||
else:
|
||||
raise RuntimeError(f"Mount failed, folder does not exist: {path}")
|
||||
if create_folders:
|
||||
for path in [source, destination]:
|
||||
Path(path).mkdir(exist_ok=True)
|
||||
|
||||
# Actually mount the folder
|
||||
sandbox.mount_rbind(str(source), str(destination))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue