From: Niki Roo Date: Sat, 3 May 2025 12:50:06 +0000 (+0200) Subject: add qemu support via qemu.sh X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=d628fe8ff3af861d53deeb7bc50c6f4f09354be2;p=gamiki.git add qemu support via qemu.sh --- diff --git a/gamiki/support/__init__.py b/gamiki/support/__init__.py index 7b22862..2c5c3ec 100644 --- a/gamiki/support/__init__.py +++ b/gamiki/support/__init__.py @@ -5,11 +5,13 @@ from .support_win31 import SupportWin31 from .support_gog import SupportGog from .support_ext import SupportExt from .support_win import SupportWin +from .support_qemu import SupportQemu Support.all = [ SupportGog() , # gaminfo SupportWin() , # wine.bat SupportWin31(), # start.conf + C/WINDOWS SupportDos() , # start.conf + no C/WINDOWS + SupportQemu() , # qemu.config + disk SupportExt() # start.sh ] diff --git a/gamiki/support/commands.py b/gamiki/support/commands.py index bdaf485..654a925 100644 --- a/gamiki/support/commands.py +++ b/gamiki/support/commands.py @@ -66,6 +66,30 @@ def wine(dir: PurePath, link: PurePath, opt: str = None) -> int: return run(cmd, cwd=dir, env=env).returncode +def qemu(dir: PurePath, link: PurePath, opt: str = None) -> int: + + cmd, env = custom.cmd("qemu", link, None) + if (not cmd): + prog = custom.program("qemu") + if (prog): + cmd = [ prog ] + else: + raise RuntimeError("qemu not found") + + if (opt): + start = dir.joinpath(f"qemu-{opt}.config") + else: + start = dir.joinpath("qemu.config") + + if (not start.exists()): + return 404; + + # TODO: port qemu.sh in python and use it here + cmd = [ "qemu.sh" ]; + cmd.append(start.as_posix()) + + return run(cmd, cwd=dir, env=env).returncode + def start_sh(start: PurePath) -> int: cmd, env = custom.cmd("start_sh", start, None) diff --git a/gamiki/support/custom_commands.py b/gamiki/support/custom_commands.py index 2af010f..d77c3f3 100644 --- a/gamiki/support/custom_commands.py +++ b/gamiki/support/custom_commands.py @@ -39,6 +39,11 @@ def cmd(prog:str, t:PurePath, lnk:PurePath, pre:PurePath=None) -> (list, dict): + "-e WINEPREFIX='" + pre.as_posix().replace("'", "\\'") + "'" + " -v '" + lnk_path + ":" + lnk_path + "'" ) + elif (prog == "qemu"): + if (program("app.sh")): + cmd = [ + program("app.sh"),"--wait", "qemu" + ] elif (prog == "start_sh"): if (program("launch.sh")): cmd = [ diff --git a/gamiki/support/support.py b/gamiki/support/support.py index 20b8a0e..7e69309 100644 --- a/gamiki/support/support.py +++ b/gamiki/support/support.py @@ -18,7 +18,7 @@ class Support: def _running(self, game: Game, opt: str = None): if (opt): - print("Running", game.name, "(option: " + opt + ")") + print("Running", game.name, "(" + game.opts.get(opt) +")") else: print("Running", game.name) diff --git a/gamiki/support/support_qemu.py b/gamiki/support/support_qemu.py new file mode 100644 index 0000000..28bfb98 --- /dev/null +++ b/gamiki/support/support_qemu.py @@ -0,0 +1,19 @@ +from gamiki import Game +from gamiki.support import Support +from gamiki.support.commands import qemu + +class SupportQemu(Support): + """Supports games run under VMs in qEmu.""" + + def supports(self, game: Game): + return ( + game.dir.joinpath("qemu.config").exists() + and game.dir.joinpath("disk").exists() + ) + + def _start(self, game: Game, opt: str = None): + self._running(game, opt) + rep = qemu(game.dir.resolve(), game.library.dir.resolve(), opt) + if (rep != 0): + self._error(game, rep) +