From: vsr Date: Tue, 31 May 2005 13:55:36 +0000 (+0000) Subject: improving common.sh functions performance X-Git-Tag: V_2_2_4~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bb013ad2fef378549fe5926fb437c925d3a31798;p=tools%2Finstall.git improving common.sh functions performance --- diff --git a/config_files/common.sh b/config_files/common.sh index 7410799..9a0dce6 100755 --- a/config_files/common.sh +++ b/config_files/common.sh @@ -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 < set inital variables +pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH" +for i in $pre_vars ; do +cat >> ${install_work}/$CSHRC < 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 < add global aliases -cat >> ${install_work}/$CSHRC <> ${install_work}/_$CSHRC < set inital variables -pre_vars="PATH LD_LIBRARY_PATH LD_RUN_PATH PYTHONPATH TCLLIBPATH" -for i in $pre_vars ; do -cat >> ${install_work}/$CSHRC < 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}