Instead of sharing the build directory between all images, let's
use a subdirectory of the build directory for subimages.
This requires us to unshare the user namespace in run_build() before
we create the directories so that we always have permissions to create
any nested build directories.
def run_build(args: Args, config: Config, *, resources: Path) -> None:
+ if (uid := os.getuid()) != 0:
+ become_root()
+ unshare(CLONE_NEWNS)
+ if uid == 0:
+ run(["mount", "--make-rslave", "/"])
+
for p in (
config.output_dir,
config.cache_dir,
p.mkdir(parents=True, exist_ok=True)
INVOKING_USER.chown(p)
- if (uid := os.getuid()) != 0:
- become_root()
- unshare(CLONE_NEWNS)
- if uid == 0:
- run(["mount", "--make-rslave", "/"])
-
if config.build_dir:
# Make sure the build directory is owned by root (in the user namespace) so that the correct uid-mapping is
# applied if it is used in RuntimeTrees=
def load_config(config: argparse.Namespace) -> Config:
if config.build_dir:
- config.build_dir = config.build_dir / f"{config.distribution}~{config.release}~{config.architecture}"
+ config.build_dir /= config.build_dir / f"{config.distribution}~{config.release}~{config.architecture}"
+ if config.image:
+ config.build_dir /= config.image
if config.sign:
config.checksum = True