]> SALOME platform Git repositories - tools/install.git/commitdiff
Salome HOME
Initial version
authoradmin <salome-admin@opencascade.com>
Mon, 29 Sep 2003 11:06:45 +0000 (11:06 +0000)
committeradmin <salome-admin@opencascade.com>
Mon, 29 Sep 2003 11:06:45 +0000 (11:06 +0000)
config_files/common.sh [new file with mode: 0755]

diff --git a/config_files/common.sh b/config_files/common.sh
new file mode 100755 (executable)
index 0000000..23b1884
--- /dev/null
@@ -0,0 +1,198 @@
+#!/bin/sh
+# 
+# This script installs a subset of products necessary for SALOME application
+#
+# Usage: install <target-directory> [all]
+#        install <target-directory> <product> ... <product>
+#
+# Type 'install --help' to get more information
+#
+# Important note: 
+#   <target-directory> must be an absolute path
+#
+# The script is the part of the SALOME PRO installation procedure.
+#
+# Copyright : 2003 CEA/DEN, EDF R&D
+####################################################################################
+
+export DELIM="------"
+export SHRC="salome.sh"
+export CSHRC="salome.csh"
+export DEBUG=1
+
+#this function takes several parameters
+#first parameter contains descriptor of output file
+#next parameters is command for execution
+#in case of bad result of execution ask user about furher steps
+#(user can cancel installation procedure)
+check_job()
+{
+  out=$1
+  shift
+  echo -e "`pwd` -> $* >> $out" 
+  if [ $DEBUG == 0 ] ; then
+    $* | tee $out
+  else
+    if [ $out == "1" ] ; then
+      $*
+    else
+      $* >> $out 2>&1
+    fi 
+  fi
+  if [ "$?" -ne "0" ] ; then
+    if [ $out != "1" ] ; then
+      cat $out
+    fi
+    echo -n " " >&2
+    echo -e "NOT DONE !!! => $*"
+    echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
+    read rep;
+    rep=`echo $rep  | tr "[A-Z]" "[a-z]"`
+    if test -z $rep || [ $rep = "y" ] ; then
+      return 1
+    fi
+    exit 1
+  fi
+  return 0
+}
+
+#invoke check_job function
+#all output will be put into terminal
+check_jb()
+{
+  check_job 1 $*
+  return
+}
+
+# make directory
+makedir()
+{
+  rm -rf "$1" > /dev/null
+  mkdir -p "$1"
+}
+
+#create environment for sh and csh
+make_env()
+{
+install_root=$1;  shift
+install_work=$1; 
+for i in $SHRC $CSHRC ; do
+    if [ -e ${install_work}/$i ]; then
+       rm ${install_work}/$i
+    fi
+    touch ${install_work}/$i
+done
+
+if [ $# -eq 3 ] ; then
+    product_name=$3;
+    product_env=${install_work}/env_${product_name}.sh
+    (test -e ${product_env} && rm ${product_env} )
+fi
+
+cat >> ${install_work}/$SHRC <<EOF
+export INSTALL_ROOT=${install_root}
+EOF
+product_sequence="$2"
+#for i in `ls -a ${install_work} | grep -E "..*" | grep -v ".salome.*"` ; do
+for i in $product_sequence ; do
+    cat ${install_work}/env_${i}.sh >> ${install_work}/$SHRC 2>/dev/null
+done 
+
+sed -e 's%^export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' -e 's%^#csh-specific  %%g' ${INSTALL_WORK}/$SHRC > ${INSTALL_WORK}/_$CSHRC
+pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH"
+for i in $pre_vars ; do
+cat >> ${install_work}/$CSHRC <<EOF
+if (! (\$?${i}) ) then
+  setenv $i
+endif
+EOF
+done
+cat ${INSTALL_WORK}/_$CSHRC >> ${INSTALL_WORK}/$CSHRC
+rm -f ${INSTALL_WORK}/_$CSHRC
+
+if [ $# -eq 4 ] ; then
+    product_dir=$4
+    cp -f ${install_work}/$SHRC ${install_work}/$CSHRC ${product_dir}/.
+fi
+cp -f ${install_work}/$CSHRC ${install_root}/env_products.csh
+cp -f ${install_work}/$SHRC ${install_root}/env_products.sh
+}
+
+#try use already existing product
+try_existing()
+{
+product_dir=$1;  install_root=$2;  install_work=$3;  product_sequence="$4";  product_type=$5
+env_file=${product_dir}/env_${product_type}.sh
+if [ -f ${env_file} ] ; then
+    cp -f ${env_file} ${install_work}
+    make_env ${install_root} ${install_work} "${product_sequence}"
+    source ${install_work}/$SHRC
+    check_version
+    if [ $? -eq 0 ] ; then
+       if [ -d ${product_dir} ] && [ -w ${product_dir} ] ; then
+           #makedir ${product_dir}
+           print_env
+           return 0    
+       fi
+    fi
+fi
+return 1;
+}
+
+#check existance of lib passed as first parameter
+#return 0 if lib exists
+#if you pass second parameter search will be done in it 
+#otherwise search will be done in $LD_LIBRARY_PATH
+#you should use : as dilimeter if you are going to pass second parameter
+check_lib_version(){
+if [ -n "$2" ]; then
+   whereIs=$2
+else
+   whereIs=$LD_LIBRARY_PATH
+fi
+for L in `echo ${whereIs} | sed -e"s%:% %g"` ;  do
+    ret=`find $L -name $1 2>/dev/null`
+    if [ -n "$ret" ] ; then
+       #echo "The $1 exists on yours system in a $L folder"
+       return 0
+    fi
+done
+return 1
+}
+
+find_in_path(){
+file=$1;  shift; 
+path=$*
+for i in `echo ${path} | sed -e"s%:% %g"` ; do 
+    ret=`find $i -name $file 2>/dev/null`
+    if [ -n "$ret" ] ; then
+       ret=`echo $ret | sed -e"s%/\$file$%%g"`
+       echo $ret
+       return 0
+    fi
+done
+return 1
+}
+
+sort_path(){
+arg1=$1;  val1=$2;  arg2=$3;  val2=$4
+tmp="^$val1$|^$val1:|:$val1$|:$val1:"
+#echo $val2 | grep -E "$tmp" >/dev/null 2>&1
+#if [ $? -eq 0 ] ; then 
+#    echo "$arg2"
+#    return
+#fi
+to_tail=1
+exclude_list="usr lib bin sbin etc"
+for i in ${exclude_list} ; do
+    tmp="^/$i/|^/$i\$"
+    echo ${val1} | grep -E "$tmp" >/dev/null 2>&1
+    if [ $? == 0 ] ; then to_tail=0; break; fi
+done
+if [ $to_tail -eq 0 ] ; then
+    echo $arg2:$arg1
+else
+    echo $arg1:$arg2
+fi
+return $to_tail
+}
\ No newline at end of file