System wide installation on Linux.

Everything about ToME 4.x.x. No spoilers, please

Moderator: Moderator

Post Reply
Message
Author
zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

System wide installation on Linux.

#1 Post by zlkndu »

Need to separate binary and data. How do i do that? As far as i understand, game looks for SELFEXE variable? Where do i change it?
BTW, when i change TENGINE_HOME_PATH in t4core.lua compiler shows many warnings. It's not neccessary, is it? Game works, no problems.

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: System wide installation on Linux.

#2 Post by greycat »

Don't try so hard. Pick a place, like /opt/t-engine4 or /usr/local/t-engine4. Build the game there. Then write a script and put it in /usr/local/bin/tome4 or whatever you want to call it:

Code: Select all

#!/bin/sh
cd /opt/t-engine4 || exit
exec ./t-engine ${1+"$@"}
Voila.


zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

Re: System wide installation on Linux.

#4 Post by zlkndu »

Same thing as greycat's suggestion.

Wish i could move binary... :)

zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

Re: System wide installation on Linux.

#5 Post by zlkndu »

I did it. :D

Code: Select all

#Fix saves dir
sed -i -e "s:\.t-engine:tome4:g" build/te4core.lua
sed -i -e "s:PHYSFS_getUserDir():\"${GAMES_STATEDIR}\":" src/physfs.c

#Fix data dir
sed -i \
	-e "s:local dir = __SELFEXE:local dir = \"${GAMES_DATADIR}/tome4/tome4\":" \
	-e 's|print(".*", dir)|print("Loading data from:", dir)|' \
	-e "s:fs.mount(\"game\":fs.mount(\"${GAMES_DATADIR}/tome4/game\":" \
	bootstrap/boot.lua
sed -i \
	-e "s:PHYSFS_mount(selfexe:PHYSFS_mount(\"${GAMES_DATADIR}/tome4/tome4\":" \
	-e "s:PHYSFS_mount(\"bootstrap\":PHYSFS_mount(\"${GAMES_DATADIR}/tome4/bootstrap\":" \
	src/main.c
With this saves will be in $GAME_STATEDIR and data (bootstrap and game folders) can be anywhere $GAMES_DATADIR points to. Doesn't matter where you place executable.

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: System wide installation on Linux.

#6 Post by greycat »

Ignoring for the moment that GNU sed's -i switch is unportable, this is a really, really bad way to make a diff. What you should do instead is make a backup copy of the source dir, edit the files, then use "diff -u -r olddir newdir" to generate a diff file showing the changes you've made in context. Context diffs (actually -u is a "unified diff" but it's similar) can be applied using patch(1).

Now, that said, the changes you've made don't really look correct to me. Among other things, you claim it "doesn't matter where you put the executable", but your sed command is putting the actual value of your variable into the source code -- it's not putting a call to "retrieve environment variable foo and use its value" in the source code. But I'm not a Lua expert, so hey... maybe there's something I don't know.

I also don't understand why you changed .t-engine to tome4.

zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

Re: System wide installation on Linux.

#7 Post by zlkndu »

Tried to do as few corrections as possible. But diff can't substitute environment variables like sed, that means writting new functions for premake, so it would accept path as option. And main source needs a few corrections...

Next, this is done for ebuild. All variables exist only in compile time, that's why i'm putting them in source. Anyway, who needs to move game folders after intstallation? Executable can be moved, but not game folders.

tome4 is an example. In ebuild it uses $PN (package name) to be consistent.

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: System wide installation on Linux.

#8 Post by greycat »

zlkndu wrote: Anyway, who needs to move game folders after intstallation? Executable can be moved, but not game folders.
Exactly my point! Build it where it's supposed to be in the first place, and then you won't have to move it. Or modify it.

zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

Re: System wide installation on Linux.

#9 Post by zlkndu »

The problems are:
1. T-engine looks for data folders in the same directory it runs from. We can't compile src in /usr/share/games than take binary and move it to /usr/games/bin
2. Save folders created in user's home dir. We can't specify folder relative to /

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: System wide installation on Linux.

#10 Post by greycat »

Sure you can.

mkdir -p /usr/share/games && cd "$_"
extract t-engine tarball, move source dir to t-engine4, however makes sense
cd t-engine4
premake4 gmake && make
cat <<EOF >/usr/games/bin/tome4
#!/bin/sh
cd /usr/share/games/t-engine4 || exit
exec ./t-engine ${1+"$@"}
EOF
chmod +x /usr/games/bin/tome4

zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

Re: System wide installation on Linux.

#11 Post by zlkndu »

That is not executable, but a script. ;) And it doesn't fix save dir.

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: System wide installation on Linux.

#12 Post by greycat »

The save dir is not broken. Games are saved in the invoking user's home directory. I don't see what you're trying to achieve here.

Canderel
Sher'Tul
Posts: 1252
Joined: Mon Nov 24, 2003 2:31 pm
Location: South Africa

Re: System wide installation on Linux.

#13 Post by Canderel »

Symbolic links?

I must admit, most of what you said doesn't make sense to me, as I am n00b with linux, but it feels like symlinks might help...

zlkndu
Low Yeek
Posts: 9
Joined: Sun Apr 10, 2011 7:41 am

Re: System wide installation on Linux.

#14 Post by zlkndu »

I want saves in /var/games/tome4

Symbolic links are not good, they add unnecessary files.

greycat
Sher'Tul
Posts: 1396
Joined: Tue May 11, 2010 11:51 pm

Re: System wide installation on Linux.

#15 Post by greycat »

I really don't understand why you want to write save games in a system-wide place, where you have to worry about permissions, and people deleting other people's saves, and so on. The home directory is perfect -- you don't have to do setgid games, audit the damned thing for security holes, etc. the way you'd have to do for a system-wide save location.

Granted, if you do setgid games, audit, etc., then you can stop savefile cheating. If that's even an issue. But somehow I think you are not in fact doing all that work....

Anyway. Enough of this. I've told you how it should be done. If you insist on this insanity, so be it.

Post Reply