yes_no,
)
from mkosi.context import Context
-from mkosi.distributions import Distribution
+from mkosi.distributions import Distribution, detect_distribution
from mkosi.documentation import show_docs
from mkosi.installer import clean_package_manager_metadata
from mkosi.kmod import gen_required_kernel_modules, loaded_modules, process_kernel_modules
hint=f"Create an empty directory at {dst} using 'mkdir -p {dst}' as root and try again",
)
+ hd, hr = detect_distribution()
+
+ env = {"MKOSI_IN_SANDBOX": "1"}
+ if hd:
+ env |= {"MKOSI_HOST_DISTRIBUTION": str(hd)}
+ if hr:
+ env |= {"MKOSI_HOST_RELEASE": hr}
+
run(
args.cmdline,
stdin=sys.stdin,
stdout=sys.stdout,
- env=os.environ | {"MKOSI_IN_SANDBOX": "1"},
+ env=os.environ | env,
log=False,
sandbox=config.sandbox(
devices=True,
def config_default_distribution(namespace: argparse.Namespace) -> Distribution:
+ if d := os.getenv("MKOSI_HOST_DISTRIBUTION"):
+ return Distribution(d)
+
detected = detect_distribution()[0]
if not detected:
def config_default_release(namespace: argparse.Namespace) -> str:
+ hd: Optional[Distribution]
+ hr: Optional[str]
+
+ if (d := os.getenv("MKOSI_HOST_DISTRIBUTION")) and (r := os.getenv("MKOSI_HOST_RELEASE")):
+ hd, hr = Distribution(d), r
+ else:
+ hd, hr = detect_distribution()
+
# If the configured distribution matches the host distribution, use the same release as the host.
- hd, hr = detect_distribution()
if namespace.distribution == hd and hr is not None:
return hr