The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: sumpfralle on November 08, 2012, 02:02:46 AM

Title: Linux: executable flags and get_pak problems
Post by: sumpfralle on November 08, 2012, 02:02:46 AM
Hi,

after downloading and extracting simulinux-112-0.zip I noticed that the two executable files ("simutrans" and "get_pak.sh") are not marked as executable. This will prevent them from being run. It can be fixed by running "chmod +x FILENAME".
Maybe the zip archive was packaged on a non-linux machine - thus there were no executable flags supported by that filesystem?

The other problem is the name of the script for downloading pak sets. The extracted filename is "get_paks.sh". But the "simutrans" executable tries to run "get_pak.sh". Either the file needs to be renamed or the binary needs to point to the real filename.

Additionally there are two problems in the "get_pak" scripts:

Additionally there are some more small issues in the shell script (cosmetics & style). Please consider my changes (including the two problems above) described in this patch:
http://pastebin.com/XHmvcLXa (http://pastebin.com/XHmvcLXa)

thanks for working on simutrans!
cheers,
Lars
Title: Re: Linux: executable flags and get_pak problems
Post by: prissi on November 08, 2012, 09:35:48 AM
And thank you very much, the existing script was mostly tested on windows and Haiku. You could have attached the patch also here.


Chmod is actually done for simutrans, since the zip is packed in a unix machine. I have to look up how to set get_pak.sh with exe bit. It did run on my machine without any modifications. Not sure, if this is a new ubuntu zip security feature ...
Title: Re: Linux: executable flags and get_pak problems
Post by: sumpfralle on November 08, 2012, 11:40:59 AM
Hi prissi,

uploading patches: thanks for the hint - I overlooked this feature ...

Simutrans executable flag: currently I see the following here:

$ unzip /home/lars/Desktop/Downloads/simulinux-112-0.zip
$ ls -l simutrans/simutrans
-rw-r--r-- 1 lars lars 3339640 Okt 22 23:37 simutrans/simutrans


Regarding the get_pak.sh executable flag: here I see the following (with the patched script but without executable flag):

$ ./simutrans
sh: 1: /home/lars/ttt/simutrans/simutrans//get_pak.sh: Permission denied


It looks like you try to execute the file directly (excuse my pseude-code):
execve(get_pak.sh", ..)
This requires the executable flag. But if you run it via
execve("/bin/bash", ["get_pak.sh", ..]..)
then you do not need the flag.
Maybe the method of calling the script changed somewhen?

And for the last detail: there is Debian here - so I don't think this is caused by weird Ubuntu madness :)

Have a nice day!
Lars
Title: Re: Linux: executable flags and get_pak problems
Post by: prissi on November 08, 2012, 11:54:42 AM
For the unix build I simply ran "./distribute.sh". This should have added the file to the zip file as is was on the disc. MAybe when looking into it on windows before upload, windows remove those (even though I did not copy anything into the zip.) I will take extra care of this next time.

And the script is run by

char command[2048];
sprintf(command, "%s/get_pak.sh %i", path_to_program, portable);
system( command );

Otherwise it will be very difficult to the the right path for the shell.
Title: Re: Linux: executable flags and get_pak problems
Post by: sumpfralle on November 08, 2012, 03:41:52 PM
The "system" call (at least according to its manpage) uses "sh -c COMMAND" to execute the given string. This means that COMMAND (here "/FULL/PATH/get_pak.sh") needs to be executable anyway.

Thus you probably used a non-standard environment if it allowed you to execute the script without an executable flag :)