Author Topic: [fixed] problems with megaglest in /usr/local megaglest  (Read 5654 times)

Andrew Clark

  • Guest
[fixed] problems with megaglest in /usr/local megaglest
« on: 22 February 2010, 18:46:27 »
hi. i build megaglest from svn (revision number 28), and
i've got problem - when i'm trying execute glest
Code: [Select]
glest.bin > /home/andy/glest.log 2>&1i've got error
Code: [Select]
[andy@timelock megaglest]$ cat /home/andy/glest.log
socket(): Address family not supported by protocol
Exception: Error opening log fileglest.log
[andy@timelock megaglest]$
How can i fix it?

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
problems with megaglest in /usr/local megaglest
« Reply #1 on: 22 February 2010, 19:13:00 »
Which operating system do you use? ( linux? )
Where did you put glest.bin and where did you start it ( you have to be in the megaglest directory to start it )?
Did the user had write rights in the megaglest directory?

Does your computer have a working network connection?
« Last Edit: 22 February 2010, 19:21:49 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Andrew Clark

  • Guest
problems with megaglest in /usr/local megaglest
« Reply #2 on: 22 February 2010, 20:56:39 »
Which operating system do you use? ( linux? )
Code: [Select]
[andy@timelock glest]$ uname -a
Linux timelock.linux 2.6.32-std-def-alt1 #1 SMP Mon Feb 1 17:04:19 UTC 2010 i686 GNU/Linux
[andy@timelock glest]$
Altlinux.
Quote from: titi
Where did you put glest.bin and where did you start it ( you have to be in the megaglest directory to start it )?
I place binary file according to fhs - /usr/bin/
Yes, i change directory to /usr/share/games/megaglest/, and then execute glest.bin
Quote from: titi
Did the user had write rights in the megaglest directory?
Of course not, because i place it in /usr/share/games/
Code: [Select]
[andy@timelock glest]$ ls -lahi /usr/share/games/megaglest/
итого 60K
23200681 drwxr-xr-x  9 root root 4,0K Фев 22 16:19 .
22814861 drwxr-xr-x  4 root root 4,0K Фев 22 11:13 ..
23200786 drwxr-xr-x  4 root root 4,0K Фев 22 11:13 data
23208513 drwxr-xr-x  3 root root 4,0K Фев 22 11:13 docs
23200829 -rw-r--r--  1 andy andy    0 Фев 22 11:16 fileglest.log
23200825 -rw-r--r--  1 root root 7,3K Фев 22 09:56 glest.ico
23200831 -rw-r--r--  1 root root  814 Фев 22 11:26 glest.ini
23200826 -rw-r--r--  1 root root   10 Фев 22 16:19 glest.log
23200827 -rw-r--r--  1 root root   22 Фев 22 09:56 glest.rc
23208671 drwxr-xr-x  2 root root 4,0K Фев 22 11:13 maps
23208689 drwxr-xr-x 11 root root 4,0K Фев 22 11:13 scenarios
23200828 -rw-r--r--  1 root root   51 Фев 22 09:56 servers.ini
23208729 drwxr-xr-x  3 root root 4,0K Фев 22 11:13 techs
23488008 drwxr-xr-x 12 root root 4,0K Фев 22 11:14 tilesets
23584999 drwxr-xr-x  4 root root 4,0K Фев 22 11:14 tutorials
[andy@timelock glest]$
Quote from: titi
Does your computer have a working network connection?
Yes, of course.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
problems with megaglest in /usr/local megaglest
« Reply #3 on: 22 February 2010, 21:12:09 »
Problem: Exception: Error opening log fileglest.log
No logfile could be written because glest needs write accessrights to its installation directory:

Maybe the other problem is due to a similar problem.
Megaglest ( and glest itself too) is not meant to be installed in /usr/local... in a linux system(yet?). Gest versions which can do this are changed by the package providers manually. Glest needs accessrights to the files ( glest.ini,logfiles...)

It should be typically installed in a home directory of a user where all is in place! And don't try to install megaglest over a version which came from your package system, I don't think this will work.

Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Andrew Clark

  • Guest
