Arx Libertatis Bug Tracker
star_faded.png
Please log in to bookmark issues
bug_report_small.png
CLOSED  Bug report #242  -  Linux system install issues
Posted Apr 24, 2012 - updated Jun 30, 2013   Shortlink: http://arx.vg/242
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
icon_info.png This issue has been closed with status "Fixed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Bug report
  • Status
     
    Fixed
  • Assigned to
    Not assigned to anyone
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     Alan Swanson
  • Owned by
    Not owned by anyone
  • Estimated time
    Not estimated
  • Category
    General
  • Resolution
    RESOLVED
  • Priority
    Not determined
  • Reproducability
    Always
  • Severity
    Not determined
  • Targetted for
    icon_milestones.png Not determined
  • OS
    icon_customdatatype.png Not determined
  • Architecture
    icon_customdatatype.png Not determined
  • Fixed in
    icon_customdatatype.png Arx Libertatis 1.1
Issue description
Hello. I've been trying to setup Arx Libertatis on Linux as a system install (where users have no write permissions) but have a few problems and believe the following points need considered;

  • Try creating user directories regardless of data directory detection.
  • Copy cfg.ini file rather than moving.
  • Use executable path as possible data directory location.


1) If the USER_DIR_PREFIXES/USER_DIR and CONFIG_DIR_PREFIXES/CONFIG_DIR directories are not manually pre-created then Arx does not create them itself and falls back to current working directory. Reading http://wiki.arx-libertatis.org/Data_directories I believe this due to the data directory not being found as install locations may, especially with games, not always match XDG specifications. Arx should try creating these user directories if not present regardless of data directory not being found (especially as game still runs when current working directory is that of install). Any missing ini files will be still be copied later.

 # ./arx-debug --debug=core
 [D] Startup:119  No data directory found.
 [D] Startup:170  Using working directory as user directory: "."
 [D] Startup:218  Using user directory as config directory: "."
 ...
 [I] Core:4043  Clean shutdown


2) Manually creating the ~/.config/arx allows local configuration settings to be saved. From the cfg.ini warning below I would suggest that this be a file copy rather than a file move to support system installs by changing fs::rename to fs::copy in Application::InitConfig() in src/core/Application.cpp perhaps.

 # mkdir ~/.config/arx
 # ./arx-debug --debug=core
 [D] Startup:119  No data directory found.
 [D] Startup:170  Using working directory as user directory: "."
 [D] Startup:187  Got config directory from CONFIG_DIR_PREFIXES: "/home/user/.config/arx"
 ...
 [W] Application:219  could not move "cfg.ini" to "/home/user/.config/arx/cfg.ini"
 ...
 [I] Core:4043  Clean shutdown


3) However then creating ~/.local/share/arx causes game to fail to run even though current working directory is still the game directory and was running previously! I would suggest using getExecutablePath() in src/platform/Environment.cpp as possible data directory too rather than requiring --data-dir be passed.

 # mkdir ~/.local/share/arx
 # ./arx-debug --debug=core
 [D] Startup:119  No data directory found.
 [D] Startup:142  Got user directory from USER_DIR_PREFIXES: "/home/user/.local/share/arx"
 [D] Startup:187  Got config directory from CONFIG_DIR_PREFIXES: "/home/user/.config/arx"
 ...
 [W] Application:219  could not move "cfg.ini" to "/home/user/.config/arx/cfg.ini"
 ...
 [CRITICAL] ArxGame:468  Unable to find data.pak in "/home/user/.local/share/arx"
 [CRITICAL] ArxGame:407  Error loading pak files
 [CRITICAL] ArxGame:243  Failed to initialize the game data.
 [CRITICAL] Core:676  Application failed to initialize properly.


 # ./arx-debug --debug=core --data-dir=/srv/games/ArxFatalis
 [D] Startup:464  Got data directory from command-line: "/srv/games/ArxFatalis"
 [D] Startup:142  Got user directory from USER_DIR_PREFIXES: "/home/user/.local/share/arx"
 [D] Startup:187  Got config directory from CONFIG_DIR_PREFIXES: "/home/user/.config/arx"
 ...
 [I] Core:4043  Clean shutdown


APPENDIX) For reference this is the list directories output;

 # ./arx-debug --list-dirs
 
 Data directories (data files):
  - --data-dir (-d) command-line parameter
  - "games/arx" in one of "$XDG_DATA_DIRS"
     = "/usr/local/share:/usr/share:/usr/share/gdm":
   * "/usr/local/share/games/arx"
   * "/usr/share/games/arx"
   * "/usr/share/gdm/games/arx"
  - "games/arx"
 selected: (none)
 
 User directories (save files, data files):
  - --user-dir (-u) command-line parameter
  - "arx" in one of "$XDG_DATA_HOME"
     = "/home/user/.local/share":
   * "/home/user/.local/share/arx"
  - "arx"
  - Current working directory
 selected: "."
 
 Config directories:
  - --config-dir (-c) command-line parameter
  - "arx" in one of "$XDG_CONFIG_HOME"
     = "/home/user/.config":
   * "/home/user/.config/arx"
  - "arx"
  - The selected user directory
 selected: "."


