PlaneShift

Gameplay => General Discussion => Topic started by: hybrasyl on January 04, 2005, 08:03:31 am

Title: Automated Installer for Linux
Post by: hybrasyl on January 04, 2005, 08:03:31 am
Below is a script that you can use to install Planeshift on nearly any linux box.  
Just copy/paste it into an empty text document, save as ps-installer.sh or some such thing, then make sure to chmod a+x the file.

Please enjoy!

Code: [Select]

#!/bin/sh
# \\
exec expect -- \"$0\" ${1+\"$@\"}

## Planeshift installer for linux v2.0 (C)2005 by Hybrasyl
## Licensed GPL etc and so forth, so if it breaks your computer don\'t cry, just fix it


###TODO fix this script so it you can run it without being root
###NOTE: Commented areas are due to bug in the expect sudo combination requiring a work around

##This script has only been tested on SuSE 9.2 and appears to do it\'s job without problems

set setupdir \"~/planeshift\"
set installdir \"/opt\"
set password \"\"
set tout 60
set addvars \"TRUE\"

send_user \"\\n\\nThis program automatically installs Planeshift to your computer\\n\"
send_user \"It\'s the next best thing to a universal RPM for Planeshift so enjoy!\\n\\n\"
send_user \"If you are unsure about what this program does or how it does it, plese READ THE SOURCE!\\n\\n\\n\"
send_user \"This program must be run as ROOT if you are not root please exit now!\\n\\n\"
send_user \"For all entries the directories must already exist\\nThis will hopefully be fixed in the next release\\n\"
send_user \"Please make sure to leave off trailing slashes these will be automatically added for you\\n\"
send_user \"When entering information please note that the defaults are sufficient for MOST OS\'s change them only if needed\\n\\n\"
send_user \"Please enter the directory you want to download to (DEFAULT is $setupdir)\\n\"
send_tty \"$setupdir: \"
set timeout $tout
expect \"\\n\" {
    set raw $expect_out(buffer)
    set setupdir2 [string trimright \"$raw\" \"\\n\"]
    if {$setupdir2 != \"\"} {
       set $setupdir $setupdir2
   }
}

send_user \"Please enter the directory you want to install to (DEFAULT is $installdir)\\n\"
send_tty \": \"
set timeout $tout
expect \"\\n\" {
    set raw $expect_out(buffer)
    set installdir2 [string trimright \"$raw\" \"\\n\"]
    if {$installdir2 != \"\"} {
     set $installdir $installdir2
   }
}

send_user \"Would you like me to add the needed environment variables to your bashrc script?\\n\"
send_user \"(HINT:  If you have used this script before then type NO)\\n\"
send_tty \": \"
set timeout $tout
expect \"\\n\" {
    set raw $expect_out(buffer)
    set addvars2 [string trimright \"$raw\" \"\\n\"]
    if {$addvars2 != \"\"} {
     set $addvars $addvars2
   }
}

#send_user \"To proceed with the install please enter the password for the root user\\n\"
#send_user \"Please note that if you leave this blank you will have to log in as root and run make install in each directory\"
#send_tty \"$password: \"
#set timeout $tout
#expect \"\\n\" {
#    set raw $expect_out(buffer)
#    set password [string trimright \"$raw\" \"\\n\"]
#   }

#exec mkdir $installdir
#exec mkdir $setupdir

cd $setupdir
send_user \"Changed to $setupdir\\n\"

##Cal 3D
spawn cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/cal3d login
expect \"CVS password: \"
send \"\\n\"
expect eof
spawn cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/cal3d co cal3d
expect eof

##Crystal Space
spawn cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/crystal login
expect \"CVS password: \"
send \"\\n\"
expect eof
spawn cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/crystal co CS
expect eof

##CEL
spawn cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/cel login
expect \"CVS password: \"
send \"\\n\"
expect eof
spawn cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/cel co cel
expect eof

##Planeshift
spawn cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/planeshift login
expect \"CVS password: \"
send \"\\n\"
expect eof
spawn cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/planeshift co planeshift
expect eof

