]> SALOME platform Git repositories - tools/install.git/commitdiff
Salome HOME
improving common.sh functions performance
authorvsr <vsr@opencascade.com>
Tue, 31 May 2005 13:55:36 +0000 (13:55 +0000)
committervsr <vsr@opencascade.com>
Tue, 31 May 2005 13:55:36 +0000 (13:55 +0000)
config_files/common.sh

index 7410799c69313ad6974ff44907332ada4fbef1c0..9a0dce607937c9fc3c45e0a3e45b422be33a9628 100755 (executable)
@@ -88,10 +88,36 @@ if [ $# -eq 3 ] ; then
     product_env=${install_work}/env_${product_name}.sh
     (test -e ${product_env} && rm ${product_env} )
 fi
-### !!! writing salome.sh file !!! -> add global functions
+### !!! writing salome.sh file !!!  -> define INSTALL_ROOT
 cat >> ${install_work}/$SHRC <<EOF
+#${DELIM} Setting products installation directory ${DELIM}
 export INSTALL_ROOT=${install_root}
 
+EOF
+### !!! writing salome.csh file !!! -> set inital variables
+pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH"
+for i in $pre_vars ; do
+cat >> ${install_work}/$CSHRC <<EOF
+#${DELIM} setting initial ${i} ${DELIM}
+if (! (\$?${i}) ) then
+  setenv $i
+endif
+
+EOF
+done
+
+### !!! writing salome.(c)sh files !!! -> dump products environment files, changing 'export' by 'setenv(a|p)' where necessary
+### Note, that for performance reasons temporary environment files used during installation procedure itself
+### are created without using setenv(a|p) aliases.
+
+# 1. first dump all environment files into the $SHRC file
+product_sequence="$2"
+for i in $product_sequence ; do
+    cat ${install_work}/env_${i}.sh >> ${install_work}/$SHRC 2>/dev/null
+done
+
+# 2. writing global functions to _salome.sh file
+cat >> ${install_work}/_$SHRC <<EOF
 ##########################################################################
 # Functions exporta and exportp are used to append/prepend correspondingly 
 # one directory or a set of directories separated by semicolon symbol (':')
@@ -158,10 +184,9 @@ export \$1=\$out_var
 ###########################################################################
 
 EOF
-### !!! writing salome.csh file !!! -> add global aliases
-cat >> ${install_work}/$CSHRC <<EOF
-setenv INSTALL_ROOT ${install_root}
 
+# 3. writing global functions to _salome.csh file
+cat >> ${install_work}/_$CSHRC <<EOF
 ###########################################################################
 # Aliases setenva and setenvp are used to append/prepend correspondingly 
 # one directory or a set of directories separated by semicolon symbol (':')
@@ -226,41 +251,38 @@ alias setenvp 'set a=\!:1 ; set b=\!:2 ;  \\
 ###########################################################################
 
 EOF
-### !!! writing salome.csh file !!! -> set inital variables
-pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH"
-for i in $pre_vars ; do
-cat >> ${install_work}/$CSHRC <<EOF
-#$DELIM $i : initial settings $DELIM
-if (! (\$?${i}) ) then
-  setenv $i
-endif
-EOF
-done
-### !!! writing salome.(c)sh files !!! -> dump products environment files, changing 'export' by 'setenv(a|p)' where necessary
-product_sequence="$2"
-for i in $product_sequence ; do
-    sed -e 's%^export\([[:blank:]]*\)PATH=\$[{]\?PATH[}]\?:\(.*\)%exporta\1PATH \2%g' -e 's%^export\([[:blank:]]*\)PATH=\(.*\):\$[{]\?PATH[}]\?%exportp\1PATH \2%g' ${install_work}/env_${i}.sh > ${INSTALL_WORK}/_tmp1 2>/dev/null
-    sed -e 's%^export\([[:blank:]]*\)LD_LIBRARY_PATH=\$[{]\?LD_LIBRARY_PATH[}]\?:\(.*\)%exporta\1LD_LIBRARY_PATH \2%g' -e 's%^export\([[:blank:]]*\)LD_LIBRARY_PATH=\(.*\):\$[{]\?LD_LIBRARY_PATH[}]\?%exportp\1LD_LIBRARY_PATH \2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
-    sed -e 's%^export\([[:blank:]]*\)PYTHONPATH=\$[{]\?PYTHONPATH[}]\?:\(.*\)%exporta\1PYTHONPATH \2%g' -e 's%^export\([[:blank:]]*\)PYTHONPATH=\(.*\):\$[{]\?PYTHONPATH[}]\?%exportp\1PYTHONPATH \2%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
-    sed -e 's%^export\([[:blank:]]*\)LD_RUN_PATH=\$[{]\?LD_RUN_PATH[}]\?:\(.*\)%exporta\1LD_RUN_PATH \2%g' -e 's%^export\([[:blank:]]*\)LD_RUN_PATH=\(.*\):\$[{]\?LD_RUN_PATH[}]\?%exportp\1LD_RUN_PATH \2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
-    cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/$SHRC 2>/dev/null
-    
-    sed -e 's%^export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
-    sed -e 's%^exporta \([[:alnum:]_[:blank:]]*\)%setenva \1%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
-    sed -e 's%^exportp \([[:alnum:]_[:blank:]]*\)%setenvp \1%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
-    cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/$CSHRC 2>/dev/null
+cat ${install_work}/$CSHRC >> ${install_work}/_$CSHRC
+
+# 4. put the contents of salome.sh to _salome.sh replacing export by export(a|p) aliases where necessary
+sed -e 's%^export\([[:blank:]]*\)PATH=\$[{]\?PATH[}]\?:\(.*\)%exporta\1PATH \2%g' -e 's%^export\([[:blank:]]*\)PATH=\(.*\):\$[{]\?PATH[}]\?%exportp\1PATH \2%g' ${install_work}/$SHRC > ${INSTALL_WORK}/_tmp1 2>/dev/null
+sed -e 's%^export\([[:blank:]]*\)LD_LIBRARY_PATH=\$[{]\?LD_LIBRARY_PATH[}]\?:\(.*\)%exporta\1LD_LIBRARY_PATH \2%g' -e 's%^export\([[:blank:]]*\)LD_LIBRARY_PATH=\(.*\):\$[{]\?LD_LIBRARY_PATH[}]\?%exportp\1LD_LIBRARY_PATH \2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
+sed -e 's%^export\([[:blank:]]*\)PYTHONPATH=\$[{]\?PYTHONPATH[}]\?:\(.*\)%exporta\1PYTHONPATH \2%g' -e 's%^export\([[:blank:]]*\)PYTHONPATH=\(.*\):\$[{]\?PYTHONPATH[}]\?%exportp\1PYTHONPATH \2%g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+sed -e 's%^export\([[:blank:]]*\)LD_RUN_PATH=\$[{]\?LD_RUN_PATH[}]\?:\(.*\)%exporta\1LD_RUN_PATH \2%g' -e 's%^export\([[:blank:]]*\)LD_RUN_PATH=\(.*\):\$[{]\?LD_RUN_PATH[}]\?%exportp\1LD_RUN_PATH \2%g' ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2
+cat ${INSTALL_WORK}/_tmp2 >> ${install_work}/_$SHRC
+
+# 5. Create a salome.csh file from salome.sh by replacing export by setenv, etc.
+sed -e 's%^export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${install_work}/$SHRC > ${INSTALL_WORK}/_tmp1 2>/dev/null
+cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/$CSHRC
+
+# 6. Create a _salome.csh file from _salome.sh by replacing export by setenv, exporta by setenva, etc.
+sed -e 's%^export \([[:alnum:]_[:blank:]]*\)\=%setenv \1 %g' ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+sed -e 's%^exporta \([[:alnum:]_[:blank:]]*\)%setenva \1%g'  ${INSTALL_WORK}/_tmp1 > ${INSTALL_WORK}/_tmp2 2>/dev/null
+sed -e 's%^exportp \([[:alnum:]_[:blank:]]*\)%setenvp \1%g'  ${INSTALL_WORK}/_tmp2 > ${INSTALL_WORK}/_tmp1 2>/dev/null
+cat ${INSTALL_WORK}/_tmp1 >> ${install_work}/_$CSHRC 2>/dev/null
 
-    rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
-done 
+rm -f ${INSTALL_WORK}/_tmp1 ${INSTALL_WORK}/_tmp2
 
 if [ $# -eq 4 ] ; then
     product_dir=$4
     if [ -e ${product_dir} ] ; then
-       cp -f ${install_work}/$SHRC ${install_work}/$CSHRC ${product_dir}/.
+       cp -f ${install_work}/_$SHRC  ${product_dir}/$SHRC
+       cp -f ${install_work}/_$CSHRC ${product_dir}/$CSHRC
     fi
 fi
-cp -f ${install_work}/$CSHRC ${install_root}/env_products.csh
-cp -f ${install_work}/$SHRC ${install_root}/env_products.sh
+cp -f ${install_work}/_$CSHRC ${install_root}/env_products.csh
+cp -f ${install_work}/_$SHRC  ${install_root}/env_products.sh
+rm -f ${install_work}/_$SHRC
+rm -f ${install_work}/_$CSHRC
 ### !!! copying build.csh script
 if [ -e ./build.csh ]; then
     cp -f ./build.csh ${install_root}