Other than that, thank you for all your work on this port!
Steps to reproduce this issue
Nothing entered.

#1
icon_reply.pngReply
Comment posted by
 Guest user
Apr 24, 00:04
Darn, all the formatting was screwed up. Sorry. Any clarifications let me know.
#2
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
Apr 24, 10:09
Hi, thanks for the detailed report. Let me start by describing the install modes we considered for Arx Libertatis under Linux:

1. System-wide install  ⇑ top
In this mode, shared read only data is loaded from /usr/share/games/arx (for data installed by package managers) or /usr/local/share/games/arx (for data installed without a package manager) or from games/arx in any $XDG_DATA_DIRS

Per-user files are stored in ~/.local/share/arx ($XDG_DATA_HOME/arx) and config in ~/.config/arx ($XDG_CONFIG_HOME/arx)

Data files are also loaded from ~/.local/share/arx to support per-user mods etc

User and config directories are automatically created if the system-wide data directory is found.

2. Per-user install  ⇑ top
For this install mode there is no system-wide data directory. Instead, all data is loaded from the user directory ~/.local/share/arx ($XDG_DATA_HOME/arx).

Config is still loaded from ($XDG_CONFIG_HOME/arx)

The config directory is created if the user directory was found.

3. Portable / not installed  ⇑ top
This mode is intended to package data and user files in one directory that can be quickly moved between systems. It is also how pre-release Arx Libertatis worked for a long time.

Here there is no system-wide data directory and both user and config directories are the current working directory.

In thus mode nothing should ever be created in $HOME as that is outside of the install.

Now to your comments...  ⇑ top

If the USER_DIR_PREFIXES/USER_DIR and CONFIG_DIR_PREFIXES/CONFIG_DIR directories are not manually pre-created then Arx does not create them itself and falls back to current working directory. Reading http://wiki.arx-libertatis.org/Data_directories I believe this due to the data directory not being found


Correct. However, if a data directory is found or specified on the command-line, both user and config directories are created automatically.

install locations may, especially with games, not always match XDG specifications.


Well, they should! Also, to be clear, the XDG Base Directory Specification does *not* specify install locations (except defaults). Instead it specifies environment variables that contain install location prefixes (amongst other things). Actual locations are covered by the Filesystem Hierarchy Standard (FHS) standard here does not mean that all distributions follow it completely, which is complete orthogonal standard and doesn't really interest arx that much - it is the responsibility of the distro to specifies the XDG variables if the defaults are not sufficient.

Arx should try creating these user directories if not present regardless of data directory not being found


Why? If the data and user directories could not be found, arx will not start due to missing data files - so why spam the user's home directory with files/dirs that won't be used (yet). After all, the user might have wanted to use an install mode that did not include those directories.

I would suggest that this be a file copy rather than a file move to support system installs by changing fs::rename to fs::copy in Application::InitConfig() in src/core/Application.cpp perhaps.


If you looked at that code you must have noticed that that move is only executed if no config file exists in the config directory, but one exists in the *user* directory, which is defined to be the user's data and should always be writable to the users. The system-wide data directory is never searched for "cfg.ini". If you want a custom system-wide cfg.ini that is copied on the first start, name it "cfg_default.ini", which is loaded from the user and system-wide data directories (in that order of preference).

The only purpose of the move is to migrate old config files as pre-release AL did not always use ~/.config

Also, that is a warning only and will not break the game - it will simply use the hardcoded default config values and save those (and any changes) to ~/.config/arx/cfg.ini later.

However then creating ~/.local/share/arx causes game to fail to run even though current working directory is still the game directory and was running previously!


Yes, this is expected. If the user directory was not found arx will fall back to use the current directory and will the load the data from there. Now that a different user directory is found (the one you created) arx has no more business looking in the CWD - consider that the CWD when launching arx from the .desktop shortcut will be '~' for most users or any random location - why should we look for data files there. What you really want is arx to find your system-wide data directory. Note that you can pass relative directories to --data-dir, so --data-dir=. will load the data files from the CWD even if a user directory is found.

I would suggest using getExecutablePath() in src/platform/Environment.cpp as possible data directory too rather than requiring --data-dir be passed.


The only scenario I can think of (in a FHS world) where the binary directory is also the data directory is the portable install mode and there the binary dir = user dir = config dir (and no system-wide data directory!) so the data will be found through the user directory.

--data-dir=/srv/games/ArxFatalis


What, why would you store game data in /srv/? Is this actually common in any distro? The FHS says /srv is for "Data for services provided by this system" and "contains site-specific data which is served by this system.". As arx is not a service and the data should not be site-specific, i don't see why this directory would be used.

Now as for possible solutions (assuming you want data to be stored in /srv):

  • Use --data-dir=/srv/games/ArxFatalis


  • Define XDG_DATA_DIRS, for example:
 $ export XDG_DATA_DIRS="/srv:$XDG_DATA_DIRS"