##Install Routines
##Cal 3D
send_user \"Beginning Compile of Cal 3D\\n\"
cd $setupdir/cal3d
spawn ./autogen.sh
expect eof
spawn ./configure  --prefix=$installdir/cal3d
expect eof
spawn ./make
expect eof
#if {$password !=\"\"}{
   send_user \"Installing Cal 3D\\n\"
   #spawn sudo make install
    #expect \"Password: \"
  #set timeout $tout
  #send \"$password\\n\"
    spawn make install
  expect eof
  exec export LD_LIBRARY_PATH=$install/cal3d/lib:$LD_LIBRARY_PATH
#}

##CS
send_user \"Beginning Compile of Crystal Space\\n\"
exec cd $setupdir/CS
spawn ./autogen.sh
expect eof
spawn ./configure --with-libcal3d=$installdir/cal3d --enable-new-renderer
expect eof
spawn jam
expect eof
#if {$password !=\"\"}{
 send_user \"Installing Crystal Space\\n\"
 #spawn sudo make install
    #expect \"Password: \"
  #set timeout $tout
  #send \"$password\\n\"
    spawn make install
  expect eof
  exec export CRYSTAL=$installdir/CS
#}

##CEL
cd $setupdir/cel
exec export CSCONFPATH=$installdir/cel/
spawn ./configure --disable-jamtest --enable-new-renderer
expect eof
spawn jam
expect eof
exec export CEL=$installdir/cel/

##Planeshift
cd $setupdir/planeshift
spawn ./autogen.sh
expect eof
spawn ./configure --enable-new-renderer
expect eof
spawn jam -aq
expect eof

##Set .bashrc environment variables
if ($addvars == \"TRUE\"){
   send_user \"Adding environment variables to ~/.bashrc\\n\"
    exec echo\"export HOME=$installdir/planeshift\" >> ~/.bashrc
    exec echo\"export LD_LIBRARY_PATH=$installdir/cal3d/lib:$LD_LIBRARY_PATH\" >> ~/.bashrc
 exec echo\"export CRYSTAL=$installdir/CS\" >> ~/.bashrc
 exec echo\"export CEL=$installdir/cel/\" >> ~/.bashrc
}

send_user \"Install Completed successfully!\\n\"
send_user \"You must now obtain the artwork using the updater unfortunately at this time it is a manual process\\n\"
send_user \"Download\\n\"
send_user \"http://laanx.fragnetics.com/updater_hidden/root/updaterconfig.xml\\n\"
send_user \"user: psteam\\n\"
send_user \"pass: p1ane\\n\"
send_user \"replace updaterconfig.xml in your planeshift dir with the downloaded one.\\n\"
send_user \"To get the laanx server into the server list do the following:\\n\"
send_user \"cd $installdir/planeshift\\n\"
send_user \"Edit the data/servers.xml file with a text editor\\n\"
send_user \"change the file to the following\\n\"
send_user \"\\n\"
send_user \"\\n\"
send_user \"
\\n\"
send_user \"Run the updater before playing the game (yes it will take alot of time. so take some coffee).\\n\"
send_user \"Without this the game has no picture, music, models, world maps, everything.\\n\"
send_user \"Special thanks to kronon for the information above and providing the inspiration for this script!\\n\"
 
exit


Special thanks go to Kronon whose previous work this script is based on, and without whom this script would not have been possible
Title:
Post by: confused on January 04, 2005, 01:38:05 pm
Yeppie!

Something for the non-programmers. Oh, what packages should be installed before running this script? I have Suse 9.1.

Thanx hybrasyl! You my hero!

:)
Title:
Post by: Nedhrys on January 04, 2005, 02:49:15 pm
hi there,

what does chmod a+x mean? Sorry, totally new to both Linux and Planeshift,

thanx,

Nedhrys
Title:
Post by: peeg on January 04, 2005, 04:26:15 pm
\"chmod a+x\" means: Grant execute-privilegs to all Users(Owner/Group/Rest) for given file.
That means: Every User can execute the script.
Title:
Post by: confused on January 04, 2005, 05:10:33 pm
Thanx, for that, I going to start now with the installation. How long did it take?

Remember I a noob to programming! :)

Here is my first error!

