Zuccace / mdps-asm-builder

Builder script for Phantasy Star m68k assembly
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Candidate IPS patcher & fixheader for linux #1

Open bge-kernel-panic opened 5 years ago

bge-kernel-panic commented 5 years ago

IPS patcher: https://github.com/kylon/Lipx Alternate: flips: https://github.com/Alcaro/Flips but seems heavy.

For fixheader: I created a script, you can find it here: https://github.com/bge-kernel-panic/ps4disasm/blob/master/linux_build/fixheader.py . Consider the code public domain (I didn't put a license, if you feel this is needed I will)

Zuccace commented 5 years ago

Thanks. I'll incorporate Lipx after I've done my tests. Also thanks for the fixheader. :) I think the license is good as it is. Thanks again!

Zuccace commented 5 years ago

Hmmm. It seems that lipx.py does not have any way to specify where to store the output being generated. This is backwards progress compared to fbeaudet's ips.py. :( But I remember having some problems with ips.py. Maybe I can patch lipx.py then...

bge-kernel-panic commented 5 years ago

Should be easy enough to patch lipx.py. I didn't bother, just added an mv instruction in the build script. So lazy :)

On Sun, Jan 20, 2019 at 11:01 AM Ilja Sara notifications@github.com wrote:

Hmmm. It seems that lipx.py does not have any way to specify where to store the output being generated. This is backwards progress compared to fbeaudet's ips.py https://github.com/fbeaudet/ips.py. :( But I remember having some problems with ips.py. Maybe I can patch lipx.py then...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-455878367, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdnY7tZXp1KKTX17cRSwN7RMlJc1Vngks5vFJLTgaJpZM4aBefP .

-- Benoit Goudreault-Emond -- Reply to: bgoudreaultemond@gmail.com Software Architect & Senior Java/Python Developer, Medscape ( http://francais.medscape.com, http://www.medscape.com) A proud user of Linux---I'd rather work than nursemaid my computer. My slightly less than horrible homepage lives at: http://bge-kernel-panic.blogspot.com

Zuccace commented 5 years ago

Okay. I think I made it. My first foray into pythoning. :P Here's the patch. While doing it i noticed https://github.com/fbeaudet/ips.py/commits/master is actually more up-to-date than Lipx.

Since I'm not familiar with ips patch format, I can't say anything to the way or another. Which one do you think is better suited?

Meanwhile I'll start tinkering with the build.sh...

bge-kernel-panic commented 5 years ago

Frankly, I don't know. I'd use whichever is simpler. I used lipx because it's the first one I found, totally missed ips.py.

The latter does look slightly better. That said your patch to lipx looks good.

I'll try ips.py and let you know if it seems to produce smaller patches.

BTW, one thing I noticed with build.sh -- the hashbang line should read

!/bin/bash, not #!/bin/sh because there are a few bashisms in there. For

most distros that won't be visible because sh is symlinked to bash. But I use debian which uses ash as /bin/sh, and I had to munge the hashbang line for that.

And congratulations on your first pythoning :) I think it's a great language, I pull it out for all my small command line utility needs... I find that at least I can reread them months down the line, unlike my Perl scripts :)

On Mon, Jan 21, 2019 at 2:11 PM Ilja Sara notifications@github.com wrote:

Okay. I think I made it. My first foray into pythoning. :P Here's the patch https://raw.githubusercontent.com/Zuccace/zucca-overlay/master/dev-util/lipx/files/user-definable-output.patch . While doing it i noticed https://github.com/fbeaudet/ips.py/commits/master is actually more up-to-date than Lipx.

Since I'm not familiar with ips patch format, I can't say anything to the way or another. Which one do you think is better suited?

Meanwhile I'll start tinkering with the build.sh...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456173759, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdnYwi4IUbQ6UYe2PMr6wziS3UxIoldks5vFhDKgaJpZM4aBefP .

-- Benoit Goudreault-Emond -- Reply to: bgoudreaultemond@gmail.com Software Architect & Senior Java/Python Developer, Medscape ( http://francais.medscape.com, http://www.medscape.com) A proud user of Linux---I'd rather work than nursemaid my computer. My slightly less than horrible homepage lives at: http://bge-kernel-panic.blogspot.com

Zuccace commented 5 years ago

Hmm. I have tried to keep it POSIX sh. I don't know last time, but I used to test it with busybox sh. I'll create another iissue for it.

BTW, one thing I noticed with build.sh -- the hashbang line should read

!/bin/bash, not #!/bin/sh because there are a few bashisms in there. For

most distros that won't be visible because sh is symlinked to bash. But I use debian which uses ash as /bin/sh, and I had to munge the hashbang line for that.

Zuccace commented 5 years ago

@bge-kernel-panic if you have time, can you test my patch? I've done only preliminary tests (not with actual binaries), but it seems to work.

EDIT: Nevermind. :) New verion is up, but...

