diff options
author | Stelios Tsampas | 2023-11-06 20:47:46 +0200 |
---|---|---|
committer | Stelios Tsampas | 2023-11-06 20:47:46 +0200 |
commit | 3810e37d596f70985e06ae2ec3b81fe8abcf4bc1 (patch) | |
tree | 1f57120dcb84da545fe75dca77f6fbdb07af257e | |
parent | 5cb0911c9b26397d1e750d6f09cc6c2b305695e3 (diff) | |
download | aur-3810e37d596f70985e06ae2ec3b81fe8abcf4bc1.tar.gz |
[rbdoom-3-bfg] Improve launcher script
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rw-r--r-- | PKGBUILD.live | 2 | ||||
-rw-r--r-- | rbdoom-3-bfg-launcher | 76 |
4 files changed, 59 insertions, 27 deletions
@@ -1,7 +1,7 @@ pkgbase = rbdoom-3-bfg pkgdesc = Doom 3 BFG Edition with modern engine features like PBR, Baked Global Illumination, Soft Shadows pkgver = 1.5.1 - pkgrel = 7 + pkgrel = 8 url = https://github.com/RobertBeckebans/RBDOOM-3-BFG install = rbdoom-3-bfg.install arch = x86_64 @@ -28,7 +28,7 @@ pkgbase = rbdoom-3-bfg sha256sums = SKIP sha256sums = 0fb6a3bb9b47cad65d5012ba20dc9de3b1487f4ac1908ee847e6087511b7f09e sha256sums = f317d503d30ecc6e0a70e353cb020d2ea78ecb05d8d2e0250f39cfd8a4fe16a5 - sha256sums = dc8cd0a2e35dcda9b87276c7d996af0fca591e41b005a443cf7850ffec082b29 + sha256sums = a3c3006c254ce25ff890494acc8cfbfb88d406661f4468b56aaefc144227db21 sha256sums = c083d028b5dd6f7c0d13d8d3f7a4b73a0d57d414890fea454eecbbf2dbcdac6d pkgname = rbdoom-3-bfg @@ -5,7 +5,7 @@ pkgname=rbdoom-3-bfg _srctag=1.5.1 pkgver=${_srctag//-/.} -pkgrel=7 +pkgrel=8 pkgdesc="Doom 3 BFG Edition with modern engine features like PBR, Baked Global Illumination, Soft Shadows" arch=('x86_64') url="https://github.com/RobertBeckebans/RBDOOM-3-BFG" @@ -77,5 +77,5 @@ package() { sha256sums=('SKIP' '0fb6a3bb9b47cad65d5012ba20dc9de3b1487f4ac1908ee847e6087511b7f09e' 'f317d503d30ecc6e0a70e353cb020d2ea78ecb05d8d2e0250f39cfd8a4fe16a5' - 'dc8cd0a2e35dcda9b87276c7d996af0fca591e41b005a443cf7850ffec082b29' + 'a3c3006c254ce25ff890494acc8cfbfb88d406661f4468b56aaefc144227db21' 'c083d028b5dd6f7c0d13d8d3f7a4b73a0d57d414890fea454eecbbf2dbcdac6d') diff --git a/PKGBUILD.live b/PKGBUILD.live index e69537118705..f4d9e164b66e 100644 --- a/PKGBUILD.live +++ b/PKGBUILD.live @@ -81,5 +81,5 @@ package() { sha256sums=('SKIP' '0fb6a3bb9b47cad65d5012ba20dc9de3b1487f4ac1908ee847e6087511b7f09e' 'f317d503d30ecc6e0a70e353cb020d2ea78ecb05d8d2e0250f39cfd8a4fe16a5' - 'dc8cd0a2e35dcda9b87276c7d996af0fca591e41b005a443cf7850ffec082b29' + 'a3c3006c254ce25ff890494acc8cfbfb88d406661f4468b56aaefc144227db21' 'c083d028b5dd6f7c0d13d8d3f7a4b73a0d57d414890fea454eecbbf2dbcdac6d') diff --git a/rbdoom-3-bfg-launcher b/rbdoom-3-bfg-launcher index 0e800dfcf255..a37db6404b1b 100644 --- a/rbdoom-3-bfg-launcher +++ b/rbdoom-3-bfg-launcher @@ -3,11 +3,9 @@ import configparser import os -import shutil -import subprocess import sys -from PySide6.QtCore import Qt +from PySide6.QtCore import Qt, QProcess, QProcessEnvironment, QStandardPaths from PySide6.QtWidgets import QApplication, QFileDialog, QMessageBox from xdg import BaseDirectory @@ -17,6 +15,7 @@ doom_dir = "/usr/share/games/doom3bfg" base_name = f"{exe_name.lower()}-launcher" conf_dir = BaseDirectory.save_config_path(base_name) data_dir = BaseDirectory.save_data_path(base_name) +mount_dir = os.path.join(data_dir, "data") def fix_config(parser, path): @@ -36,9 +35,16 @@ def main() -> int: app.setApplicationName(base_name) app.setOrganizationName(base_name) - mergerfs = shutil.which("mergerfs") + if not os.path.exists(mount_dir): + os.mkdir(mount_dir) + elif not os.path.isdir(mount_dir): + QMessageBox.critical(None, f"{base_name}", f"Path <b>{mount_dir}</b> exists and it is not a directory.") + app.exit() + return 1 + + mergerfs = QStandardPaths.findExecutable("mergerfs") if not mergerfs: - QMessageBox.critical(None, f"{base_name}", "<b>mergerfs</b> is not installed.") + QMessageBox.critical(None, f"{base_name}", f"<b>{os.path.basename(mergerfs)}</b> is not installed.") app.exit() return 1 @@ -47,9 +53,11 @@ def main() -> int: if os.path.exists(conf_path): try: config.read(conf_path) - except configparser.MissingSectionHeaderError: - fix_config(config, conf_path) - config.read(conf_path) + except Exception as e: + sys.stderr.write(str(e)) + config.add_section(base_name) + # fix_config(config, conf_path) + # config.read(conf_path) else: config.add_section(base_name) @@ -62,7 +70,7 @@ def main() -> int: f"Without it, the default locations will be searched for game files.\n\n" f"Do you want to set it now?\n" ) - if ans == QMessageBox.Yes: + if ans == QMessageBox.StandardButton.Yes: install_dir = QFileDialog().getExistingDirectory(None, base_name) config.set(base_name, "install_dir", install_dir) @@ -70,19 +78,43 @@ def main() -> int: config.write(conf_file) base_path = [] - if install_dir is not None: - subprocess.run( - [mergerfs, "-o", f"fsname={exe_name}", f"{doom_dir}:{install_dir}", data_dir] - ) - base_path = ["+set", "fs_basepath", data_dir] - - subprocess.run( - [shutil.which(exe_name), "+set", "in_tty", "0", *base_path, *sys.argv] - ) - - if os.path.ismount(data_dir): - subprocess.run(["umount", data_dir]) - + proc = QProcess(app) + proc.setProcessEnvironment(QProcessEnvironment.systemEnvironment()) + + if install_dir: + proc.setProgram(mergerfs) + proc.setArguments(["-o", f"fsname={exe_name}", f"{doom_dir}:{install_dir}", mount_dir]) + proc.start() + proc.waitForFinished(-1) + if proc.exitStatus() == QProcess.ExitStatus.CrashExit or proc.exitCode() != 0: + stderr = proc.readAllStandardError().data().decode('utf-8', 'ignore') + sys.stderr.write(stderr) + QMessageBox.critical( + None, f"{base_name}", + f"<b>{os.path.basename(mergerfs)}</b> failed to execute correctly:\n" + f"{stderr}" + ) + proc.deleteLater() + app.exit() + return 1 + base_path = ["+set", "fs_basepath", mount_dir] + + proc.setProgram(QStandardPaths.findExecutable(exe_name)) + proc.setArguments(["+set", "in_tty", "0", *base_path, *sys.argv]) + proc.start() + proc.waitForFinished(-1) + if proc.exitStatus() == QProcess.ExitStatus.CrashExit or proc.exitCode() != 0: + sys.stderr.write(proc.readAllStandardOutput().data().decode('utf-8', 'ignore')) + + if os.path.ismount(mount_dir): + proc.setProgram(QStandardPaths.findExecutable("umount")) + proc.setArguments([mount_dir]) + proc.start() + proc.waitForFinished(-1) + if proc.exitStatus() == QProcess.ExitStatus.CrashExit or proc.exitCode() != 0: + sys.stderr.write(proc.readAllStandardError().data().decode('utf-8', 'ignore')) + + proc.deleteLater() app.exit() return 0 |