~/software/games/planeshift> ./ps-installer.sh
./ps-installer.sh: line 3: exec: expect: not found
Title:
Post by: RHSeeger on January 04, 2005, 10:21:18 pm
> Here is my first error!

> ~/software/games/planeshift> ./ps-installer.sh
> ./ps-installer.sh: line 3: exec: expect: not found

That means you either don\'t have expect (its a program, and a Tcl extension) installed on your system,  or you don\'t have it in your PATH environment variable.
Title:
Post by: Marduk Kurios on January 05, 2005, 01:25:22 am
3 notes:


1-you should intall the expect program . In debian will be something like:

apt-get install expect

2-when you copy/paste appears a blanck line between the real lines, you must delete, at least, the blank lines from the beginning to the line

set setupdir \"~/planeshift\"


3-If you run this like root, you must create a planeshift folder in /root

it\'s all right now
Title: 4th note
Post by: Marduk Kurios on January 05, 2005, 01:28:05 am
4- you should install cvs. In debian will be something like:

apt-get install cvs
Title: Supporting the script
Post by: hybrasyl on January 05, 2005, 01:29:38 am
Hey everyone, as I find workarounds for the problems in the script above I will edit the script, if you know of any fixes please post them here and I will add them to the post.  In the meantime, I have a fulltime job and a brand new baby girl to take care of, so I won\'t be able to support this script.

Please make sure at a minimum you have installed TCL/TK and LSB packages on your system, also check to make sure you have zlib and curl as well as curl-development installed.  The script should pretty much handle the rest.  But if it craps out saying something is missing, go to http://www.rpmfind.net/ and look for what packages have the missing file and or library.

To run the script you will need to have expect installed, most distros I have run, do this by default.
Expect is an extension to the TCL programming language and is installed by either LSB or TCL packages depending on your distro.

Enjoy!
Title:
Post by: raloupower on January 05, 2005, 08:37:46 am
i\'ve this error, don\'t know why :
can\'t read \"0\": no such variable
    while executing
