Porting a program to Haiku
I see many programs and games ported to Haiku. Here are ported apps from other systems and old BeOS programs.
By testing and working with this programs i often see problems with program files they are not useable, because they are stored in write protected areas of Haiku.
I dont know if this people get not deep enough into the haiku structures or informations for people like this are not available. It is very sad that many of these great programs do not work properly at the end because some of them are not functional.
I want to explain how to solve this problem in form of a game i put into a haiku package in the past. The name of the game is Wallman, a game written with EGSL.
The example program is a game with two data files who are needed to play the game. They are originaly placed into the game folder, but this folder is by default write protected.
So what can we do to solve this?
The solution is easier than you think. What would be the first thought to solve this problem? Correct, move the files that must be writable to a place where this is possible.
First we create a corresponding directory in the User-Settings folder of haiku (/boot/home/config/settings/). To make clear for what the files are, we create a directory with the name of the game.
Then we move the files from game folder to the settings folder.
Then we link the moved files to the game directory as a symbolic link (Right mouse button: "create linke here").
|It is important that the link is set up so that it starts from boot/|
Now you should have two files underlined with dots in the game folder. Thats the links.
Then we create a zip file with the two original program files included. We simply zip the whole settings directory.
zip -r gamedata.zip /boot/home/config/settings/wallman
Make sure that the files contained in the zip file stored with the file path from boot/...
Then copy the zipped file into the game directory.
Now we need to make sure that the zipped file is extracted to /home/config/settings during installing the game.
To do that we need a post-install script. This is nothing more than a text file that is made executable.
Create a new text file in the program folder and name it programname-post-install.sh. The program name in front of the post-install script name is important so that every script is actually executed.
Add following code to the script:
cd /;unzip -o /boot/system/apps/Wallman/gamedata.zip
Now the script has to be made executable. You can use the command chmod or click right mouse button on the script, select "file info", and mark at executable.
If you now build your haiku-package, then you have to create an additional folder for the post-install script.
Create the folder <i>boot</i> and here the folder <i>post-install</i> and copy the script in here.
At the end your package folder should look like this:
If you now create an hpkg and run it, the game will be installed in the applications folder and the required game files will be extracted into the settings folder using the post-install script.
Tutorial by Christian Albrecht (Lelldorin) May 2020
Made available by BeSly the Haiku, BeOS and Zeta knowledge base.