Page 1 of 2

HOWTO: specify data directories for spring & unitsync

Posted: 09 Aug 2006, 14:05
by Tobi
Since the documentation for this is currently hidden deep into the source code, I thought it would be good to explain it here.

Basically spring now (as of revision 1787) supports a list with any number of data directories. Each data directory can either be read-only or read-write. Data directories higher on the list take priority over data directories lower on the list. This means that if a file exists in 2 data directories, the one in the highest-priority data directory is used. This applies to both reading and writing, but obviously for writing only read-write directories are used.

The list of data directories can be specified in the following way, where items on the top of this list end up on top of the data directory list (ie. with highest priority). Spring figures the access out for itself, you can see this on the console when starting spring.
  • 'SpringData=/path/to/data' declaration in '~/.springrc' (colon separated list, like PATH)
  • 'SPRING_DATADIR' environment variable (colon separated list, like PATH)
  • Every line in the plain text file '/etc/spring/datadir' is then added to the list (in the same order as appearing in the file).
  • If you passed a 'datadir=/path/to/data' or a 'prefix=/install/path' option to scons configure, then the last directory in the list is set to respectively '$datadir' or '$prefix/games/taspring/' ('datadir=' takes precedence). If you didn't pass such an option, the default value for it is used, ie. '/usr/local/games/taspring'.
  • As a fallback, if there has been no read-write data directory specified, spring automagically adds the current directory to the end of the list.
All of the methods to supply data directory paths to spring, support environment variables substitution, ie. '$HOME/.springdata' expands to e.g. '/home/joe/.springdata'. Note that tilde (~) expansion is NOT supported.

I hope this makes the subject somewhat clearer.

