|
|
Porting X11 apps to OpenBSD |
|
|
|
2024-03-15 |
|
|
|
Last edit: 2024-03-15 |
|
|
|
--------------------- |
|
|
|
|
|
|
|
I was getting interested in BSD systems, more specifically OpenBSD, its firewall (`pf`) and more generally its security. Then I wanted to use some programs with a graphical interface such as `xclicker`. But it doesn't exist on the distribution, so I wanted to integrate it. |
|
|
|
|
|
|
|
*By the way, there's a site that explains why OpenBSD is great ( |
|
|
 |
why-openbsd.rocks (https://why-openbsd.rocks) |
|
|
|
).* |
|
|
|
|
|
|
|
I thought it could be interesting to port/package some games I've played during my childhood such as |
|
|
 |
Super Mario War](http://smwstuff.net) or [VVVVVV (https://thelettervsixtim.es) |
text/html |
|
|
. |
|
|
|
|
|
|
|
Before making the game compatible with the distribution, it's best to fetch the port tree ( |
|
|
 |
doc](https://www.openbsd.org/faq/ports/ports.html)) and read the official documentation ([doc (https://www.openbsd.org) |
text/html |
|
|
) to get the essentials. |
|
|
|
|
|
|
|
## OpenBSD environment |
|
|
|
|
|
|
|
My test environment is a virtual machine managed by `virt-manager` (using libvirt to interact with KVM) on which |
|
|
 |
OpenBSD 7.4](https://www.openbsd.org/74.html) has been installed, following the steps [here (https://www.openbsdhandbook.com) |
|
|
|
. |
|
|
|
|
|
|
|
To manage X displays, I used `xenodm` which is installed by default on OpenBSD. You can activate its system service with the following command. |
|
|
|
|
|
|
|
```bash |
|
|
|
rcctl enable xenodm |
|
|
|
``` |
|
|
|
|
|
|
|
And for the windows manager, there's a basic one (cwm) but I opted for i3wm anyway. |
|
|
|
|
|
|
|
## Porting VVVVVV |
|
|
|
|
|
|
|
Few years ago, VVVVVV has released an open source version (engine + levels). The game binary requires a **`data.zip`** file which must be in the same folder, luckily there are options to specify in which folders to look for the fonts and languages. |
|
|
|
|
|
|
|
So that the user doesn't have to fill in all this information himself, I've created a shell script with the appropriate values. |
|
|
|
|
|
|
|
```bash |
|
|
|
#!/bin/sh |
|
|
|
|
|
|
|
NAME=VVVVVV |
|
|
|
GAMES_DIR=${TRUEPREFIX}/games/${NAME} |
|
|
|
SHARE_DIR=${TRUEPREFIX}/share/${NAME} |
|
|
|
|
|
|
|
cd ${GAMES_DIR} |
|
|
|
|
|
|
|
exec ./${NAME} \ |
|
|
|
-fontsdir ${SHARE_DIR}/fonts \ |
|
|
|
-langdir ${SHARE_DIR}/lang \ |
|
|
|
${@} |
|
|
|
``` |
|
|
|
|
|
|
|
Note that `${TRUEPREFIX}` is not defined in the script, this is normal, it will be replaced by `${SUBST_CMD}` defined in **`/usr/ports/infrastructure/mk/bsd.port.mk`**. |
|
|
|
|
|
|
|
This is what the game's makefile looks like. |
|
|
|
|
|
|
|
```makefile |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
# Bsd-like |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
do-extract: |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
do-install: |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
post-install: |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
.for d in lang licenses fonts |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
.endfor |
|
|
|
|
|
|
|
.include |
|
|
|
``` |
|
|
|
|
|
|
|
As you can see, I had to override some of the BSD port makefile targets, because, actually this ports is a little bit special. It must download multiple distfiles from different sites (see below). |
|
|
|
|
|
|
|
```makefile |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
|
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
``` |
|
|
|
|
|
|
|
Moreover, there were conflicts with the extracted files names, so I had to rename the directory containing **`data.zip`**. |
|
|
|
|
|
|
|
```makefile |
|
|
|
do-extract: |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
Happy helping ☃ here: You tried to output a spurious TAB character. This will break gopher. Please review your scripts. Have a nice day! |
|
|
|
``` |
|
|
|
|
|
|
|
Also, we didn't want to build the dependencies using the github modules, because obviously, the released zip file doesn't have a **`.git`** folder inside. |
|
|
|
|
|
|
|
I've also patched a few source files, the full port is available |
|
|
 |
here (https://github.com) |
|
|
|
. |
|
|
|
|
|
|
|
## Links |
|
|
|
|
|
|
 |
My OpenBSD ports (https://github.com) |
|
|
|
|
|