2023-12-21 18:53:25 +00:00
|
|
|
import os
|
|
|
|
import argparse
|
2023-12-21 19:42:13 +00:00
|
|
|
|
|
|
|
from gentooimgr import LOG
|
2023-12-21 18:53:25 +00:00
|
|
|
import gentooimgr.config as config
|
|
|
|
import gentooimgr.download as download
|
|
|
|
import gentooimgr.qemu as qemu
|
|
|
|
import gentooimgr.common
|
|
|
|
import requests
|
|
|
|
|
|
|
|
def build(args: argparse.Namespace, config: dict) -> None:
|
2023-12-21 19:42:13 +00:00
|
|
|
LOG.info(": build")
|
2023-12-21 18:53:25 +00:00
|
|
|
|
|
|
|
iso = config.get("iso") or download.download(args)
|
|
|
|
stage3 = config.get("stage3") or download.download_stage3(args)
|
|
|
|
portage = config.get("portage") or download.download_portage(args)
|
|
|
|
filename = f"{args.image}.{args.format}"
|
|
|
|
image = qemu.create_image(args, config)
|
|
|
|
if not os.path.exists(image):
|
|
|
|
raise Exception(f"Image {image} does not exist")
|
|
|
|
|
|
|
|
is_default = os.path.basename(image) == filename
|
2023-12-21 19:42:13 +00:00
|
|
|
LOG.info(image)
|
|
|
|
LOG.info(f"Image {image} build successfully.\nRun `python -m gentooimgr run{' ' + image if not is_default else ''} --iso {iso}`")
|
|
|
|
|
|
|
|
return image
|