1. AIO

I have made changes to the source so that an AIO installer will work on installations other than those with French language preferences on.

Here is the source listing: install_aio.ex

include std/filesys.e  
include std/error.e  
include std/io.e as io 
include std/pipeio.e as pipe  
include std/get.e as get 
 
constant cmd = command_line() 
constant info = pathinfo(cmd[2]) 
object   void = 0  
sequence InitialDir  
integer  f_debug = open(info[PATH_BASENAME]&".log", "w", 1) 
if f_debug =-1 then 
	f_debug = io:STDERR 
end if 
------------------------------------------------------------------------------  
  
public procedure logMsg(sequence msg)  
  puts(f_debug, msg & "\n")  
  flush(f_debug)  
  puts(1, msg & "\n")  
end procedure  
  
------------------------------------------------------------------------------  
  
public function execCommand(sequence cmd)  
  sequence s = ""  
  object z = pipe:create()  
  object p = pipe:exec(cmd, z)  
  if atom(p) then  
    printf(2, "Failed to exec() with error %x\n", pipe:error_no())  
    pipe:kill(p)  
	return -1  
  end if  
  object c = pipe:read(p[pipe:STDOUT], 256)  
  while sequence(c) and length(c) do  
    s &= c  
    if atom(c) then  
	  printf(2, "Failed on read with error %x\n", pipe:error_no())  
      pipe:kill(p)  
	  return -1  
    end if  
    c = pipe:read(p[pipe:STDOUT], 256)  
  end while  
  --Close pipes and make sure process is terminated  
  pipe:kill(p)  
  return s  
end function  
  
------------------------------------------------------------------------------  
  
function isInstalled(sequence package)  
  sequence s = execCommand("dpkg-query -s " & package & " | grep Status")  
  if length(s) and match("ok installed", s) then  
    return 1  
  else  
    return 0  
  end if  
end function  
  
------------------------------------------------------------------------------  
  
procedure installIfNot(sequence package)  
  if isInstalled(package) then  
    logMsg(package & " already installed")  
  else  
    logMsg("apt-get install -y " & package)  
    sequence s = execCommand("apt-get install -y " & package)  
    logMsg(s)  
  end if  
end procedure  
  
------------------------------------------------------------------------------  
  
  sequence targetDirectory = "/usr/local/euphoria-4.1.0"  
  if length(cmd) < 3 then 
    logMsg( "Usage: install_AIO [<target directory>]") 
    logMsg( "Using default target directory: /usr/local/euphoria-4.1.0")  
  else  
    targetDirectory = cmd[3] 
  end if 
  void = chdir(info[PATH_DIR]) 
  InitialDir = current_dir() 
  f_debug = open(InitialDir&SLASH&info[PATH_BASENAME]&".log", "w")  
  crash_file(InitialDir&SLASH&info[PATH_BASENAME]&".err") 
  
  -- verify user is root  
  sequence s = execCommand("id -u") 
  logMsg(s) 
  s = get:value(s) 
  if s[1] != GET_SUCCESS or s[2] != 0 then  
    logMsg("Need to be run as root")  
    close(f_debug) 
    abort(1) 
  end if 
  
  -- install dependencies  
  s = read_lines(InitialDir&SLASH&"dependencies.txt")  
  for i = 1 to length(s) do 
    installIfNot(s[i]) 
  end for 
  
  -- install OpenEuphoria 4.1  
  s = execCommand("mkdir "&targetDirectory)  
  logMsg(s) 
  s = execCommand("tar -xvf "&InitialDir&SLASH&"eu41.tgz -C "&targetDirectory)  
  logMsg(s) 
  
  -- update environment variables  
  if append_lines("/etc/bash.bashrc", {  
    "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:"&targetDirectory&"/bin",   
    "export EUDIR="&targetDirectory, 
    "export EUINC="&targetDirectory&"/include/"  
  }) = -1 then 
    logMsg("Failed to append lines to /etc/bash.bashrc")  
    close(f_debug) 
    abort(1) 
  end if 
  
  -- apply environment variables  
  s = execCommand(". "&SLASH&"/etc/bash.bashrc")  
  logMsg(s)  
    
  close(f_debug) 

Here is a driver, so you don't need to compile the installer but let the tar ball that is included run the script.

install_AIO:

#!/bin/sh 
mkdir eu41 
tar xzf eu41.tgz -C eu41 
rm eu41/bin/eu.cfg 
eu41/bin/eui -i eu41/include install_aio.ex $1 

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu