osen / openhl

Digital preservation of Half-Life
35 stars 6 forks source link

Packaging issue #1

Open sdsddsd1 opened 3 years ago

sdsddsd1 commented 3 years ago

I am trying to package openhl and install to /usr. The problem is however that xash3d needs to write on first startup gameinfo.txt to /usr/share/xash3d/valve, basically the XASH_BASEDIR. Without this file the game starts but no "games/content" is available. Some package from the AUR provides a launcher which has the XASH_BASEDIR coded to $HOME, which makes packaging the game data impossible :( https://aur.archlinux.org/cgit/aur.git/tree/xash3d?h=xash3d-fwgs-git A bad workaround is to start the game as root or provide the file. I have to test the file generated on my linux box on my OpenBSD machine.

// generated by Xash3D FWGS 0.20-notset (linux-amd64)

basedir         "valve"
gamedir         "valve"
title           "Half-Life"
startmap                "c0a0"
trainmap                "t0a0"
version         1
dllpath         "cl_dlls"
gamedll         "dlls/hl.dll"
gamedll_linux           "dlls/hl_i386.so"
gamedll_osx             "dlls/hl.dylib"
icon            "game.ico"
sp_entity               "info_player_start"
mp_entity               "info_player_deathmatch"
max_edicts      900
max_tempents    500
max_beams               128
max_particles   4096
osen commented 3 years ago

Hi sdsddsd1,

Yes, there are a couple of issues with packaging so far. You will also see that if you try to save configs such as keyboard or video, these also want to write to share/xash3d/valve (i.e video.cfg).

I am even considering making the script (on first launch) extract the data and build the game into a $HOME/.openhl folder. That way each user has a separate copy of the data but also means they can write to it.

Due to EULA I don't think packaging (and thus /opt, /usr/local installs) are feasible.

I have been planning to have a scan through the code and isolate every write to the /share folder. If this is feasible, I am very happy to tweak the code. Perhaps some sort of overlay system can be added to that it initially reads from the data dir but then reads/writes to the home directory in future.

sdsddsd1 commented 3 years ago

I have made some progress. I just linked the content from share/xash3d/valve to $HOME/ and set XASH3D_BASEDIR to the same. This way the data is readable from share but the write portion happens in $HOME. On first glance I was not able to create quotes for ln -s $PREFIX/share/xash3d/valve/* but it works for me. This is the smallest intrusive effort I came up with. I am packaging for a source based distro. Just distributing a recipe, not distributing any kind of binary. Greetings

#!/bin/sh

PREFIX="$(cd "$(dirname "$(which "$0")")" && cd .. && pwd)"

# $PREFIX/share/xash3d might not be user writeable. Link it to $HOME to possibly create
# necessary config files.
if [ ! -f "$HOME/.config/openhl/notfirstrun" ]; then
    mkdir -p                           "$HOME/.config/openhl/valve"
    touch                              "$HOME/.config/openhl/notfirstrun"
    ln -s $PREFIX/share/xash3d/valve/* "$HOME/.config/openhl/valve"
fi

if [ -z "$XASH3D_BASEDIR" ]; then
    export XASH3D_BASEDIR="$HOME/.config/openhl/"
fi

XASH_BIN_PATH="$PREFIX/lib/xash3d"
HL_CLIENT_LIB="$PREFIX/lib/xash3d/valve/client.so"
HL_SERVER_LIB="$PREFIX/lib/xash3d/valve/hl.so"

LD_LIBRARY_PATH="$XASH_BIN_PATH:$LD_LIBRARY_PATH" "$XASH_BIN_PATH/xash3d" \
 -clientlib "$HL_CLIENT_LIB" -dll "$HL_SERVER_LIB" -console "$@"
osen commented 3 years ago

I quite like this. You possibly might need to make sure to copy any .cfg files across at this point rather than symlinking (otherwise they will still try to write to potentially ro filesystem).

However for now, I am still going to have a dig around the source and see if I can fix it there. Are you OK to maintain this script file (possibly it its entirety) on your package spec? I am currently trying to fix the breakage in the Video Mode menu but will then tackle the config files.

I actually wrote this startup script (I take full responsibility for the cross-platform PREFIX finding script ;) so the license is completely free on it to take the file and do what you want.

sdsddsd1 commented 3 years ago

I need to find test(play) a little more throughly. But so far this looks quiet good. I have it now all packaged incl. the launcher script.

Zirias commented 2 years ago

I ran into the same issue creating a FreeBSD port. There's a better solution, use the -rodir option. It's marked experimental, but works fine for me :)

Here's a patch for the two startup scripts: https://github.com/Zirias/zfbsd-ports/blob/local/games/openhl/files/patch-startup-with-rodir