\"exec expect -- \"$0\" ${1+\"$@\"}\"
    (file \"./installer.sh\" line 5)
Can someone help me please? thank you.
Title:
Post by: confused on January 05, 2005, 11:51:47 am
It says you must be ROOT. Does it only install for ROOT and can only be played while ROOT?
Title:
Post by: rapsys on January 05, 2005, 02:31:45 pm
> i\'ve this error, don\'t know why :
> can\'t read \"0\": no such variable
> while executing
> \"exec expect -- \"$0\" ${1+\"$@\"}\"
> (file \"./installer.sh\" line 5)
> Can someone help me please? thank you.

comment out the 5th line :
exec expect -- \"$0\" ${1+\"$@\"}\"
replace it by this :
#exec expect -- \"$0\" ${1+\"$@\"}\"

and run the script like this :
[root@host planeshift]$ expect -- ps-install.sh
Title:
Post by: derula on January 05, 2005, 03:09:32 pm
Quote
Originally posted by raloupower
i\'ve this error, don\'t know why :
can\'t read \"0\": no such variable
    while executing
\"exec expect -- \"$0\" ${1+\"$@\"}\"
    (file \"./installer.sh\" line 5)
Can someone help me please? thank you.


had this too, read:

Quote
Originally posted by Marduk Kurios
2-when you copy/paste appears a blanck line between the real lines, you must delete, at least, the blank lines from the beginning to the line


edit: I got an error:
Beginning Compile of Cal 3D
spawn ./autogen.sh
Running \'aclocal-1.9 \'
Running \'autoheader\'
Running \'libtoolize --force\'
Running \'automake-1.9 --add-missing --force-missing --copy\'
configure.in: installing `./install-sh\'
configure.in: installing `./missing\'
configure.in:63: required file `src/Makefile.in\' not found
configure.in:63: required file `src/cal3d/Makefile.in\' not found
Makefile.am:36: required directory ./src does not exist
spawn ./configure --prefix=/opt/cal3d
couldn\'t execute \"./configure\": no such file or directory
    while executing
\"spawn ./configure  --prefix=$installdir/cal3d\"
    (file \"install.sh\" line 209)

edit2: ran it again and got:
spawn ./make
couldn\'t execute \"./make\": no such file or directory
    while executing
\"spawn ./make\"
    (file \"install.sh\" line 213)
Title:
Post by: rapsys on January 05, 2005, 03:49:10 pm
I re-write the script in REAL bash!

dl it their : http://rapsys.free.fr/planeshift.sh

my mail if trouble rapsys_free_fr
(do not forget to put planetshift in subject)
first _ = @
second _ = .
Title:
Post by: raloupower on January 05, 2005, 03:51:53 pm
My first problem is clear, thank you, but i\'ve got now the same problem with \".make\". I\'ve got
spawn ./make
couldn\'t execute \"./make\": no such file or directory
    while executing
\"spawn ./make\"
    (file \"installer.sh\" line 228)


i edit once again, i\'m trying the new bash script.
Title:
Post by: derula on January 05, 2005, 04:11:48 pm
Quote
Originally posted by rapsys
I re-write the script in REAL bash!


u think it will run better than the expect thingy?

Quote
Originally posted by raloupower
My first problem is clear, thank you, but i\'ve got now the same problem with \".make\". I\'ve got
spawn ./make
couldn\'t execute \"./make\": no such file or directory
while executing
\"spawn ./make\"
(file \"installer.sh\" line 228)


got same on line 213
Title:
Post by: raloupower on January 05, 2005, 04:23:15 pm
for now it\'s seems to work (still compiling). i\'ve been further.. let\'s wait and see.
Title:
Post by: derula on January 05, 2005, 04:26:14 pm
er i\'m lacking of the file cal3d/animcallback.h..... all the time.... so compilation ends up in CS not found? s.o. has this file?

edit: btw:
install_bash.sh: line 233: syntax error near unexpected token `{\'
install_bash.sh: line 233: `if ($addvars == \"TRUE\"){\'

hehe... \"real bash\"? afaik no { but then
Title:
Post by: raloupower on January 05, 2005, 04:35:31 pm
...but 10 mn later :
configure: WARNING: Can not find cs-config in path you provided
no
configure: error:
*** Crystal Space could not be found. The latest version is always available
*** from http://crystal.sourceforge.net/
*** Be sure also that you have either installed Crystal Space or set the
*** CRYSTAL environment variable properly.

+ make
make: *** Pas de cibles sp?cifi?es et aucun makefile n\'a ?t? trouv?. Arr?t.
./planeshift.sh: line 233: syntax error near unexpected token `{\'
./planeshift.sh: line 233: `if ($addvars == \"TRUE\"){\'


...but better that  last time!
Title:
Post by: derula on January 05, 2005, 04:42:24 pm
I guess we have the same problem... look through your log if also cal3d/animcallback.h is missing...

edit: and go to line 233 and replace the if block with:
if [$addvars == \"TRUE\"]; then

echo -e \"Adding environment variables to ~/.bashrc\\n\"

echo -e \"export HOME=$installdir/planeshift\" >> ~/.bashrc

echo -e \"export LD_LIBRARY_PATH=$installdir/cal3d/lib:$LD_LIBRARY_PATH\" >> ~/.bashrc

echo -e \"export CRYSTAL=$installdir/CS\" >> ~/.bashrc

echo -e \"export CEL=$installdir/cel/\" >> ~/.bashrc

fi

edit2: Rapsys: your questioning for adding .bashirc stuff is missing
edit3: this is important, so you don\'t get a too long .bashrc
Title:
Post by: raloupower on January 05, 2005, 04:50:09 pm
let\'s try it!
Title:
Post by: derula on January 05, 2005, 09:52:04 pm
Nevertheless I need a file called animcallback.h from the cal3d package...
Title: Delete it
Post by: hybrasyl on January 06, 2005, 02:12:32 am
Try deleting the directory for cal3D and re-running the script, the CVS updater should download all the files you need.

I like Rapsys bash script better than my own,  however what I don\'t like about it is having to sit and wait for 3 different packages to download just so I can press enter.  I think i will take the good parts from both and merge them to make a nicer script.  Anyways great work Rapsys.
Title:
Post by: derula on January 06, 2005, 01:04:53 pm
okay, i retried that. besides that animcallback.h is still missing, i doubt that the export function do work properly somehow, because it is always telling me, cs could not be found. is any package needed therefor? second, do i have to create the file ~/.bashrc when it isn\'t excisting? third, in the bash version at the end i get somewhat that output:
1.:
+ \'[TRUE\' == \'TRUE]\'
install_bash.sh: line 233: [TRUE: command not found
2.:
+ echo -e \'Install Completed successfully!\\n\'
Install Completed successfully!
every echo appears twice... these 2 are probably from an inomplete conversion into bash?

edit: I\'m running SuSE 9.2 Pro.
Title:
Post by: hybrasyl on January 07, 2005, 03:18:46 am
~/.bashrc is your bash resource file and was created by SuSE when you created your user account.
~/ always means the users home directory so if your user name was jenny and your running SuSE ~/.bashrc would mean.

Look at the file /home/jenny/.bashrc
Predicating a file with a period means it is a hidden file.  To see all the files (just to make sure you have this file go to a command shell and type ls -all
This will show all files and folders on in your current directory, hidden or otherwise.
To view the contents of your bashrc file type
less ~/.bashrc
To edit it by hand (recommended if using less shows some kind of error) you can use pico
pico ~/.bashrc
Alternatively you can also open it in any other text editor such as kwrite (my fav).
kwrite ~/.bashrc or kwrite /home/jenny/.bashrc if your username is jenny :)

I hope that helps, as for the problem of the missing file verify that it is not in fact there .

On my system it\'s
/home/jenny/planeshift/cal3d/include/cal3d/animcallback.h
I also seem to have one at
/home/jenny/planeshift/cal3d/src/cal3d/animcallback.h

If you didn\'t get the file look here for just that one file you can get it from the web enabled cvs tree by going here http://cvs.sourceforge.net/viewcvs.py/cal3d/cal3d/src/cal3d/
and looking for the file, just make sure to copy it to wherever it belongs in your own source tree.
Title:
Post by: derula on January 07, 2005, 12:05:47 pm
thanks for the link... as for the .bashrc: there is a .bashrc in my home directory,  but there is none in the root\'s home (/root), and ~/.bashrc links to /root/.bashrc (which doesn\'t seem to exist) when you are logged in as root, what you have to when starting the script (or don\'t you have to?). so that was my question.

edit: actually I do have animcallback.h, like i found out... then why is there an error message?

edit2: okay, i actually found the problem... the cal3d include path doesn\'t seem to be defined for CS, so it can\'t find animcallback.h... were do I add that? or does it use LD_LIBRARY_PATH constant? This ends with a :, is that why it doesn\'t work for me?

edit3: OKAY. I now manually added to /home/simon/.bashrc the following:
Quote
# Planeshift stuff...
installdir=/usr/local
export HOME=$installdir/planeshift
export LD_LIBRARY_PATH=$installdir/cal3d/lib
export CRYSTAL=$installdir/CS
export CEL=$installdir/cel/

but still: the same error (animcallback.h is not in include path/cal3d...)
I also changed LD_LIBRARY_PATH to $installdir/cal3d/includes which didn\'t seem to work, either.
isn\'t the /home/*/.bashrc used when logged on as root?
or do I need another constant name but LD_LIBRARY_PATH?
I\'m a little confused, since this all is new to me ^^\'

edit4: okay, changed a line in the install script:
Quote
./configure --with-libcal3d=$installdir/cal3d/includes --enable-new-renderer

seems to work by now...

edit5: question: may the download dir as well as the dir i ran the script in deleted after successful install? i guess yes?

edit6: OKAY. I now could install CS after some trouble, but CS won\'t be found by cel or planeshift. the following: $installdir/CS doesn\'t exist. only $installdir/lib/crystalspace and $installdir/include/crystalspace, so does $installdir/share/crystalspace and $installdir/share/crystalspace/doc. so, if i set $CRYSTAL to $installdir/lib/crystalspace it doesn\'t work, $installdir/include/crystalspace doesn\'t work either. which is correct?