added linux only check for sudo usage and write / execution permissions for the installer folder itself

This commit is contained in:
Faraphel 2022-08-30 15:30:38 +02:00
parent 48f7236755
commit 4a19aff206
5 changed files with 20 additions and 4 deletions

View file

@ -115,6 +115,8 @@
"CONVERTING_TO_RIIVOLUTION": "Converting to Riivolution patch", "CONVERTING_TO_RIIVOLUTION": "Converting to Riivolution patch",
"PATCHS": "patchs", "PATCHS": "patchs",
"PRE-PATCHS": "pre-patchs", "PRE-PATCHS": "pre-patchs",
"CALCULATING_HASH_FOR": "Calculating hash for" "CALCULATING_HASH_FOR": "Calculating hash for",
"WARNING_NOT_ROOT": "The application require root permission. You should start the application with 'sudo'. Continue anyway ?",
"WARNING_INSTALLER_PERMISSION": "The application need writing and execution permissions to its own files. You can use 'sudo chmod 777 -R <installer-path>' to fix that. Continue anyway ?"
} }
} }

View file

@ -116,6 +116,8 @@
"CONVERTING_TO_RIIVOLUTION": "Conversion en patch Riivolution", "CONVERTING_TO_RIIVOLUTION": "Conversion en patch Riivolution",
"PATCHS": "patchs", "PATCHS": "patchs",
"PRE-PATCHS": "pre-patchs", "PRE-PATCHS": "pre-patchs",
"CALCULATING_HASH_FOR": "Calcule du hash pour" "CALCULATING_HASH_FOR": "Calcule du hash pour",
"WARNING_NOT_ROOT": "Cette application nécessite les permissions root. Vous devriez lancer l'application avec 'sudo'. Continuer quand même ?",
"WARNING_INSTALLER_PERMISSION": "Cette application nécessite les permissions d'écriture et d'exécution sur ses propres fichiers. Vous pouvez utiliser 'sudo chmod 777 -R <installer-path>' pour corriger cela. Continuer quand même ?"
} }
} }

View file

@ -4,6 +4,8 @@ __author__ = 'Faraphel'
# external links # external links
import os
discord_url = "https://discord.gg/HEYW5v8ZCd" discord_url = "https://discord.gg/HEYW5v8ZCd"
github_wiki_url = "https://github.com/Faraphel/MKWF-Install/wiki/help" github_wiki_url = "https://github.com/Faraphel/MKWF-Install/wiki/help"
readthedocs_url = "https://mkwf-install.readthedocs.io/" readthedocs_url = "https://mkwf-install.readthedocs.io/"
@ -17,6 +19,7 @@ Go: int = 1_000 * Mo
minimum_space_available: int = 15*Go minimum_space_available: int = 15*Go
file_block_size: int = 128*Ko file_block_size: int = 128*Ko
system = "win64" if os.name == "nt" else "lin64"
# global type hint # global type hint
TemplateSafeEval: str TemplateSafeEval: str

View file

@ -379,6 +379,16 @@ class ButtonInstall(ttk.Button):
if not messagebox.askokcancel(_("WARNING"), _("WARNING_LOW_SPACE_CONTINUE")): if not messagebox.askokcancel(_("WARNING"), _("WARNING_LOW_SPACE_CONTINUE")):
return return
if system == "lin64": # if linux
if os.getuid() != 0: # if the user is not root
if not messagebox.askokcancel(_("WARNING"), _("WARNING_NOT_ROOT")):
return
if not os.access("./", os.W_OK | os.X_OK):
# check if writing (for the /.cache/) and execution (for /tools/) are allowed
if not messagebox.askokcancel(_("WARNING"), _("WARNING_INSTALLER_PERMISSION")):
return
game = Game(source_path) game = Game(source_path)
output_type = Extension[self.root.options.extension.get()] output_type = Extension[self.root.options.extension.get()]

View file

@ -1,13 +1,12 @@
import subprocess import subprocess
from pathlib import Path from pathlib import Path
import os
from typing import Callable from typing import Callable
from source import system
from source.translation import translate as _ from source.translation import translate as _
tools_dir: Path = Path("./tools/") tools_dir: Path = Path("./tools/")
system = "win64" if os.name == "nt" else "lin64"
subprocess_kwargs = {"creationflags": subprocess.CREATE_NO_WINDOW} if system == "win64" else {} subprocess_kwargs = {"creationflags": subprocess.CREATE_NO_WINDOW} if system == "win64" else {}
# creationflags are Windows specific. Linux don't show any subprocess window per default. # creationflags are Windows specific. Linux don't show any subprocess window per default.