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 (':')
###########################################################################
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 (':')
###########################################################################
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}