3 # This script installs a subset of products necessary for SALOME application
5 # Usage: install <target-directory> [all]
6 # install <target-directory> <product> ... <product>
8 # Type 'install --help' to get more information
11 # <target-directory> must be an absolute path
13 # The script is the part of the SALOME PRO installation procedure.
15 # Copyright : 2003 CEA/DEN, EDF R&D
16 ####################################################################################
19 export SHRC="salome.sh"
20 export CSHRC="salome.csh"
23 #this function takes several parameters
24 #first parameter contains descriptor of output file
25 #next parameters is command for execution
26 #in case of bad result of execution ask user about furher steps
27 #(user can cancel installation procedure)
32 echo -e "`pwd` -> $* >> $out"
33 if [ $DEBUG == 0 ] ; then
36 if [ $out == "1" ] ; then
42 if [ "$?" -ne "0" ] ; then
43 if [ $out != "1" ] ; then
47 echo -e "NOT DONE !!! => $*"
48 echo -n "Would you like to continue to install this product: (Y,N) [Y] : "
50 rep=`echo $rep | tr "[A-Z]" "[a-z]"`
51 if test -z $rep || [ $rep = "y" ] ; then
59 #invoke check_job function
60 #all output will be put into terminal
70 rm -rf "$1" > /dev/null
74 #create environment for sh and csh
77 install_root=$1; shift
79 for i in $SHRC $CSHRC ; do
80 if [ -e ${install_work}/$i ]; then
83 touch ${install_work}/$i
86 if [ $# -eq 3 ] ; then
88 product_env=${install_work}/env_${product_name}.sh
89 (test -e ${product_env} && rm ${product_env} )
92 cat >> ${install_work}/$SHRC <<EOF
93 export INSTALL_ROOT=${install_root}
96 #for i in `ls -a ${install_work} | grep -E "..*" | grep -v ".salome.*"` ; do
97 for i in $product_sequence ; do
98 cat ${install_work}/env_${i}.sh >> ${install_work}/$SHRC 2>/dev/null
101 sed -e 's%^export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' -e 's%^#csh-specific %%g' ${INSTALL_WORK}/$SHRC > ${INSTALL_WORK}/_$CSHRC
102 pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH"
103 for i in $pre_vars ; do
104 cat >> ${install_work}/$CSHRC <<EOF
105 if (! (\$?${i}) ) then
110 cat ${INSTALL_WORK}/_$CSHRC >> ${INSTALL_WORK}/$CSHRC
111 rm -f ${INSTALL_WORK}/_$CSHRC
113 if [ $# -eq 4 ] ; then
115 cp -f ${install_work}/$SHRC ${install_work}/$CSHRC ${product_dir}/.
117 cp -f ${install_work}/$CSHRC ${install_root}/env_products.csh
118 cp -f ${install_work}/$SHRC ${install_root}/env_products.sh
121 #try use already existing product
124 product_dir=$1; install_root=$2; install_work=$3; product_sequence="$4"; product_type=$5
125 env_file=${product_dir}/env_${product_type}.sh
126 if [ -f ${env_file} ] ; then
127 cp -f ${env_file} ${install_work}
128 make_env ${install_root} ${install_work} "${product_sequence}"
129 source ${install_work}/$SHRC
131 if [ $? -eq 0 ] ; then
132 if [ -d ${product_dir} ] && [ -w ${product_dir} ] ; then
133 #makedir ${product_dir}
142 #check existance of lib passed as first parameter
143 #return 0 if lib exists
144 #if you pass second parameter search will be done in it
145 #otherwise search will be done in $LD_LIBRARY_PATH
146 #you should use : as dilimeter if you are going to pass second parameter
151 whereIs=$LD_LIBRARY_PATH
153 for L in `echo ${whereIs} | sed -e"s%:% %g"` ; do
154 ret=`find $L -name $1 2>/dev/null`
155 if [ -n "$ret" ] ; then
156 #echo "The $1 exists on yours system in a $L folder"
166 for i in `echo ${path} | sed -e"s%:% %g"` ; do
167 ret=`find $i -name $file 2>/dev/null`
168 if [ -n "$ret" ] ; then
169 ret=`echo $ret | sed -e"s%/\$file$%%g"`
178 arg1=$1; val1=$2; arg2=$3; val2=$4
179 tmp="^$val1$|^$val1:|:$val1$|:$val1:"
180 #echo $val2 | grep -E "$tmp" >/dev/null 2>&1
181 #if [ $? -eq 0 ] ; then
186 exclude_list="usr lib bin sbin etc"
187 for i in ${exclude_list} ; do
189 echo ${val1} | grep -E "$tmp" >/dev/null 2>&1
190 if [ $? == 0 ] ; then to_tail=0; break; fi
192 if [ $to_tail -eq 0 ] ; then