will get arx so search for /srv/games/arx as a possible system-wide data directory. Now this should really be done by any XDG-basedir-compliant distro that considers /srv to be a "directoriey relative to which data files should be searched".

  • If these run-time methods of setting the data directory location are not acceptable, you can overwrite the directories at compile time.
 $ cmake .. -DDATA_DIR=/srv/games/ArxFatalis
will then cause the arx binary to use /srv/games/ArxFatalis and only /srv/games/ArxFatalis as the data directory. You should make this change clear to everyone you distribute the binary to.

Note: cmake will remember changes to these variables until you remove CMakeCache.txt

  • Alternatively use
 $ cmake .. -DDATA_DIR_PREFIXES=/srv:\$XDG_DATA_DIRS
which will then cause the arx binary to consider /srv/games/arx as well as /usr/share/games/arx and /usr/local/share/games/arx as the data directory (and whatever else your distro has in XDG_DATA_DIRS). Remember to reset DATA_DIR (e.g. by removing CMakeCache.txt) if you tried the previous solution first.

Darn, all the formatting was screwed up. Sorry. Any clarifications let me know.


Signed in users can edit their descriptions / comments ;-). The next bug tracker version will support OpenID, so that should be even easier.
#4
icon_reply.pngReply
Comment posted by
 Alan Swanson
Apr 24, 15:12
Regarding creating user directories, I concur as I was probably making the point against the data directory not being found. Regarding the cfg.ini copy, I understand now.

However, XDG_DATA_DIR specifications are definitely in the minority for commercial and ex-commercial game installs. The vast majority of commercial and ex-commercial games for Linux uses the executables path as the data directory, whether started via a symbolic link in bin path or a desktop entry. Whilst this can be in part related to install methods used, the real reason is often due to the sheer size of commercial games. Users create specific partitions for games that do not lie in the XDG specifications. In my example it was /srv/game but is more usually /usr/local/games. Yes, users could add this to XDG_DATA_DIRS but also consider users defining their own directory names to which games are installed such as /usr/local/games/ArxFatalis.

In a system install asking each user to define data-dir when the game could simply resolve the executable path itself is not friendly.

Perhaps I'm just old school. smileys/2.png
#5
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
Apr 26, 19:09
What commercial games do is fine for them, but not really relevant to us as we have a completely different distribution model. For commercial games you get everything in one big package that is rarely updated, if ever. For us, the game data is also not updated as that is not in our control (although we might provide patches at some point) - however the game binary is expected to change more frequently and thus it's better to install it through the package manager - meaning it gets installed in a standard (distribution-specific) location. In this setup there is no relation between the binary location and the data location, so loading the data from the executable path (or even trying to do so) would not make much sense.

Users create specific partitions for games that do not lie in the XDG specifications. In my example it was /srv/game but is more usually /usr/local/games. Yes, users could add this to XDG_DATA_DIRS


And they should (/usr/local/games is part of the default list for XDG_DATA_DIRS). How would you install other open source games with larger data files? Why should the install locations be different just because the game is ex-commercial?

I have no problem with adding additional logic to the data directory detection algorithm to make more users happy, as long as it doesn't break existing install modes. And using the executable dir as the data dir does break at least the portable install, as the game doesn't know if the config/saves should be put in the home dir (your system install) or in the game dir (the portable install). I also realize that the portable install is probably not much more common than a custom install such as yours - maybe even less - but as far as changes go, not breaking things for existing users has priority.

My opinion is that such custom installs that don't fit in with the XDG-basedir/FHS specs is best done with a wrapper script that sets the data dir to the custom location - that is after all not too uncommon in the commercial game install you want to emulate. Something like

 #!/bin/sh
 cd "$(dirname "$(readlink -f "$0")")"
 ./arx --data-dir=.


but also consider users defining their own directory names to which games are installed such as /usr/local/games/ArxFatalis.


That is very much something worth considering. But how should the game detect this without the user having to define something? (they can already achieve this by creating a wrapper script) Looking at the executable path is just not a general solution, especially considering how AL is normally meant to be installed.

One option would be to pre-define a list and then use the first one found (e.g 'arx:ArxLibertatis:ArxFatalis') but there will surely be someone this does not cover.

Again, may be this is better covered with a wrapper script.
#7
icon_reply.pngReply
Comment posted by
 Alan Swanson
May 18, 14:27
Using a wrapper script is common for games (and I've done so for Arx Libertis) but, as previously mentioned, since there is already getExecutablePath() in src/platform/Environment.cpp it could be reused obviating the need for any wrapper script. Regardless of your decision, thanks for the port again.
#10
icon_reply.pngReply
Comment posted by
 Daniel Scharrer
Aug 04, 03:24
Git master now always uses/creates ~/.local/share/arx and ~/.config/arx unless told not to do so on the command-line.

Also, more directories are now considered for data dirs: - $XDG_DATA_DIRS/games/arx - $XDG_DATA_DIRS/arx - /opt/games/arx - /opt/arx - executable path

The issue was updated with the following change(s):
  • This issue has been closed
  • The status has been updated, from New to Fixed.
  • The resolution has been updated, from Not determined to RESOLVED.
  • This issue's progression has been updated to 100 percent completed.