Tool Ren'Py UnRen for MacOS and Linux v0.8.2

5.00 star(s) 1 Vote

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
Suggestion: when de-compiling, it should do so for files in subdirectories of /game as well, as there may be files (such as translations) which are in .rpyc format.
That's a good suggestion. When I feel the need for my lazy ass to release a new version, I'll look into that. :)
 

randomname42

Member
May 30, 2017
139
337
That's a good suggestion. When I feel the need for my lazy ass to release a new version, I'll look into that. :)
It turns out it's actually super simple because unrpyc.py will automatically decompile all .rpyc files in a directory and its subdirectories if you pass it a directory instead of a file. So all you need is:

Code:
function decompile
{
    echo "Decompiling rpyc files"
    pushd "$game" > /dev/null
    python "/tmp/unrpyc.py" "." "-c"
    popd > /dev/null
}
I added the -c argument to force it to overwrite existing decompiled .rpy files.
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
Thanks! I put the changes in my dev copy. They'll be in the next version.

I'll also post this on the UnRen.bat thread for Sam to see.
 

joel69

Newbie
Mar 30, 2018
15
13
Thanks @bossapplesauce for telling me about this. Thanks @jimmy5 for making it (since I'm to lazy to do it myself! :) ).


Some comments:

You're assuming the user's default shell is /bin/sh. That's not always the case. Add this line to the top of the script:

#! /bin/sh

---------------

You should let the user specify the app directory on the command line. Something like:
if [ "$#" -ne 1 ]; then
read appdir
else
appdir = $1
fi

---------------

The main menu doesn't have an exit command.

---------------

In function extract, this code:
for f in $game/*.rpa; do
python "/tmp/rpatool.txt" -x "$f" -o ${f%".rpa"}
done

will extract the files in archive.rpa into the folder "archive", for example. But this gives 2 locations for the scripts - one in game/archive.rpa and one in game/archive/, which will cause errors when the game is launched. Remove the -o option and have rpatool extract in place.

That's what unren 0.7 does:
for %%f in (*.rpa) do (
echo + Unpacking "%%~nf%%~xf" - %%~zf bytes
"%pythondir%python.exe" -O "%rpatool%" -x "%%f"
)

---------------

Extracting packages can take a long time. You should print out something like "Extracting <package>" as you extract each package, so the user isn't staring at a blank screen. See the previous code from unren 0.7 - it prints the package as it extracts it.

---------------

The decompile option installs a decompiler. Instead of that, how about doing the same thing the rpa extract does, and run the decompile now? I use unrpyc from to do that when I want to look at script sources.

Again, that's what unren 0.7 does:

for /r %%f in (*.rpyc) do (
if not %%~nf == un (
echo + Decompiling "%%~nf%%~xf" - %%~zf bytes
"%pythondir%python.exe" -O "%unrpycpy%" "%%f"
)

The game won't launch for me with the decompiler installed. It immediately quits. Also, I can't decompile un.rpyc. If you stick with a decompiler, you should install the .rpy instead of the .rpyc.

---------------

Function finish has this code:
"2")
osascript -e 'tell application "Terminal" to close (every window whose name contains "UnRen Mac v0.1")' & exit
;;

If I'm running from the command line I don't want to close my terminal window!
thanks for the script! to make it work under linux i needed to adapt the base64 parameters: e.g. -d instead of -D and a pipe ( > ) into the target file instead of -o.

btw, shift+o or shift+d (or d for that matter) don't work, no matter whether i use the script or apply the changes manualla, neither the console nor the dev menu gets activated. any idea how to find out what's going on?
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
thanks for the script! to make it work under linux i needed to adapt the base64 parameters: e.g. -d instead of -D and a pipe ( > ) into the target file instead of -o.

btw, shift+o or shift+d (or d for that matter) don't work, no matter whether i use the script or apply the changes manualla, neither the console nor the dev menu gets activated. any idea how to find out what's going on?
Of course base64 takes different arguments...wouldn't want them to be the same! :)

What game are you trying to enable the console for?
The way it works is it creates a file in the "game" directory called unren-dev.rpy, which turns on the console and dev menu in a very late init block. Make sure that file is in the right place, and contains the right code. It's possible the game you're working with has other things that later turn off the console.
 

joel69

Newbie
Mar 30, 2018
15
13
Of course base64 takes different arguments...wouldn't want them to be the same! :)
indeed, who wants easy when you can have cumbersome? ;)

What game are you trying to enable the console for?
The way it works is it creates a file in the "game" directory called unren-dev.rpy, which turns on the console and dev menu in a very late init block. Make sure that file is in the right place, and contains the right code. It's possible the game you're working with has other things that later turn off the console.
it's independent of the game - i have tried many; interestingly, F-keys work, so do CTRL and TAB, but not SPACE. i cannot find a pattern here but i did some further experiments ...

when i add the line config.keymap['developer'].append('shift_D') (or config.keymap['developer'].append('shift_K_d') for that matter) to unren-dev.rpy, the key combination works! i had initially assumed that i needed to remove the entry and re-append it (in the hopes that it would re-initialise things to make it work) but it turned out the combination was not added in the first place, even though the entries are defined in renpy/common/00keymap.rpy (initiated at -1600). i.e. trying to remove them at init 999 yields the error message that the key can't be removed (b/c it can't be found). what gives?

again, explicitly appending the key combo works but i keep wondering why that is necessary for some (read: most) keys ...
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
indeed, who wants easy when you can have cumbersome? ;)


it's independent of the game - i have tried many; interestingly, F-keys work, so do CTRL and TAB, but not SPACE. i cannot find a pattern here but i did some further experiments ...

when i add the line config.keymap['developer'].append('shift_D') (or config.keymap['developer'].append('shift_K_d') for that matter) to unren-dev.rpy, the key combination works! i had initially assumed that i needed to remove the entry and re-append it (in the hopes that it would re-initialise things to make it work) but it turned out the combination was not added in the first place, even though the entries are defined in renpy/common/00keymap.rpy (initiated at -1600). i.e. trying to remove them at init 999 yields the error message that the key can't be removed (b/c it can't be found). what gives?

again, explicitly appending the key combo works but i keep wondering why that is necessary for some (read: most) keys ...
That's really odd. I've never had to redefine keymaps, and I've turned on the console on lots of games.
 

joel69

Newbie
Mar 30, 2018
15
13
That's really odd. I've never had to redefine keymaps, and I've turned on the console on lots of games.
i find that too and have no idea where to start looking for the cause. my own research yielded nothing useful ... it would be great if someone else had a few leads or, even better, knew exactly how to proceed from here.
 

joel69

Newbie
Mar 30, 2018
15
13
indeed, who wants easy when you can have cumbersome? ;)


it's independent of the game - i have tried many; interestingly, F-keys work, so do CTRL and TAB, but not SPACE. i cannot find a pattern here but i did some further experiments ...

when i add the line config.keymap['developer'].append('shift_D') (or config.keymap['developer'].append('shift_K_d') for that matter) to unren-dev.rpy, the key combination works! i had initially assumed that i needed to remove the entry and re-append it (in the hopes that it would re-initialise things to make it work) but it turned out the combination was not added in the first place, even though the entries are defined in renpy/common/00keymap.rpy (initiated at -1600). i.e. trying to remove them at init 999 yields the error message that the key can't be removed (b/c it can't be found). what gives?

again, explicitly appending the key combo works but i keep wondering why that is necessary for some (read: most) keys ...
btw, just to document my workaround in case someone else hits the same problem, i have added the following lines to function console:
Bash:
    echo "  config.keymap['dismiss'].remove('K_SPACE')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['dismiss'].append('K_SPACE')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['developer'].append('shift_K_d')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['developer'].append('shift_D')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['console'].append('shift_K_o')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['console'].append('shift_O')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['developer'].append('K_F6')" >> "$game/unren-dev.rpy"
    echo "  config.keymap['console'].append('K_F7')" >> "$game/unren-dev.rpy"
strictly speaking, it wouldn't be necessary to add both shift_D and shift_K_d as one of them suffices but there is no downside as far as i could see and, more importantly, you never know when this kind of redudancy comes in handy. despite having added shift+O and shift-D, it still can happen that none of them work, which is why i left the F6 and F7 mappings in there - they always worked for me.
 

joel69

Newbie
Mar 30, 2018
15
13
is it possible to add a line to the script that makes sure that the execution flag is set for the game executable in lib/<linux-x86_64 or linux-i686>?

in my UnRen.sh, i have added the following line (just a hack, really) to the quit option ("q"):
Bash:
chmod u+x $appdir/lib/linux-x86_64/${appdir:0:3}*
this line only cares about linux-x86_64 as that's the lib my system is corresponding to but the UnRen.sh script could be more circumspect. also, i did not bother finding out the actual name of the executable as it usually reflects (part of) the appdir, so the line is just taking the first three letters (appdir:0:3) into account.

this addition would be a very practical feature, imho, as it's often the case that the execution flag is not set, which is why the particular game won't start.
 
  • Like
Reactions: Thermophob

Thermophob

Well-Known Member
Apr 10, 2018
1,922
2,577
this addition would be a very practical feature, imho, as it's often the case that the execution flag is not set, which is why the particular game won't start.
But if binary is not executable, then bash launcher is also not set properly. Anyway, majority of games do have executables set properly. Problem is when somebody repacks game (crunched versions, or torrent files where new splash screens are added). Why? Those guys usually work on window and use archive managers which do not understand unix permissions.
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
is it possible to add a line to the script that makes sure that the execution flag is set for the game executable in lib/<linux-x86_64 or linux-i686>?

in my UnRen.sh, i have added the following line (just a hack, really) to the quit option ("q"):
Bash:
chmod u+x $appdir/lib/linux-x86_64/${appdir:0:3}*
this line only cares about linux-x86_64 as that's the lib my system is corresponding to but the UnRen.sh script could be more circumspect. also, i did not bother finding out the actual name of the executable as it usually reflects (part of) the appdir, so the line is just taking the first three letters (appdir:0:3) into account.

this addition would be a very practical feature, imho, as it's often the case that the execution flag is not set, which is why the particular game won't start.
Is it possible? Yes. Does it fit the UnRen mission? Probably not. UnRen is built to open up various hidden things in a Ren'Py game. But another utility to fix permissions? That's a good idea. I'll think about that some.
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
I created a new script. It fixes execute permissions for Mac apps and Linux Ren'Py programs.
 

cold_arctus

Devoted Member
Sep 25, 2018
8,944
10,832
@goobdoob
unren.png

This is what I get, when I try to start your program. And if I drag + drop a folder into the terminal, the terminal crash and close itself.

Code:
~$ base64 --version
base64 (GNU coreutils) 8.25
Copyright © 2016 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder höher <http://gnu.org/licenses/gpl.html>

~$ tar --version
tar (GNU tar) 1.28
Copyright © 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL Version 3 oder später <http://gnu.org/licenses/gpl.html>

~$ uname -a
Linux 4.15.0-43-generic #46~16.04.1-Ubuntu  x86_64 x86_64 x86_64 GNU/Linux
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
@goobdoob
View attachment 234721

This is what I get, when I try to start your program. And if I drag + drop a folder into the terminal, the terminal crash and close itself.

Code:
~$ base64 --version
base64 (GNU coreutils) 8.25
Copyright © 2016 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder höher <http://gnu.org/licenses/gpl.html>

~$ tar --version
tar (GNU tar) 1.28
Copyright © 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL Version 3 oder später <http://gnu.org/licenses/gpl.html>

~$ uname -a
Linux 4.15.0-43-generic #46~16.04.1-Ubuntu  x86_64 x86_64 x86_64 GNU/Linux
It seems that base64 from BSD (the version MacOS uses) -D to decode, while the GNU version used on Linux uses -d. Awesome. There are places where base64 is run. Find them and change -D to --decode .

The "drag and drop" stuff works on the Mac; I don't know if it works on Linux. Copy/paste the path to the game instead.
 

cold_arctus

Devoted Member
Sep 25, 2018
8,944
10,832
It seems that base64 from BSD (the version MacOS uses) -D to decode, while the GNU version used on Linux uses -d. Awesome. There are places where base64 is run. Find them and change -D to --decode .

The "drag and drop" stuff works on the Mac; I don't know if it works on Linux. Copy/paste the path to the game instead.
Unfortunately it did not help.

I also get this error, when I try the first option "Extract RPA packages":

Code:
Extracting RPA packages
/home/cold/Downloads/Games/corruption/Eng/UnRen.command: Zeile 150: pushd: base64 --help/Contents/Resources/autorun/game: Datei oder Verzeichnis nicht gefunden
extracting *.rpa
python: can't open file '/tmp/rpatool.py': [Errno 2] No such file or directory
/home/cold/Downloads/Games/corruption/Eng/UnRen.command: Zeile 155: popd: Der Verzeichnisstapel ist leer.
@Thermophob: does it work for you?

EDIT: OK, I missed one base64 --decode and now I only get this error:

Code:
1
Extracting RPA packages
extracting AON.rpa
python: can't open file '/tmp/rpatool.py': [Errno 2] No such file or directory
extracting archive.rpa
python: can't open file '/tmp/rpatool.py': [Errno 2] No such file or directory
 

goobdoob

Conversation Conqueror
Modder
Respected User
Dec 17, 2017
7,426
9,693
Unfortunately it did not help.

I also get this error, when I try the first option "Extract RPA packages":

Code:
Extracting RPA packages
/home/cold/Downloads/Games/corruption/Eng/UnRen.command: Zeile 150: pushd: base64 --help/Contents/Resources/autorun/game: Datei oder Verzeichnis nicht gefunden
extracting *.rpa
python: can't open file '/tmp/rpatool.py': [Errno 2] No such file or directory
/home/cold/Downloads/Games/corruption/Eng/UnRen.command: Zeile 155: popd: Der Verzeichnisstapel ist leer.
@Thermophob: does it work for you?
It can't find the directory "base64 --help/Contents/Resources/autorun/game". I have no idea where most of that came from. If it can't find the game directory it should exit out very early.

Is it putting unrpyc.py, decompiler and rpatool.py in /tmp?
 

cold_arctus

Devoted Member
Sep 25, 2018
8,944
10,832
It can't find the directory "base64 --help/Contents/Resources/autorun/game". I have no idea where most of that came from. If it can't find the game directory it should exit out very early.
I fixed these by copy and paste to the game folder (next to .exe, .sh etc., where I also put the unren.command), as you mentioned it.

Is it putting unrpyc.py, decompiler and rpatool.py in /tmp?
No.

I think it is not downloading from Github either.
 
5.00 star(s) 1 Vote