0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

SERVER-32211 Set the python interpreter based on target platform

This commit is contained in:
Mathew Robinson 2017-12-07 17:07:37 -05:00
parent 64e3571e79
commit ecb76e06cd
3 changed files with 32 additions and 18 deletions

2
README
View File

@ -19,7 +19,7 @@ UTILITIES
bsondump - Convert BSON files into human-readable formats.
mongoreplay - Traffic capture and replay tool.
mongotop - Track time spent reading and writing data.
install_compass - Installs MongoDB Compass for your platform
install_compass - Installs MongoDB Compass for your platform.
BUILDING

View File

@ -637,9 +637,14 @@ if env.TargetOSIs('windows'):
# On windows the .in needs to be explicitly added to the file.
compass_script = "Install-Compass.ps1.in"
compass_python_interpreter = '/usr/bin/env python2'
if env.TargetOSIs('darwin'):
compass_python_interpreter = '/usr/bin/env python'
compass_installer = env.Substfile('#/src/mongo/installer/compass/' + compass_script,
SUBST_DICT=[
('@compass_type@', compass_type)
('@compass_type@', compass_type),
('@python_interpreter@', compass_python_interpreter),
])
distBinaries.append(compass_installer)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!@python_interpreter@
# This script downloads the latest version of Compass and installs it on
# non-windows platforms.
@ -64,21 +64,30 @@ def download_pkg(link, pkg_format=''):
def install_mac(dmg):
"""Use CLI tools to mount the dmg and extract all .apps into Applications."""
tmp = tempfile.mkdtemp()
subprocess.check_call(['hdiutil', 'attach', '-mountpoint', tmp, dmg])
try:
apps = [f for f in os.listdir(tmp) if f.endswith('.app')]
for app in apps:
if path.isdir('/Applications/' + app):
print 'Old version found removing...'
shutil.rmtree('/Applications/' + app)
print 'Copying %s to /Applications' % app
shutil.copytree(path.join(tmp, app), '/Applications/' + app)
# We don't really care about what errors come up here. Just log the failure
# and use the finally to make sure we always unmount the dmg.
except Exception as exception:
print exception
finally:
subprocess.check_call(['hdiutil', 'detach', tmp])
with open(os.devnull, 'w') as fnull:
subprocess.check_call(['hdiutil', 'attach', '-nobrowse', '-noautoopen',
'-mountpoint', tmp, dmg], stdout=fnull, stderr=fnull)
try:
apps = [f for f in os.listdir(tmp) if f.endswith('.app')]
for app in apps:
if path.isdir('/Applications/' + app):
print 'Old version found removing...'
shutil.rmtree('/Applications/' + app)
print 'Copying %s to /Applications' % app
shutil.copytree(path.join(tmp, app), '/Applications/' + app)
# We don't really care about what errors come up here. Just log the failure
# and use the finally to make sure we always unmount the dmg.
except Exception as exception:
print exception
finally:
subprocess.check_call(['hdiutil', 'detach', tmp], stdout=fnull, stderr=fnull)
if path.isdir('/Applications/MongoDB Compass.app'):
subprocess.check_call(['open', '/Applications/MongoDB Compass.app'])
return
if path.isdir('/Applications/MongoDB Compass Community.app'):
subprocess.check_call(['open', '/Applications/MongoDB Compass Community.app'])
return
def install_linux(pkg_format, pkg_file):