Also, if you find any bugs (it's a brand new feature after all), notify me about them!

Oh, and one note: only absolute paths are accepted, paths not starting with '/' or containing '..' are denied.

Posted: 11 Aug 2006, 02:25
by keithjr
I'm seeing this trend all over the place, and it's probably a relic of an unspoken rule from before I got here, but what data is expected to be in the read-only directory /usr/share/games/whatever? I keep hearing people say that it is the default location but have read NO documentation about this. Somebody clarify the difference between a read-only and read-write datadir and why anybody would ever want to have the former?

Posted: 11 Aug 2006, 03:19
by Tobi
In short:

The difference between read only and read write is (besides that the first isn't writable and the second is) that you can safely install all static data in /usr/whatever on a multiuser system, without needing to make the directory writable for all users, which may impose a security risk.

Somewhat longer:

For someone installing from SVN, you can basically ignore it - just dump all data in trunk/game and run spring from inside that directory and everything will work.

For packagers & sysadmins on multiuser systems however, it's quite impossible or hackish to make a /usr directory world writable. All kind of package checking programs error on that, also it defeates the original point of separating data like it's done on linux: this way you can mount /usr on a disk that reads really fast but doesn't write (or has limited number of rewrites, like flash memory), and keep the per-user things that are written every game (demos, screenshots, debugging files) per user.

Indeed /usr/local/games/taspring is the default location, no clue who invented it, I just kept it the same throughout my modifications.

Whatever you do tho, in practice you will going to see just one or two configurations, which will be:
/usr/local/games/taspring (or whatever the distro uses for static data) for the static data (that's installable through packages (rpm, deb, etc.)), and something like ~/.springdata for the debugging files, screenshots, demos and extra maps a users wants to add without acquiring admin privileges first.

I hope that makes it somewhat clearer.

Posted: 11 Aug 2006, 10:58
by clericvash
I think to be honest we need something that can automate this for all linux platforums.

Mabye spring-gui can include something to set everything up?

Posted: 11 Aug 2006, 11:12
by hollowsoul
ahhh
Short answer no & Long answer no.

This will be up to package maintainers, noway should u run spring-gui as root.
At very least later today have adv setup setup where it will chdir into datadir & then use unitsync / spring. This will be like running spring inside datadir, with no datadirs setup in (/etc/spring/datadir | ~/.springrc) etc.

Posted: 11 Aug 2006, 15:09
by keithjr
For someone installing from SVN, you can basically ignore it - just dump all data in trunk/game and run spring from inside that directory and everything will work.
Excellent, that's exactly what I wanted to know. Once again, thank you!

Posted: 12 Aug 2006, 11:17
by Tobi
I just found another really useful use for this feature: if you use spring on windows & on linux, theres no need to do dull symlinking anymore to get the windows data automatically recognized on linux, but you can just add e.g. '/windows/Program Files/TASpring' to the end of the list of data directories and you automagically have all maps & mods you play on windows on linux too.

Posted: 12 Aug 2006, 11:58
by clericvash
Tobi wrote:I just found another really useful use for this feature: if you use spring on windows & on linux, theres no need to do dull symlinking anymore to get the windows data automatically recognized on linux, but you can just add e.g. '/windows/Program Files/TASpring' to the end of the list of data directories and you automagically have all maps & mods you play on windows on linux too.
WOOOOOOOOOOOOOOOOO

Oh im sorry *haha*

Seriously though, that is an awesome thing!

Posted: 21 Aug 2006, 13:13
by clericvash
What actual file do we edit to add in another data directory?

Posted: 21 Aug 2006, 13:23
by Tobi
Tobi wrote:Every line in the plain text file '/etc/spring/datadir' is then added to the list (in the same order as appearing in the file).
EDIT: made it a bit clearer :roll:

Posted: 21 Aug 2006, 13:30
by clericvash
I don't have an /etc bit for it.

I have an SVN checkout in my src folder and i really can't be fucked with moving all these different folders into /etc/ /usr/ etc etc.

Posted: 21 Aug 2006, 13:35
by hollowsoul
ehh

Code: Select all

mkdir -p /etc/spring
echo "/path/to/datadir" >> /etc/spring/datadir
Repeat last line for each datadir. Its not exactly hard. Or use a GUI text editor

Posted: 21 Aug 2006, 13:46
by Tobi
clericvash wrote:I don't have an /etc bit for it.

I have an SVN checkout in my src folder and i really can't be fucked with moving all these different folders into /etc/ /usr/ etc etc.
Tobi wrote:'SpringData=/path/to/data' declaration in '~/.springrc' (colon separated list, like PATH)
That then if you really can't create 1 single text file in /etc.

And there is no need to fuck-move the folders to /etc/ or /usr/. Please Read The Fucking Manual (aka my post) before complaining...

Posted: 21 Aug 2006, 19:01
by clericvash
Theres no need to be a dick about it tobi, your guide isn't exactly the easiest for a complete linux n00b to follow you know!

Jeezus fucking christ mate.

Posted: 21 Aug 2006, 20:14
by Tobi
Sorry, I just get a bit annoyed when I have to restate the same things over and over (not necesessarily this thing, and not necessarily to you though) while I even took the time to type some documentation for this (tho it isn't the best quality one can get, but I really don't have time to make it better right now).

Posted: 21 Aug 2006, 20:41
by AF
tobi, how about if I added a tab in the options pane of AFLobby that displayed the textfile in /etc/spring/datadir and allowed you to edit it manually while having button to save/load aswell as shortcuts where you checked radio buttons as read writable etc and specified a path and clicked add rather than manually typing it all out......

Posted: 21 Aug 2006, 20:42
by hollowsoul
AF u realise /etc/spring/datadir == system file & really should not be user writeable.
For security purposes which i believe the whole point of mult datadir is for more unix / linux like setups & security.

edited:-
Otherwise a user account could change datadir to there folder, with there own special data files :) For everyone to use
U be hard to find a linux distro to include setup files in /etc/ that are user writeable


Anyway its a matter of the moment to get some
  • source rpm
    source deb
Done to make user install easier.
Would do it myself, but believe u have to package the source code inside it aswell. Which i dont have bandwidth to upload it atm

Posted: 21 Aug 2006, 20:45
by AF
pah

Posted: 21 Aug 2006, 20:59
by clericvash
Forgive me but what is actually the point of a source rpm/deb?

Is it just for easier removal?

What do they actually do?

Posted: 21 Aug 2006, 21:04
by Tobi
I don't know about rpm, but I have done a little .deb packaging in the past.

Basically you always create a source debian package, which is platform independent and can be used, with minor modifications on all debian derivatives. Then there are relatively simple commands that turn the source package into a binary package suitable to the architecture & specific debian derivative on which you run that command.

So for debs, it's really a "source" package: it contains the sourcecode, and it is the source for the binary, user installable .deb packages.

(E: Actually you can't even make binary packages without making a source package first if I'm right.)