Page 1 of 1

System wide installation on Linux.

Posted: Sun Jul 17, 2011 12:14 am
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.

Re: System wide installation on Linux.

Posted: Sun Jul 17, 2011 2:11 am
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.

Re: System wide installation on Linux.

Posted: Mon Jul 18, 2011 6:44 am
by Dinth

Re: System wide installation on Linux.

Posted: Mon Jul 18, 2011 1:56 pm
by zlkndu
Same thing as greycat's suggestion.

Wish i could move binary... :)

Re: System wide installation on Linux.

Posted: Thu Jul 21, 2011 1:15 am
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.

Re: System wide installation on Linux.

Posted: Thu Jul 21, 2011 12:21 pm
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.

Re: System wide installation on Linux.

Posted: Thu Jul 21, 2011 7:34 pm
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.

Re: System wide installation on Linux.

Posted: Thu Jul 21, 2011 8:39 pm
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.

Re: System wide installation on Linux.

Posted: Thu Jul 21, 2011 9:33 pm
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 /

Re: System wide installation on Linux.

Posted: Thu Jul 21, 2011 11:59 pm
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

Re: System wide installation on Linux.

Posted: Fri Jul 22, 2011 5:02 pm
by zlkndu
That is not executable, but a script. ;) And it doesn't fix save dir.

Re: System wide installation on Linux.

Posted: Sat Jul 23, 2011 12:13 am
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.

Re: System wide installation on Linux.

Posted: Sat Jul 23, 2011 7:46 am
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...

Re: System wide installation on Linux.

Posted: Sat Jul 23, 2011 10:52 pm
by zlkndu
I want saves in /var/games/tome4

Symbolic links are not good, they add unnecessary files.

Re: System wide installation on Linux.

Posted: Sun Jul 24, 2011 1:55 pm
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.