Added "--shell=<SHELL>" option to coriolisEnv.py.
This commit is contained in:
parent
36ce36f582
commit
b1befe5626
|
@ -100,27 +100,34 @@ def guessOs ():
|
||||||
return ( osType, useDevtoolset )
|
return ( osType, useDevtoolset )
|
||||||
|
|
||||||
|
|
||||||
def guessShell ():
|
def guessShell ( forcedShell ):
|
||||||
# This environement variable cannot be trusted as it is set once when
|
# This environement variable cannot be trusted as it is set once when
|
||||||
# the user logs in. If aftewards it changes it that variable is *not*
|
# the user logs in. If aftewards it changes it that variable is *not*
|
||||||
# affected :-(.
|
# affected :-(.
|
||||||
#if os.environ.has_key('SHELL'): return os.environ['SHELL']
|
#if 'SHELL' in os.environ: return os.environ['SHELL']
|
||||||
psCommand = subprocess.Popen ( ['ps', '-p', str(os.getppid()) ], stdout=subprocess.PIPE )
|
|
||||||
shell = psCommand.stdout.readlines()[1].decode('ascii')[:-1].split()[3].lstrip('-')
|
|
||||||
whichCommand = subprocess.Popen ( ['which', shell ], stdout=subprocess.PIPE )
|
|
||||||
shellPath = whichCommand.stdout.readlines()[0][:-1]
|
|
||||||
isBourneShell = True
|
isBourneShell = True
|
||||||
cshBins = [ '/usr/bin/tcsh'
|
cshBins = [ u'/usr/bin/tcsh'
|
||||||
, '/bin/tcsh'
|
, u'/bin/tcsh'
|
||||||
, '/usr/pkg/bin/tcsh'
|
, u'/usr/pkg/bin/tcsh'
|
||||||
, '/usr/local/bin/tcsh'
|
, u'/usr/local/bin/tcsh'
|
||||||
, '/usr/bin/csh'
|
, u'/usr/bin/csh'
|
||||||
, '/bin/csh'
|
, u'/bin/csh'
|
||||||
, '/usr/pkg/bin/csh'
|
, u'/usr/pkg/bin/csh'
|
||||||
, '/usr/local/bin/csh'
|
, u'/usr/local/bin/csh'
|
||||||
]
|
]
|
||||||
if shellPath in cshBins: isBourneShell = False
|
if shellName is None:
|
||||||
#print( 'GUESSED SHELL: "{}"'.format( shellPath ))
|
psCommand = subprocess.Popen ( ['ps', '-p', str(os.getppid()) ], stdout=subprocess.PIPE )
|
||||||
|
shell = psCommand.stdout.readlines()[1].decode('utf8')[:-1].split()[3].lstrip('-')
|
||||||
|
whichCommand = subprocess.Popen ( ['which', shell ], stdout=subprocess.PIPE )
|
||||||
|
shellPath = whichCommand.stdout.readlines()[0][:-1].decode('utf8')
|
||||||
|
#print( 'GUESSED shellPath={}'.format(shellPath) )
|
||||||
|
else:
|
||||||
|
shellPath = forcedShell
|
||||||
|
#print( 'FORCED shellPath={}'.format(shellPath) )
|
||||||
|
if shellPath in cshBins:
|
||||||
|
#print( 'Matched C-Shell' )
|
||||||
|
isBourneShell = False
|
||||||
|
#print( 'isBourneShell={}\n'.format(isBourneShell) )
|
||||||
return shellPath, isBourneShell
|
return shellPath, isBourneShell
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,7 +137,7 @@ if __name__ == "__main__":
|
||||||
buildType = "Release"
|
buildType = "Release"
|
||||||
linkType = "Shared"
|
linkType = "Shared"
|
||||||
rootDir = None
|
rootDir = None
|
||||||
shellBin, isBourneShell = guessShell()
|
shellName = None
|
||||||
|
|
||||||
parser = optparse.OptionParser()
|
parser = optparse.OptionParser()
|
||||||
# Build relateds.
|
# Build relateds.
|
||||||
|
@ -144,6 +151,7 @@ if __name__ == "__main__":
|
||||||
parser.add_option ( "--no-python" , action="store_true" , dest="nopython" )
|
parser.add_option ( "--no-python" , action="store_true" , dest="nopython" )
|
||||||
parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" )
|
parser.add_option ( "--root" , action="store" , type="string", dest="rootDir" )
|
||||||
parser.add_option ( "--remove" , action="store_true" , dest="remove" )
|
parser.add_option ( "--remove" , action="store_true" , dest="remove" )
|
||||||
|
parser.add_option ( "--shell" , action="store" , type="string", dest="shell" )
|
||||||
( options, args ) = parser.parse_args()
|
( options, args ) = parser.parse_args()
|
||||||
|
|
||||||
if options.release: buildType = "Release"
|
if options.release: buildType = "Release"
|
||||||
|
@ -152,6 +160,8 @@ if __name__ == "__main__":
|
||||||
if options.static: linkType = "Static"
|
if options.static: linkType = "Static"
|
||||||
if options.shared: linkType = "Shared"
|
if options.shared: linkType = "Shared"
|
||||||
if options.rootDir: rootDir = options.rootDir
|
if options.rootDir: rootDir = options.rootDir
|
||||||
|
if options.shell: shellName = options.shell
|
||||||
|
shellBin, isBourneShell = guessShell( shellName )
|
||||||
|
|
||||||
scriptPath = os.path.abspath( os.path.dirname( sys.argv[0] ))
|
scriptPath = os.path.abspath( os.path.dirname( sys.argv[0] ))
|
||||||
if 'Debug.' in scriptPath: buildType = 'Debug'
|
if 'Debug.' in scriptPath: buildType = 'Debug'
|
||||||
|
@ -186,6 +196,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
|
|
||||||
shellScriptSh = \
|
shellScriptSh = \
|
||||||
|
'echo "Issuing commands for Bourne shell like interpreters";' \
|
||||||
'echo "%(MESSAGE)s";' \
|
'echo "%(MESSAGE)s";' \
|
||||||
'echo "Switching to Coriolis 2.x (%(buildDir)s)";' \
|
'echo "Switching to Coriolis 2.x (%(buildDir)s)";' \
|
||||||
'PATH="%(PATH)s";' \
|
'PATH="%(PATH)s";' \
|
||||||
|
@ -196,6 +207,7 @@ if __name__ == "__main__":
|
||||||
# 'STRATUS_MAPPING_NAME="%(SYSCONF_DIR)s/stratus2sxlib.xml";' \
|
# 'STRATUS_MAPPING_NAME="%(SYSCONF_DIR)s/stratus2sxlib.xml";' \
|
||||||
|
|
||||||
shellScriptCsh = \
|
shellScriptCsh = \
|
||||||
|
'echo "Issuing commands for C-shell like interpreters";' \
|
||||||
'echo "%(MESSAGE)s";' \
|
'echo "%(MESSAGE)s";' \
|
||||||
'echo "Switching to Coriolis 2.x (%(buildDir)s)";' \
|
'echo "Switching to Coriolis 2.x (%(buildDir)s)";' \
|
||||||
'setenv PATH "%(PATH)s";' \
|
'setenv PATH "%(PATH)s";' \
|
||||||
|
|
Loading…
Reference in New Issue