cnvogelg / amitools

Various tools for using AmigaOS programs on other platforms
250 stars 69 forks source link

Feature Request: Support for Linux binfmt #176

Open christianhujer opened 1 year ago

christianhujer commented 1 year ago

It would be great to see packaged support for Linux binfmt. Using Linux binfmt, Amiga OS binaries could be directly run from a Linux shell using their name.

I managed to quickly get this running on Ubuntu 22.04 using these files:

File /usr/share/binfms/amiga-vamos:

package amiga-vamos
interpreter /home/christian.hujer/.local/bin/vamos
magic \x00\x00\x03\xf3

(The path in the file obviously would have to be set correctly by make install-binfmt or whatever would be used.)

Then I ran sudo update-binfmts --import amiga-vamos and sudo service binfmt-support force-reload. And voilà, I could run an Amiga-OS binary by making it executable chmod +x hello and then running it using ./hello.

cnvogelg commented 1 year ago

Nice one! I like the approach... Unfortunately, I don't see a way on how to support this automatically on the myriad of Linux variants out there...

However, a readme keeping this information would be really helpful... I'll extend the manual...

riker77 commented 1 year ago

I just set this up myself in Gentoo, where both OpenRC and systemd init-systems use the same format[2] for configuring new binary formats.

/etc/binfmt.d/amiga_hunk.conf :AmigaHUNK:M::\x00\x00\x03\xf3::/path/to/amitools/bin/vamos:

The config file will be picked up by /etc/init.d/binfmtor systemd's systemd-binfmt.service if you (re)start the service. You can also manually add it by issuing[2] the following command - this only works, if the binfmt_misc pseudo-filesystem has already been mounted. cat /etc/binfmt.d/amiga_hunk.conf >/proc/sys/fs/binfmt_misc/register

[1] https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html [2] https://manpages.debian.org/testing/systemd/binfmt.d.5.en.html