problems with megaglest in /usr/local megaglest
« Reply #4 on: 22 February 2010, 21:28:12 »
Problem: Exception: Error opening log fileglest.log
No logfile could be written because glest needs write accessrights to its installation directory:
Can you fix that problem? In patch, for old glest version, this problem was solved by
respecting $HOME variable. Patch:
Code: [Select]
--- glest_source_2.0.0/source/glest_game/main/program.cpp.orig  2006-12-01 20:47:26 +0300
+++ glest_source_2.0.0/source/glest_game/main/program.cpp       2006-12-01 20:49:12 +0300
@@ -66,7 +66,10 @@

     //log start
        Logger &logger= Logger::getInstance();
-       logger.setFile("glest.log");
+       string home = getenv("HOME");
+       string logfile = home + "/.glest.log";
+       printf("Logfile patch debug: using %s as logfile\n", logfile.c_str());
+       logger.setFile(logfile.c_str());
        logger.clear();

        srand(time(NULL));
--- glest_source_2.0.0/source/glest_game/facilities/logger.cpp.orig     2006-12-01 20:47:11 +0300
+++ glest_source_2.0.0/source/glest_game/facilities/logger.cpp  2006-12-01 20:50:07 +0300
@@ -48,7 +48,7 @@
 void Logger::add(const string &str,  bool renderScreen){
        FILE *f=fopen(fileName.c_str(), "at+");
        if(f==NULL){
-               throw runtime_error("Error opening log file"+ fileName);
+               throw runtime_error("Error opening log file: "+ fileName);
        }
        fprintf(f, "%s\n", str.c_str());
     fclose(f);
@@ -79,7 +79,7 @@

        FILE *f= fopen(fileName.c_str(), "wt+");
        if(f==NULL){
-               throw runtime_error("Error opening log file"+ fileName);
+               throw runtime_error("Error opening log file: "+ fileName);
        }

     fprintf(f, "%s", s.c_str());
[andy@timelock glest]$
Quote from: titi
Maybe the other problem is due to a similar problem.
Megaglest ( and glest itself too) is not meant to be installed in /usr/local... in a linux system(yet?).
That's right. If i building program from the source code - installation is in /usr/local/ directory.
When i'm installed program from package - rpm (deb, whatever), binary files installed in /usr/bin
Quote from: titi
Gest versions which can do this are changed by the package providers manually. Glest needs accessrights to the files ( glest.ini,logfiles...)
Access rights for read, or write?
Quote from: titi
It should be typically installed in a home directory of a user where all is in place! And don't try to install megaglest over a version which came from your package system, I don't think this will work.
Actually, installation in home directory is a bad idea, because in this directory is my personal data. Software, installed from packages, are
placed in directories, according to Filesystem Hierarchy Standard. I don't try
install megaglest over glest, i try to roll the package for altlinux, that's why i ask for help.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
problems with megaglest in /usr/local megaglest
« Reply #5 on: 22 February 2010, 21:32:42 »
Please come to irc
irc://irc.freenode.net/glest
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Andrew Clark

  • Guest
problems with megaglest in /usr/local megaglest
« Reply #6 on: 22 February 2010, 21:33:14 »
btw - log file may be created/placed in /var/log/ directory.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: problems with megaglest in /usr/local megaglest
« Reply #7 on: 22 February 2010, 21:44:25 »
Of course you are right all files with settings and so on  should be in ~/.glest/ ....
and the logfiles too. But this is not done yet.

The problem is that glest is not linux only!
I already thought about how to solve this problem, but without success, because my C++ skills are are .....
I started to learn c++ with this project!

I already looked at these kind of patches and none of them will ever work on windows :) .
So what can I do?
Btw which version of megaglest are you aiming on? Do you use the data too?

« Last Edit: 22 February 2010, 21:47:24 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: problems with megaglest in /usr/local megaglest
« Reply #8 on: 22 February 2010, 22:57:35 »
Yggdrasil has been working on putting config and addons into the user directory. see https://forum.megaglest.org/index.php?topic=4658.msg36815#msg36815
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Yggdrasil

  • GAE Team
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: problems with megaglest in /usr/local megaglest
« Reply #9 on: 22 February 2010, 23:20:34 »
Yep, but it's now a bit different in trunk with physfs. And physfs is a bit too much regarding code changes and not well tested yet. I have something more simple in mind, which could be also interesting for the 0.2.x branch in GAE. We would face the same problem there.

