Salome HOME
Modifications in according to improvement 15165.
[tools/install.git] / config_files / common.sh
index f1a8def2c4970cda02b735a796faf7fa962807e0..0a86f3aa77eb58c4e302b889a36b9fe765985684 100755 (executable)
@@ -84,8 +84,8 @@ for i in $SHRC $CSHRC ; do
     touch ${install_work}/$i
 done
 
-if [ $# -eq 3 ] ; then
-    product_name=$3;
+if [ $# -eq 4 ] ; then
+    product_name=$4;
     product_env=${install_work}/env_${product_name}.sh
     (test -e ${product_env} && rm ${product_env} )
 fi
@@ -136,9 +136,20 @@ fi
 
 # 1. first dump all environment files into the $SHRC file
 product_sequence="$2"
+install_products="$3"
 for i in $product_sequence ; do
     env_file=${install_work}/env_${i}.sh
-    ( test -e $env_file && cat $env_file >> ${install_work}/$SHRC 2>/dev/null )
+    _env_file=${install_work}/_env_${i}.sh
+    if [ -e $_env_file ] ; then
+       cat $_env_file >> ${install_work}/$SHRC 2>/dev/null
+    elif [ -e $env_file ] ; then
+       echo $install_products | grep -q "\b${i}\b"
+       if [ $? -eq 1 ] ; then
+           cat $env_file | sed 's/^/## /' >> ${install_work}/$SHRC 2>/dev/null
+       else
+           cat $env_file >> ${install_work}/$SHRC 2>/dev/null
+       fi
+    fi
 done
 
 # 2. writing global functions to _salome.sh file
@@ -339,25 +350,31 @@ cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_$CSHRC 2>/dev/null
 
 rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
 
-if [ $# -eq 4 ] ; then
-    product_dir=$4
+if [ $# -eq 5 ] ; then
+    product_dir=$5
     if [ -e ${product_dir} ] ; then
-       cp -f ${install_work}/_$SHRC  ${product_dir}/$SHRC
-       cp -f ${install_work}/_$CSHRC ${product_dir}/$CSHRC
+       test -e ${product_dir}/$SHRC && mv ${product_dir}/$SHRC ${product_dir}/${SHRC}_`date +%F_%T`
+       cp ${install_work}/_$SHRC  ${product_dir}/$SHRC
+       test -e ${product_dir}/$CSHRC && mv ${product_dir}/$CSHRC ${product_dir}/${CSHRC}_`date +%F_%T`
+       cp ${install_work}/_$CSHRC ${product_dir}/$CSHRC
     fi
 fi
 sed -e 's%setenv ENV_FOR_LAUNCH 1%setenv ENV_FOR_LAUNCH 0%' ${install_work}/_$CSHRC > ${install_root}/env_build.csh
 sed -e 's%export ENV_FOR_LAUNCH=1%export ENV_FOR_LAUNCH=0%' ${install_work}/_$SHRC  > ${install_root}/env_build.sh
 
+#test -e ${install_root}/env_products.csh && mv ${install_root}/env_products.csh ${install_root}/env_products.csh_`date +%F_%T`
 cp -f ${install_work}/_$CSHRC ${install_root}/env_products.csh
+#test -e ${install_root}/env_products.sh && mv ${install_root}/env_products.sh ${install_root}/env_products.sh_`date +%F_%T`
 cp -f ${install_work}/_$SHRC  ${install_root}/env_products.sh
 
 rm -f ${install_work}/_$SHRC ${install_work}/_$CSHRC
 ### !!! copying build.csh and build.sh scripts
 if [ -e ./build.csh ]; then
+    #test -e ${install_root}/build.csh && mv ${install_root}/build.csh ${install_root}/build.csh_`date +%F_%T`
     cp -f ./build.csh ${install_root}
 fi
 if [ -e ./build.sh ]; then
+    #test -e ${install_root}/build.sh && mv ${install_root}/build.sh ${install_root}/build.sh_`date +%F_%T`
     cp -f ./build.sh ${install_root}
 fi
 ### !!! copying release notes
@@ -376,25 +393,26 @@ done
 #try use already existing product
 try_existing()
 {
-product_dir=$1;  install_root=$2;  install_work=$3;  product_sequence="$4";  product_type=$5
+product_dir=$1;  install_root=$2;  install_work=$3;
+product_sequence="$4"; installed_products="$5";  product_type=$6
 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}"
+#    cp -f ${env_file} ${install_work}
+    cp -f ${env_file} ${install_work}/_env_${product_type}.sh
+    make_env ${install_root} ${install_work} "${product_sequence}" "${installed_products}"
     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
-    else
-       rm -f ${install_work}/env_${product_type}.sh
-       make_env ${install_root} ${install_work} "${product_sequence}"
+       return 0
     fi
 fi
-return 1;
+echo ${product_type} | grep -q '_src$'
+if [ $? -eq 1 ] ; then
+    print_env_bin
+else
+    print_env_src
+fi
+return 0
 }
 
 #check existance of lib passed as first parameter