):
check_tools(config, Verb.build)
- # Create these as the invoking user to make sure they're owned by the user running mkosi.
for p in (
config.output_dir,
config.cache_dir,
config.build_dir,
config.workspace_dir,
):
- if p:
- run(["mkdir", "--parents", p], user=INVOKING_USER.uid, group=INVOKING_USER.gid)
+ if p and not p.exists():
+ INVOKING_USER.mkdir(p)
with (
acl_toggle_build(config, INVOKING_USER.uid),
from pathlib import Path
from mkosi.log import die
-from mkosi.run import spawn
+from mkosi.run import run, spawn
from mkosi.util import flock
SUBRANGE = 65536
return cache / "mkosi"
+ @classmethod
+ def mkdir(cls, path: Path) -> Path:
+ user = cls.uid if cls.is_regular_user() and path.is_relative_to(cls.home()) else os.getuid()
+ group = cls.gid if cls.is_regular_user() and path.is_relative_to(cls.home()) else os.getgid()
+ run(["mkdir", "--parents", path], user=user, group=group)
+ return path
+
def read_subrange(path: Path) -> int:
uid = str(os.getuid())