about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2021-03-16 02:36:21 +0100
committeraszlig <aszlig@nix.build>2021-04-14 00:50:30 +0200
commitadd4475d51caaf03aca07337e9ad5405ecf2a05c (patch)
tree0a75e69765539d986a13215d54be79f590791769 /pkgs/games
parent67e0540e443706624fff62605f6a632226e95fb4 (diff)
factorio: Fix patcher to work with Radare2 5.x
Version 5.0.0 of Radare2 introduced a few changes in symbol naming,
which causes our patcher to fail because it's unable to find the
"/usr/share/factorio" string and the getSystemWriteData() method.

The upstream change[1] in question for example now uses underscores for
certain characters in the symbol/comment name, so for us to be
backwards-compatible I added a check against the major version of
Radare2 to determine whether we should add underscores when needed.

[1]: https://github.com/radareorg/radare2/commit/aaa930ab261a31e58b1257df06db02481cd3bd55

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/gog/factorio/patch.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkgs/games/gog/factorio/patch.py b/pkgs/games/gog/factorio/patch.py
index 9ffd9bb6..4544e2da 100644
--- a/pkgs/games/gog/factorio/patch.py
+++ b/pkgs/games/gog/factorio/patch.py
@@ -327,7 +327,11 @@ def patch_read_data_path(patcher: Patcher, out: Path) -> None:
     data_path = str(out / 'share' / 'factorio')
     data_path_offset = patcher.write_cstring_to_compost(data_path)
 
-    matches = patcher.raw_command_json('/vj str.usr_share_factorio')
+    if patcher.raw_command_json('?V0') >= 5:
+        name = 'str._usr_share_factorio'
+    else:
+        name = 'str.usr_share_factorio'
+    matches = patcher.raw_command_json(f'/vj {name}')
     assert len(matches) > 0, \
         f'no matches found for /usr/share/factorio: {matches}'
 
@@ -340,7 +344,11 @@ def patch_read_data_path(patcher: Patcher, out: Path) -> None:
 def patch_write_data_path(patcher: Patcher) -> None:
     # This is the function which returns fs::path("$HOME/.factorio"), but since
     # we want to conform to XDG, we need to rewrite that function.
-    fun = patcher.load_function('method.Paths.getSystemWriteData')
+    if patcher.raw_command_json('?V0') >= 5:
+        name = 'method.Paths.getSystemWriteData__'
+    else:
+        name = 'method.Paths.getSystemWriteData'
+    fun = patcher.load_function(name)
 
     # The function in question uses getpwuid(getuid())->pw_dir, so let's find
     # out the register that references the value of the home directory.