OpenTESArena
OpenTESArena copied to clipboard
Not fully linux file system compatible
Hello there I wish you a very pleasant evening/morning/day/night :D
While I was about to add this nice little project to the software repositories of my favorite distribution I noticed some Linux filesystem inconsistency regarding the load path of the options-default.txt
While you already allow for overrides to the default options file via ~/.local/share/OpenTESArena/options/options-changes.txt and there fore allow for loading the data files from somewhere else the engine still insist on loading the default options relative from the location where executable is located.
While this works fine for the releases you build and ship by placing OpenTESArena relative to options/ and data/ this is difficult to achieve for any software package which should be installed on a default Linux system.
If someone tries to bundle software for any Linux distribution there are some file structures and concept to be followed. One of these is that binaries are to be located at /usr/bin and data files at /usr/share/application-name/
For TESArena this would look like:
/usr/bin/TESArena and /usr/share/OpenTESArena/data /usr/share/OpenTESArena/options
Since at start up OpenTESArena searches for the default option file relative to it's binary location is will fail to do so because there will be no /usr/bin/options/ folder.
It would be nice if you may also let the engine search for the default options in ~/.config/OpenTESArena/options/options-default.txt as if it can not locate this file relative to the executable or maybe embed the options-default.txt into the executable and load it from there.
[Game/Game.cpp(35)] Initializing (Platform: Linux). [Game/Options.cpp(611)] Reading defaults "/usr/bin/options/options-default.txt". [utilities/KeyValueFile.cpp(149)] Error: Could not find "/usr/bin/options/options-default.txt". [Game/Options.cpp(85)] Error: Couldn't load "/usr/bin/options/options-default.txt".
Thank you for your time and efforts :)
I looked around at Platform.cpp and some stuff and I think just this needs to change to look at the ~/.config/ path if it can't find options next to the executable. Maybe need a defaultOptionsPath and defaultOptionsPathFallback.
Should I be using this for the fallback? https://github.com/afritz1/OpenTESArena/blob/075ce256ccb4d446a7d1ebd90f7d8a2e33a12fb5/OpenTESArena/src/Utilities/Platform.cpp#L37
Do I need to change the data path too? You made it sound like you could change the ArenaPath in options-changes.txt to get things working fine.
Is there an easy way to test? I don't really know the Unix filesystem very well.
Side note: maybe the base path should be renamed to data path and it should include /data/ at the end.
Side note 2: I don't really want the Linux binary to be called TESArena, but I thought there was some limitation with the binary name conflicting with a folder name. On Windows this limitation doesn't exist.
Nevermind what I've said. I found a solution for this :D
Thankfully the file system guideline allow for some stunts inside the library path. like /usr/lib or /usr/lib64
I now moved the TESArena binary to: /usr/lib/OpenTESArena/ or /usr/lib64/OpenTESArena/ on 64bit systems And created symlinks from there to: /usr/share/OpenTESArena/data/ and /usr/share/OpenTESArena/options/
While keeping a symlink in /usr/bin/TESArena to /usr/lib:lib64/OpenTESArena/TESArena
I found other applications (firefox) which do this the same way :)
I guess it is now up to you if you may want to adapt the current behavior or just keep it
Also I'll rename the TESArena binary to OpenTESArena to conform with you. It's very well possible it was just me renaming stuff in the package build recipe to better distinct between the folder and the binary but now that I sorted out the stuff I can make it OpenTESArena instead :)
My bad I am also still new to package software at all and tend to do errors and sometimes need to ask around how to do things properly and then get the necessary answers like the thing with the lib folders :D
@afritz1 I do not think this is something you might want to handle at runtime. Commonly you set up the paths at compile time, as they will not change.
So e.g. if you want to package it for a standard linux distribution, this patch allows you to install it like any other game / program / application: custom-paths.patch.txt
(Sorry had to rename it to .txt as github does not allow patch-files).
You would compile it like
cmake \
-DOPENTESARENA_OPTIONSDIR=/etc/OpenTESArena \
-DOPENTESARENA_DATADIR=/usr/share/OpenTESArena
As there are currently no install targets you would then install / copy
OpenTESArena -> /usr/bin
data/* -> /usr/share/OpenTESArena
options/* -> /etc/OpenTESArena
I think I want to keep most of those ifdefs out of general engine code and keep it all in Platform.cpp. I want it to be really easy to make things work across Windows/Linux/macOS. Not entirely set on the idea of doing it in CMake either although that seems like an agreeable option.
I get a little nervous when it comes to things like where a user want files to go because that seems to change frequently and for various reasons, especially with Linux. If the CMake paths would make it work for every conceivable Linux distro and package manager then I'll probably go for it, but I just don't have enough experience to know which way to go with.
On Linux it should use the XDG standards.