mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
fix(setup): use consistent runtime paths and reject incomplete installs
This commit is contained in:
1 parent
057f0f06d1
commit
9adfaf010f
18 files changed
+439
-48
No files matched your search
@@ -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))
|
||||
Reference in new issue
Block a user