2023-12-21 18:53:25 +00:00
|
|
|
import os
|
2023-12-21 19:42:13 +00:00
|
|
|
|
|
|
|
from gentooimgr import LOG
|
2023-12-21 18:53:25 +00:00
|
|
|
import gentooimgr.config
|
|
|
|
import gentooimgr.qemu
|
|
|
|
import gentooimgr.common
|
|
|
|
|
2023-12-21 19:42:13 +00:00
|
|
|
def run(args, config: dict) -> None:
|
|
|
|
LOG.info(": run")
|
2023-12-21 18:53:25 +00:00
|
|
|
mounts = args.mounts
|
|
|
|
# Specified image or look for gentoo.{img,qcow2}
|
|
|
|
image = config.get("imagename") or args.image or gentooimgr.qemu.create_image()
|
|
|
|
# We need to package up our gentooimgr package into an iso and mount it to the running image
|
|
|
|
# Why? basic gentoo livecd has no git and no pip installer. We want install to be simple
|
|
|
|
# and use the same common codebase.
|
|
|
|
|
|
|
|
# This will require a couple mount commands to function though.
|
|
|
|
main_iso = gentooimgr.common.make_iso_from_dir(os.path.join(
|
|
|
|
os.path.abspath(os.path.dirname(__file__)),
|
|
|
|
".."
|
|
|
|
))
|
|
|
|
|
2023-12-21 19:42:13 +00:00
|
|
|
assert os.path.isfile(main_iso), f"iso not found {main_iso}"
|
|
|
|
LOG.info(args)
|
|
|
|
LOG.info(f'iso={args.iso}')
|
2023-12-26 00:06:43 +00:00
|
|
|
if args.iso != config['iso']:
|
|
|
|
LOG.warn(f'iso={args.iso}')
|
|
|
|
config['iso'] = args.iso
|
|
|
|
else:
|
|
|
|
LOG.info(f'iso={args.iso}')
|
2023-12-21 18:53:25 +00:00
|
|
|
gentooimgr.qemu.run_image(
|
|
|
|
args,
|
|
|
|
config,
|
|
|
|
# Add our generated mount and livecd (assumed)
|
|
|
|
mounts=[main_iso]
|
|
|
|
)
|
2023-12-21 19:42:13 +00:00
|
|
|
LOG.info("done")
|