Zuccace commented 5 years ago

I cannot yet include Lipx as an "offical" ips patcher utility, since it sometimes creates faulty patches or applies the patch incorrectly. Discuss over https://github.com/kylon/Lipx/issues/3.

Zuccace commented 5 years ago

And fbeaudet/ips.py which I have used before indeed has stopped working. So it seems that the script is now without a proper ips patcher. :( Next obvious step is to try out Flips...

Zuccace commented 5 years ago

After too many hours, I think I have fixed ips.py from fbeaudet/ips.py. At least with my patch, it now creates patches, which succesfully create bit for bit exact binaries. It remains to be seen if the patches are conforming to the IPS file format.

bge-kernel-panic commented 5 years ago

Thanks for letting me know, I'll also check against LunarIPS for my own project.

Sorry I haven't looked at this too much, was busy futzing around with the PSIV French translation (converting some assets, working with the script compressor etc.)

On Tue, Jan 22, 2019, 16:14 Ilja Sara <notifications@github.com wrote:

After too many hours, I think I have fixed ips.py from fbeaudet/ips.py. At least with my patch https://github.com/Zuccace/zucca-overlay/blob/956bf338784d9881b4e14873761693e7b3dc07a6/dev-util/fbeaudet-ips-tool/files/0.1_alpha-r1.patch, it now creates patches, which succesfully create bit for bit exact binaries. It remains to be seen if the patches are conforming to the IPS file format.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456565925, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdnY5dqwu2oVyVNy4zYjrCdHReevdAvks5vF39QgaJpZM4aBefP .

Zuccace commented 5 years ago

No problem! If Lunar can take patches created with the fixed ips.py, then it's looking very good. -- Ilja

On January 22, 2019 11:23:57 PM UTC, Benoit Goudreault-Emond notifications@github.com wrote:

Thanks for letting me know, I'll also check against LunarIPS for my own> project.>

Sorry I haven't looked at this too much, was busy futzing around with the> PSIV French translation (converting some assets, working with the script> compressor etc.)>

On Tue, Jan 22, 2019, 16:14 Ilja Sara <notifications@github.com wrote:>

After too many hours, I think I have fixed ips.py from fbeaudet/ips.py.> At least with my patch>

https://github.com/Zuccace/zucca-overlay/blob/956bf338784d9881b4e14873761693e7b3dc07a6/dev-util/fbeaudet-ips-tool/files/0.1_alpha-r1.patch,> it now creates patches, which succesfully create bit for bit exact binaries.> It remains to be seen if the patches are conforming to the IPS file format.>

—> You are receiving this because you were mentioned.> Reply to this email directly, view it on GitHub>

https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456565925,> or mute the thread>

https://github.com/notifications/unsubscribe-auth/ABdnY5dqwu2oVyVNy4zYjrCdHReevdAvks5vF39QgaJpZM4aBefP> .>

-- > You are receiving this because you commented.> Reply to this email directly or view it on GitHub:> https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456604128

bge-kernel-panic commented 5 years ago

OK, so it checks out; I get the same result, at least with my own use case.

I changed the ips.py to use & 0xFF (with parenthesis around) instead of % 256 because I think that's actually closer to the intent -- it's basically bit banging.

BTW as far as bashisms go in your script, one I managed to find and fix was line 236; replace while [ "${1:0:1}" = "-" ] with while echo -n "$i" | grep '^-'

There are other problems with Debian's dash though, looks like functions don't work exactly as in Bourne Shell. Didn't investigate further; I think dash is quite brain damaged. I have to try it in ash one of those days.

Anyway, thanks for looking into this.

On Tue, Jan 22, 2019 at 7:46 PM Ilja Sara notifications@github.com wrote:

No problem! If Lunar can take patches created with the fixed ips.py, then it's looking very good. -- Ilja

On January 22, 2019 11:23:57 PM UTC, Benoit Goudreault-Emond < notifications@github.com> wrote:

Thanks for letting me know, I'll also check against LunarIPS for my own> project.>

Sorry I haven't looked at this too much, was busy futzing around with the> PSIV French translation (converting some assets, working with the script> compressor etc.)>

On Tue, Jan 22, 2019, 16:14 Ilja Sara <notifications@github.com wrote:>

After too many hours, I think I have fixed ips.py from fbeaudet/ips.py.> At least with my patch>

< https://github.com/Zuccace/zucca-overlay/blob/956bf338784d9881b4e14873761693e7b3dc07a6/dev-util/fbeaudet-ips-tool/files/0.1_alpha-r1.patch ,> it now creates patches, which succesfully create bit for bit exact binaries.> It remains to be seen if the patches are conforming to the IPS file format.>

—> You are receiving this because you were mentioned.> Reply to this email directly, view it on GitHub>

< https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456565925 ,> or mute the thread>

< https://github.com/notifications/unsubscribe-auth/ABdnY5dqwu2oVyVNy4zYjrCdHReevdAvks5vF39QgaJpZM4aBefP

.>

-- > You are receiving this because you commented.> Reply to this email directly or view it on GitHub:>

https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456604128

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-456622458, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdnYyS6UUQsi6AXRKP2fCEqdGSUpnqwks5vF7DkgaJpZM4aBefP .

-- Benoit Goudreault-Emond -- Reply to: bgoudreaultemond@gmail.com Software Architect & Senior Java/Python Developer, Medscape ( http://francais.medscape.com, http://www.medscape.com) A proud user of Linux---I'd rather work than nursemaid my computer. My slightly less than horrible homepage lives at: http://bge-kernel-panic.blogspot.com

Zuccace commented 5 years ago

BTW as far as bashisms go in your script, one I managed to find and fix was line 236; replace while [ "${1:0:1}" = "-" ] with while echo -n "$i" | grep '^-'

I have created #2 for removing bashisms or changing the shebang. ;)

Zuccace commented 5 years ago

I'm about to solve this. I'm going to prefer python based helpers like fixheader of yours, @bge-kernel-panic. Now I have to choose between kylon/Lipx and fbeaudet/ips.py. I think I'll default to Lipx, since there's still some development and I managed to get my patches applied to the upstream. fbeaudet seems to be gone from github?

bge-kernel-panic commented 5 years ago

Well if you prefer Python helpers I'll look for a pure Python BPS diff program. xdelta I don't think we'll find a pure version because it's complex, but BPS does have some traction, I think I saw a pure Python one, and some emulators even autoapply BPS as a softpatch (notably I think retroarch can do this - though unfortunately not for Megadrive/genesis cores, but eventually I guess someone will add it). I'll submit a PR if I find anything. Likely I'll have to munge the pure Python BPS one because it's meant to be used as a library with a bunch of helper scripts, and I'd much prefer a self-contained .py instead.

As far as lipx vs ips.py -- I have no preference, except that it doesn't create buggy IPS files :) Of course something still maintained is better.

On Wed, Jan 30, 2019 at 6:23 AM Ilja Sara notifications@github.com wrote:

I'm about to solve this. I'm going to prefer python based helpers like fixheader of yours, @bge-kernel-panic https://github.com/bge-kernel-panic. Now I have to choose between kylon/Lipx and fbeaudet/ips.py. I think I'll default to Lipx, since there's still some development and I managed to get my patches applied to the upstream. fbeaudet seems to be gone from github?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Zuccace/mdps-asm-builder/issues/1#issuecomment-458909559, or mute the thread https://github.com/notifications/unsubscribe-auth/ABdnY1N-HpRgDAiSIdZE72KJZKRybwBdks5vIYC1gaJpZM4aBefP .

-- Benoit Goudreault-Emond -- Reply to: bgoudreaultemond@gmail.com Software Architect & Senior Java/Python Developer, Medscape ( http://francais.medscape.com, http://www.medscape.com) A proud user of Linux---I'd rather work than nursemaid my computer. My slightly less than horrible homepage lives at: http://bge-kernel-panic.blogspot.com

Zuccace commented 5 years ago

Python helpers are generally good in this project since I can then drop requirement for gcc/clang. In this case it is only the fixheader, thanks for that btw. Also most systems have python already installed. The optimal would be to have all the helpers as awk programs. That way one would only need busybox. But good luck finding anything complex and modern made with awk (although I do love awk).

My plan is for the script to look for patch programs from $PATH. If not found, then download a (preferably) python equivalent.

Zuccace commented 5 years ago

Currently I don't know if either of the smaller python ips patchers work propely in every case. Both have their issues still open. :(