mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-25 21:45:11 +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
|
import pmb.helpers
|
||||||
from pmb.core import Chroot
|
from pmb.core import Chroot
|
||||||
from pmb.types import PathString
|
from pmb.types import PathString
|
||||||
import pmb.helpers.run
|
|
||||||
from pmb.init import sandbox
|
from pmb.init import sandbox
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,13 +39,9 @@ def bind(
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check/create folders
|
# Check/create folders
|
||||||
for path in [source, destination]:
|
if create_folders:
|
||||||
if os.path.exists(path):
|
for path in [source, destination]:
|
||||||
continue
|
Path(path).mkdir(exist_ok=True)
|
||||||
if create_folders:
|
|
||||||
pmb.helpers.run.root(["mkdir", "-p", path])
|
|
||||||
else:
|
|
||||||
raise RuntimeError(f"Mount failed, folder does not exist: {path}")
|
|
||||||
|
|
||||||
# Actually mount the folder
|
# Actually mount the folder
|
||||||
sandbox.mount_rbind(str(source), str(destination))
|
sandbox.mount_rbind(str(source), str(destination))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue