Skip to content

Commit

Permalink
create shell install scripts on wine errors within mg
Browse files Browse the repository at this point in the history
  • Loading branch information
GB609 committed Dec 2, 2024
1 parent 9463ea5 commit d709a0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions minigalaxy/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ def extract_by_wine(game: Game, installer: str, temp_dir: str, config: Config):
command = ["env", *wine_env, wine_bin, installer, *installer_args]
stdout, stderr, exitcode = _exe_cmd(command, False, True)
if exitcode not in [0]:
linesToWrite = [
"#!/bin/sh",
'',
shlex.join(command)
]
if os.path.exists(game.install_dir):
#FIXME fix with test somehow, also do the same for prefix creation
with open(os.path.join(game.install_dir, 'minigalaxy_install_wine_game.sh'), 'w') as f:
f.writelines(linesToWrite)
return _("Wine extraction failed.")

return ""
Expand Down
2 changes: 2 additions & 0 deletions tests/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,11 @@ def test1_extract_by_wine(self, mock_symlink, wine_path, mock_path_exists, mock_
@mock.patch("os.path.exists")
@mock.patch("os.unlink")
@mock.patch("os.symlink")
#FIMXE: Make run again: problem is diagnostic install script written on failure
def test2_extract_by_wine(self, mock_symlink, mock_unlink, mock_path_exists, mock_subprocess, mock_config):
"""[scenario: install failed]"""
mock_path_exists.return_value = True
#side_effect = (True, True, False)
mock_subprocess().poll.return_value = 1
mock_subprocess().stdout.readlines.return_value = ["stdout", "stderr"]
game = Game("Absolute Drift", install_dir="/home/makson/GOG Games/Absolute Drift", platform="windows")
Expand Down

0 comments on commit d709a0c

Please sign in to comment.