From: Niki Roo Date: Fri, 12 Sep 2025 19:01:51 +0000 (+0200) Subject: custom scripts: app.sh X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=e750c858fc957bdcfcfd518dafd2ba3d14d43ef5;p=gamiki.git custom scripts: app.sh --- diff --git a/gamiki/support/commands.py b/gamiki/support/commands.py index 654a925..56ddf56 100644 --- a/gamiki/support/commands.py +++ b/gamiki/support/commands.py @@ -68,25 +68,22 @@ def wine(dir: PurePath, link: PurePath, opt: str = None) -> int: 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") + qemu_conf = dir.joinpath(f"qemu-{opt}.config") else: - start = dir.joinpath("qemu.config") + qemu_conf = dir.joinpath("qemu.config") - if (not start.exists()): + if (not qemu_conf.exists()): return 404; - # TODO: port qemu.sh in python and use it here - cmd = [ "qemu.sh" ]; - cmd.append(start.as_posix()) + cmd, env = custom.cmd("qemu", qemu_conf, link) + if (not cmd): + prog = custom.program("qemu") + if (prog): + # TODO: port qemu.sh in python? + cmd = [ "qemu.sh", qemu_conf.as_posix() ]; + else: + raise RuntimeError("qemu not found") return run(cmd, cwd=dir, env=env).returncode diff --git a/gamiki/support/custom_commands.py b/gamiki/support/custom_commands.py index 06f5773..69b63b0 100644 --- a/gamiki/support/custom_commands.py +++ b/gamiki/support/custom_commands.py @@ -22,34 +22,28 @@ def video(file: PurePath) -> (list, dict): return cmd, env def cmd(prog:str, t:PurePath, lnk:PurePath, pre:PurePath=None) -> (list, dict): + # t: the target to start + # lnk: link to library directory + # pre: the WINEPREFIX (wine only) cmd = None env = environ.copy() + + # All the custom procedures requires app.sh + if (not program("app.sh")): + return cmd, env if (prog == "dosbox"): - if (program("app.sh")): - cmd = [ - program("app.sh"),"--wait", "dosbox", "--link", t.as_posix() - ] + cmd = [ program("app.sh"),"--wait", "dosbox", "--ddlink", t.as_posix() ] elif (prog == "wine"): - if (program("launch.sh")): - cmd = [ program("launch.sh"), "wine", "--dlink", t.as_posix() ] - lnk_path = lnk.as_posix().replace("'", "\\'") - env["OPTS"] = ( "" - + "-e WINEPREFIX='" + pre.as_posix().replace("'", "\\'") + "'" - + " -v '" + lnk_path + ":" + lnk_path + "'" - ) + cmd = [ + program("app.sh"), "wine", "--ddlink", t.as_posix(), + "--prefix", pre.as_posix() + ] elif (prog == "qemu"): - if (program("app.sh")): - cmd = [ - program("app.sh"),"--wait", "qemu" - ] + cmd = [ program("app.sh"), "--wait", "qemu", "--ddlink", t.as_posix() ] elif (prog == "start_sh"): - if (program("launch.sh")): - cmd = [ - program("launch.sh"), "games", "--dlink", t.as_posix() - ] - env["OPTS"] = "--entrypoint=bash" + cmd = [ program("app.sh"), "games", "--dlink", t.as_posix() ] return cmd, env