From 94ca985a2d6d377e2bcbac7c9ac30502d6d3b039 Mon Sep 17 00:00:00 2001 From: prascle Date: Tue, 28 Mar 2006 16:58:55 +0000 Subject: [PATCH] SALOME Application with symbolic links --- bin/appli_clean.sh | 4 ++ bin/appli_install.sh | 62 +++++++++++++++++ bin/virtual_salome.py | 153 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 bin/appli_clean.sh create mode 100644 bin/appli_install.sh create mode 100644 bin/virtual_salome.py diff --git a/bin/appli_clean.sh b/bin/appli_clean.sh new file mode 100644 index 000000000..d716cbdfa --- /dev/null +++ b/bin/appli_clean.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +#clean appli +rm -rf bin lib share doc envd setAppliPath.sh searchFreePort.sh runAppli runConsole runSession env.d diff --git a/bin/appli_install.sh b/bin/appli_install.sh new file mode 100644 index 000000000..4ae69a81b --- /dev/null +++ b/bin/appli_install.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +SALOME_ROOT=${HOME}/SALOME2 +INSTALL_ROOT=${SALOME_ROOT}/Install + +APPLI_ROOT=`pwd` + +# --- clean appli +rm -rf bin lib share doc envd setAppliPath.sh searchFreePort.sh runAppli runConsole runSession env.d + +# --- install appli + +mkdir -p env.d +ln -fs bin/salome/appliskel/envd . +ln -fs bin/salome/appliskel/setAppliPath.sh . +ln -fs bin/salome/appliskel/searchFreePort.sh . +ln -fs bin/salome/appliskel/runAppli . +ln -fs bin/salome/appliskel/runConsole . +ln -fs bin/salome/appliskel/runSession . + +# --- prerequisites + +if [ x${PREREQUISITE_SH} != x ]; then + cp ${PREREQUISITE_SH} env.d/envProducts.sh; +else + # --- unless PREREQUISITE_SH defines the prerequisite script, + # edit and uncomment the following line to set it, and comment the echo and exit lines + #ln -fs myPathForSalomePrerequisiteScriptToBeSourced env.d/envProducts.sh + echo "The file to source for SALOME prerequisite definition is not known:" + echo "--> Edit the corresponding line in " $0 ",Comment this message and the exit command," + exit 1; +fi + +# --- symbolic links creation, from modules_root_dir + +VERSION=BR_PR_V320b1 + +for module in KERNEL MED GUI GEOM SMESH VISU SUPERV LIGHT NETGENPLUGIN PYCALCULATOR PYTIX; +do + echo " ========= " ${module}; + python virtual_salome.py -v --prefix="." --module=$INSTALL_ROOT/${module}_${VERSION} + echo "export ${module}_ROOT_DIR=$APPLI_ROOT" >> env.d/configSalome.sh +done + +# --- HELLO module + +echo " ========= HELLO1"; +python virtual_salome.py -v --prefix="." --module=$INSTALL_ROOT/HELLO1_${VERSION} +echo "export HELLO_ROOT_DIR=$APPLI_ROOT" >> env.d/configSalome.sh + +# --- PYHELLO module + +echo " ========= PYHELLO1"; +python virtual_salome.py -v --prefix="." --module=$INSTALL_ROOT/PYHELLO1_${VERSION} +echo "export PYHELLO_ROOT_DIR=$APPLI_ROOT" >> env.d/configSalome.sh + +# --- GUI config + +echo "export SalomeAppConfig=$APPLI_ROOT:$APPLI_ROOT/share/salome/resources" >> env.d/configGUI.sh +echo "export SUITRoot=$APPLI_ROOT/share/salome" >> env.d/configGUI.sh + +# --- \ No newline at end of file diff --git a/bin/virtual_salome.py b/bin/virtual_salome.py new file mode 100644 index 000000000..5c92ae8f6 --- /dev/null +++ b/bin/virtual_salome.py @@ -0,0 +1,153 @@ +"""Create a virtual Salome installation + +Based on a script created by Ian Bicking. + +Typical use:: + + python virtual_salome.py -v --prefix="." --module=/local/chris/SALOME2/RELEASES/Install/KERNEL_V3_1_0b1 + +install module KERNEL in the current directory +""" + +import sys, os, optparse, shutil,glob,fnmatch +py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) + +def mkdir(path): + """Create a directory and all the intermediate directories if path does not exist""" + if not os.path.exists(path): + print 'Creating %s' % path + os.makedirs(path) + else: + if verbose: + print 'Directory %s already exists' % path + +def symlink(src, dest): + """Create a link if it does not exist""" + if not os.path.exists(dest): + if verbose: + print 'Creating symlink %s' % dest + os.symlink(src, dest) + else: + print 'Symlink %s already exists' % dest + +def rmtree(dir): + """Remove (recursive) a directory if it exists""" + if os.path.exists(dir): + print 'Deleting tree %s' % dir + shutil.rmtree(dir) + else: + if verbose: + print 'Do not need to delete %s; already gone' % dir + +def main(): + usage="""usage: %prog [options] +Typical use is: + python virtual_salome.py -v --prefix="." --module=/local/chris/SALOME2/RELEASES/Install/KERNEL_V3_1_0b1 +""" + parser = optparse.OptionParser(usage=usage) + + parser.add_option('-v', '--verbose', action='count', dest='verbose', + default=0, help="Increase verbosity") + + parser.add_option('--prefix', dest="prefix", default='.', + help="The base directory to install to (default .)") + + parser.add_option('--module', dest="module", + help="The module directory to install in (mandatory)") + + parser.add_option('--clear', dest='clear', action='store_true', + help="Clear out the install and start from scratch") + + options, args = parser.parse_args() + global verbose + + if not options.module: + print "Option module is mandatory" + return + + module_dir=options.module + if not os.path.exists(module_dir): + print "Module %s does not exist" % module_dir + return + + home_dir = os.path.expanduser(options.prefix) + + #module_dir="/local/chris/SALOME2/RELEASES/Install/KERNEL_V3_1_0b1" + module_bin_dir=os.path.join(module_dir,'bin','salome') + module_lib_dir=os.path.join(module_dir,'lib','salome') + module_lib_py_dir=os.path.join(module_dir,'lib',py_version,'site-packages','salome') + module_lib_py_shared_dir=os.path.join(module_dir,'lib',py_version,'site-packages','salome','shared_modules') + module_share_dir=os.path.join(module_dir,'share','salome','resources') + module_doc_gui_dir=os.path.join(module_dir,'doc','salome','gui') + module_doc_tui_dir=os.path.join(module_dir,'doc','salome','tui') + module_doc_dir=os.path.join(module_dir,'doc','salome') + + if not os.path.exists(module_lib_py_dir): + print "Python directory %s does not exist" % module_lib_py_dir + return + + bin_dir=os.path.join(home_dir,'bin','salome') + lib_dir=os.path.join(home_dir,'lib','salome') + lib_py_dir=os.path.join(home_dir,'lib',py_version,'site-packages','salome') + lib_py_shared_dir=os.path.join(home_dir,'lib',py_version,'site-packages','salome','shared_modules') + share_dir=os.path.join(home_dir,'share','salome','resources') + doc_gui_dir=os.path.join(home_dir,'doc','salome','gui') + doc_tui_dir=os.path.join(home_dir,'doc','salome','tui') + doc_dir=os.path.join(home_dir,'doc','salome') + + verbose = options.verbose + + if options.clear: + rmtree(bin_dir) + rmtree(lib_dir) + rmtree(share_dir) + rmtree(doc_dir) + + #directory bin/salome : create it and link content + mkdir(bin_dir) + for fn in os.listdir(module_bin_dir): +# if os.path.splitext(fn)[1] not in (".pyc",".pyo"): #Compiled python are excluded + symlink(os.path.join(module_bin_dir, fn), os.path.join(bin_dir, fn)) + + #directory lib/salome : create it and link content + mkdir(lib_dir) + for fn in os.listdir(module_lib_dir): + symlink(os.path.join(module_lib_dir, fn), os.path.join(lib_dir, fn)) + + #directory lib/py_version/site-packages/salome : create it and link content + mkdir(lib_py_shared_dir) + for fn in os.listdir(module_lib_py_dir): +# if os.path.splitext(fn)[1] not in (".pyc",".pyo"): #Compiled python are excluded + symlink(os.path.join(module_lib_py_dir, fn), os.path.join(lib_py_dir, fn)) + for fn in os.listdir(module_lib_py_shared_dir): +# if os.path.splitext(fn)[1] not in (".pyc",".pyo"): #Compiled python are excluded + symlink(os.path.join(module_lib_py_shared_dir, fn), os.path.join(lib_py_shared_dir, fn)) + + #directory share/salome/resources : create it and link content + mkdir(share_dir) + for fn in os.listdir(module_share_dir): + symlink(os.path.join(module_share_dir, fn), os.path.join(share_dir, fn)) + + #html files in doc/salome directory + if os.path.exists(module_doc_dir): + mkdir(doc_dir) + for fn in os.listdir(module_doc_dir): + if fn == 'gui':continue + if fn == 'tui':continue + symlink(os.path.join(module_doc_dir, fn), os.path.join(doc_dir, fn)) + + #directory doc/salome/gui : create it and link content + if os.path.exists(module_doc_gui_dir): + mkdir(doc_gui_dir) + for fn in os.listdir(module_doc_gui_dir): + symlink(os.path.join(module_doc_gui_dir, fn), os.path.join(doc_gui_dir, fn)) + + #directory doc/salome/tui : create it and link content + if os.path.exists(module_doc_tui_dir): + mkdir(doc_tui_dir) + for fn in os.listdir(module_doc_tui_dir): + symlink(os.path.join(module_doc_tui_dir, fn), os.path.join(doc_tui_dir, fn)) + +if __name__ == '__main__': + main() + -- 2.39.2