The posted patch only saves the logfile in home. You still have the problem that the binary needs to be next to the data. I'm also not sure if megaglest needs write access to the settings.

I would just add some unix specific code to set the logfiles/settings to home and after that change the working directory to /usr/share/megaglest (hardcoded) for accessing data in the same way like before.

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #10 on: 23 February 2010, 04:38:03 »
I would just add some unix specific code to set the logfiles/settings to home and after that change the working directory to /usr/share/megaglest (hardcoded) for accessing data in the same way like before.
Can you change it to /usr/share/game/megaglest?

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #11 on: 23 February 2010, 04:57:26 »
Of course you are right all files with settings and so on  should be in ~/.glest/ ....
and the logfiles too. But this is not done yet.
Maybe you want to checkout another opensource games, like
Bloodfrontier,
Sauerbraten
,AssaultCube?
This games have both windows and linux version, and they create .(gamename) directories.
Quote from: titi
The problem is that glest is not linux only!
This is not a problem, from different point of view. ;)
Quote from: titi
I already thought about how to solve this problem, but without success, because my C++ skills are are .....
I started to learn c++ with this project!
That's really great!
Quote from: titi
I already looked at these kind of patches and none of them will ever work on windows :) .
So what can I do?
Well, you may help me with building last svn version of original glest. I came to this
forum, because i got errors when i'm building original glest. I start to read messages,
and then i saw your work (megaglest), and think - maybe build megaglest?
Quote from: titi
Btw which version of megaglest are you aiming on? Do you use the data too?
I build only svn version. I dont understand the question - "Do you use the data too?"
What do you mean?

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: problems with megaglest in /usr/local megaglest
« Reply #12 on: 23 February 2010, 08:46:53 »
I will look at the other games.
For you question concerning the data. megaglest has a lot more content than original glest. There are several tilesets and 4 new factions and some more maps and scenarios. 
I'm the main creator of the glest megapack and all this stuff ( and a bit more ) can now be found in megaglest. So megaglest is not only software, its content too.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #13 on: 23 February 2010, 11:37:44 »
I will look at the other games.
Thank you. I hope you find something useful for yourself.
Quote
For you question concerning the data. megaglest has a lot more content than original glest. There are several tilesets and 4 new factions and some more maps and scenarios. 
I'm the main creator of the glest megapack and all this stuff ( and a bit more ) can now be found in megaglest. So megaglest is not only software, its content too.
I know that, thats why i starting to roll megaglest package :)

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: problems with megaglest in /usr/local megaglest
« Reply #14 on: 24 February 2010, 10:16:12 »
What about a start parameter or environment variable where you can give a directory for usage?
When you start glest with a script everything should be solved?
What do you think about this?
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Yggdrasil

  • GAE Team
  • Ornithopter
  • ********
  • Posts: 408
    • View Profile
Re: problems with megaglest in /usr/local megaglest
« Reply #15 on: 24 February 2010, 15:04:58 »
Just use this patch from gentoo (the last one):
http://bugs.gentoo.org/259701

It does more or less what i said. It does not work on windows, so just apply it for your package.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: problems with megaglest in /usr/local megaglest
« Reply #16 on: 25 February 2010, 14:12:11 »
Another idea without a patch or codechange:
A startscript that builds up a virtual view in users .glest directory using links and copies like this:

if [ ! -h techs ]
then
  ln -s /usr/local/share/glestdata/techs  --target-directory=$HOME/.glest
fi

and so on for other needed directories/files.
Files which will be changed with a copy of course
and so on...

All this in a startscrpit will make all codechanges unnecessary
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #17 on: 20 March 2010, 09:10:15 »
Just use this patch from gentoo (the last one):
http://bugs.gentoo.org/259701

It does more or less what i said. It does not work on windows, so just apply it for your package.
Thank you, that patch is work (after slightly modification). Well, megaglest svn110 is in my git.
http://git.altlinux.org/people/andyc/packages/
Greets flies to: titi, softcoder and other people, who don't let the game die!

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: problems with megaglest in /usr/local megaglest
« Reply #18 on: 20 March 2010, 09:35:39 »
you can also look at the ubuntu startscripts. They do the trick with the links without modifying the source!
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: problems with megaglest in /usr/local megaglest
« Reply #19 on: 21 March 2010, 22:59:36 »
Tomorrow I'll checkin to SVN an update that allows a user to setup a special environment variable to over-ride the location of all writable logs and ini files:

