From 19ed35784c386611a2d41e3d78b6c2d7e351183a Mon Sep 17 00:00:00 2001 From: Staf Verhaegen Date: Mon, 24 Feb 2020 13:33:52 +0100 Subject: [PATCH] Allow to remove the Coriolis environment. coriolisEnv.py now has a --remove option to allow to remove Coriolis settings from the shell environment. --- bootstrap/coriolisEnv.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/bootstrap/coriolisEnv.py b/bootstrap/coriolisEnv.py index 78a21ce8..38814d68 100755 --- a/bootstrap/coriolisEnv.py +++ b/bootstrap/coriolisEnv.py @@ -186,6 +186,7 @@ if __name__ == "__main__": parser.add_option ( "--shared" , action="store_true" , dest="shared" ) parser.add_option ( "--no-python" , action="store_true" , dest="nopython" ) parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" ) + parser.add_option ( "--remove" , action="store_true" , dest="remove" ) ( options, args ) = parser.parse_args () if options.release: buildType = "Release" @@ -206,6 +207,32 @@ if __name__ == "__main__": strippedLibraryPath = scrubPath( "LD_LIBRARY_PATH" ) strippedPythonPath = scrubPath( "PYTHONPATH" ) + if options.remove: + shellScript = 'echo "Removing Coriolis environment";' + if osType == "Darwin": + ldVar = 'DYLD_LIBRARY_PATH' + else: + ldVar = 'LD_LIBRARY_PATH' + + if isBourneShell: + shellScript += 'export PATH={};hash -r;'.format(strippedPath) + shellScript += 'BOOTSTRAP_TOP="";CORIOLIS_TOP="";export -n BOOTSTRAP_TOP CORIOLIS_TOP;' + if strippedLibraryPath: + shellScript += 'export {}={};'.format(ldVar, strippedLibraryPath) + else: + shellScript += '{0}=""; export -n {0};'.format(ldVar) + else: + shellScript += 'setenv PATH {};rehash;'.format(strippedPath) + shellScript += 'unsetenv BOOTSTRAP_TOP CORIOLIS_TOP;' + if strippedLibraryPath: + shellScript += 'setenv {} {};'.format(ldVar, strippedLibraryPath) + else: + shellScript += 'unsetenv {};'.format(ldVar) + + print(shellScript) + sys.exit(0) + + shellScriptSh = \ 'echo "%(MESSAGE)s";' \ 'echo "Switching to Coriolis 2.x (%(buildDir)s)";' \