1
0
Fork 1
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:
Casey Connolly 2025-05-26 18:08:54 +02:00
parent a707a3003d
commit 8856887ece

View file

@ -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))