fix(setup): use consistent runtime paths and reject incomplete installs

This commit is contained in:
Nicolai Bruns committed 2026-10-17 22:09:29 +02:00
1 parent 057f0f06d1
commit 9adfaf010f
18 files changed
+439 -48

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
"""Shared host-side destinations for configured runtime installers."""
import os
from pathlib import Path
def runtime_paths(config):
prefix = Path(os.environ.get("DPREFIX") or config["prefix"])
guest_home = Path(os.environ.get("RIOT_GUEST_HOME") or
str(prefix / config["guest_home"].lstrip("/")))
if not prefix.is_absolute() or not guest_home.is_absolute():
raise ValueError("Runtime paths must be absolute host paths")
if ".." in guest_home.parts or not guest_home.is_relative_to(prefix) or guest_home == prefix:
raise ValueError("RIOT_GUEST_HOME must be inside DPREFIX")
if not guest_home.resolve().is_relative_to(prefix.resolve()) or guest_home.resolve() == prefix.resolve():
raise ValueError("RIOT_GUEST_HOME must resolve inside DPREFIX")
return prefix, guest_home
if __name__ == '__main__':
import sys
try:
runtime_paths({'prefix': sys.argv[1], 'guest_home': '/'},)
except (ValueError, OSError) as error:
raise SystemExit(str(error))