you must set the following environment variable:

GLESTHOME

If this variable has been setup and is a valid path, then MEga-Glest (the next release) will use it. This should work with Windows and Linux (not sure about MAC).

Linux users could go:

GLESTHOME=$HOME

While Windows users could go:

SET GLESTHOME=%APPDATA%

This will allow mega-glest to run in environments where the game is installed in a location where the running user cannot write to files but allow them to over-ride the default path to save and read logs and ini files.

Thanks

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #20 on: 8 June 2010, 18:56:40 »
Tomorrow I'll checkin to SVN an update that allows a user to setup a special environment variable to over-ride the location of all writable logs and ini files:

you must set the following environment variable:

GLESTHOME

If this variable has been setup and is a valid path, then MEga-Glest (the next release) will use it. This should work with Windows and Linux (not sure about MAC).

Linux users could go:

GLESTHOME=$HOME
Hello!
I want to ask about environment variable GLESTHOME. Is there some equal
variable in glest.ini? Because if i define GLESTHOME in shell, after reboot this
variable is gone, and besides - different people use different shells, i can't guess
what exact shell user are using.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: problems with megaglest in /usr/local megaglest
« Reply #21 on: 8 June 2010, 19:15:10 »
The problem is that we need to know the "path" to files before we read any file!

This path then tells us where to find important files that we need to be able to read and write to such as:
glest.ini
*.log
*.lck
etc..

So if you want to point glest to a specific folder.. edit the existing glest bash script and add the exported environment variable in there, then have the game launch via the glest script (which the linux installer already does)

Thanks

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #22 on: 8 June 2010, 20:05:10 »
The problem is that we need to know the "path" to files before we read any file!
So am i need to know "path", because i am maintain megaglest in altlinux distro and i don't know
how many users in system and how his names, so i ask about variable in glest.ini that user could
define...
This path then tells us where to find important files that we need to be able to read and write to such as:
glest.ini
*.log
*.lck
etc..
...and from that variable megaglest could read path where to find *.log
So if you want to point glest to a specific folder.. edit the existing glest bash script and add the exported environment variable in there, then have the game launch via the glest script (which the linux installer already does)
thats good idea! But the question is - how i explain to user, that he need to edit starting script?
Thank you for your answer!

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: problems with megaglest in /usr/local megaglest
« Reply #23 on: 8 June 2010, 23:42:01 »
Ok Andrew, I'd love to help you with this. So please tell me the following and I will see if I can add support to do what you need:

a) where do you plan to deploy Mega-Glest (the path) and what access permissions do all users have?
b) what location can all users read AND write to (relative to the installation)?

Thanks

Andrew Clark

  • Guest
Re: problems with megaglest in /usr/local megaglest
« Reply #24 on: 9 June 2010, 07:58:53 »
thats good idea! But the question is - how i explain to user, that he need to edit starting script?
Answer to yourself. We may change startup script like this:
Code: [Select]
#!/bin/sh
GLESTHOME=$HOME
export GLESTHOME
/bin/ln -s /usr/share/games/megaglest/glest.ini $GLESTHOME/glest.ini
cd /usr/share/games/megaglest/
/usr/bin/megaglest-bin
So we don't need to know how many users in the system and
and their names. When i come home, i check this workaround.
Ok Andrew, I'd love to help you with this. So please tell me the following and I will see if I can add support to do what you need:
Thank you for your help!
a) where do you plan to deploy Mega-Glest (the path) and what access permissions do all users have?
b) what location can all users read AND write to (relative to the installation)?
a) megaglest data files is in /usr/share/games/megaglest, according to fhs. users can not write to that directory (only root
has write permissons)
b) i think only location where user can write - it is own home directory. So we can create symbolic link to ini file and
log file created in home directory automatically. If user need to edit ini file, he is switch to root and do what he want.
« Last Edit: 9 June 2010, 08:01:37 by Andrew Clark »