summaryrefslogtreecommitdiff
path: root/src/mongo/installer
diff options
context:
space:
mode:
authorMathew Robinson <chasinglogic@gmail.com>2017-10-27 15:17:35 -0400
committerMathew Robinson <chasinglogic@gmail.com>2017-11-06 17:09:14 -0500
commit62bd8ce2a8261c9393285e7c03e50386c73168a7 (patch)
tree47ee77b1bcd210f248222cf2ae1d34c871889344 /src/mongo/installer
parentc97dd9bc1f8652efcc41706b9b40a0829aed587a (diff)
downloadmongo-62bd8ce2a8261c9393285e7c03e50386c73168a7.tar.gz
SERVER-31781 Rename variable to not conflict with module name
Diffstat (limited to 'src/mongo/installer')
-rwxr-xr-xsrc/mongo/installer/compass/install_compass.in60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/mongo/installer/compass/install_compass.in b/src/mongo/installer/compass/install_compass.in
index 1fa49a2b442..a7b14089c4b 100755
--- a/src/mongo/installer/compass/install_compass.in
+++ b/src/mongo/installer/compass/install_compass.in
@@ -46,9 +46,16 @@ def download_progress(count, block_size, total_size):
sys.stdout.flush()
-def download_pkg(link):
+def download_pkg(link, pkg_format=''):
"""Download the package from link, logging progress. Returns the filename."""
- res = urllib.urlretrieve(link, reporthook=download_progress)
+ suf = ''
+ if pkg_format == 'apt':
+ suf = '.deb'
+ elif pkg_format == 'yum' or pkg_format == 'dnf':
+ suf = '.rpm'
+
+ tmpf = tempfile.mkstemp(suffix=suf)
+ res = urllib.urlretrieve(link, filename=tmpf[1], reporthook=download_progress)
# Download progress doesn't end with a newline so add it here.
print ''
return res[0]
@@ -62,7 +69,7 @@ def install_mac(dmg):
apps = [f for f in os.listdir(tmp) if f.endswith('.app')]
for app in apps:
if path.isdir('/Applications/' + app):
- print 'Old version appound removing...'
+ print 'Old version found removing...'
shutil.rmtree('/Applications/' + app)
print 'Copying %s to /Applications' % app
shutil.copytree(path.join(tmp, app), '/Applications/' + app)
@@ -77,9 +84,12 @@ def install_mac(dmg):
def install_linux(pkg_format, pkg_file):
"""Use the package manager indicated by pkg_format to install pkg_file."""
if pkg_format == 'yum':
- install = ['yum', 'install', '--assumeyes', pkg_file]
+ install = ['yum', 'localinstall', '--assumeyes', pkg_file]
elif pkg_format == 'apt':
- install = ['apt-get', 'install', '--yes', pkg_file]
+ # dpkg returns an error code when it fails to install dependencies
+ # so just run it and let apt-get tell us if something went wrong
+ subprocess.call(['dpkg', '--install', pkg_file])
+ install = ['apt-get', 'install', '-f', '--yes']
elif pkg_format == 'dnf':
install = ['dnf', 'install', '--assumeyes', pkg_file]
else:
@@ -98,7 +108,7 @@ def is_supported_distro():
return True
if (distro_name == 'Red Hat Enterprise Linux Server' and
- (int(version_numer) >= 7)):
+ (float(version_number) >= 7.0)):
return True
return False
@@ -106,44 +116,44 @@ def is_supported_distro():
def download_and_install_compass():
"""Download and install compass for this platform."""
- platform = sys.platform
+ os_type = sys.platform
pkg_format = get_pkg_format()
# Sometimes sys.platform gives us 'linux2' and we only want 'linux'
- if platform.startswith('linux'):
- platform = 'linux'
+ if os_type.startswith('linux'):
+ os_type = 'linux'
if pkg_format == 'apt':
- platform += '_deb'
+ os_type += '_deb'
elif pkg_format == 'yum' or pkg_format == 'dnf':
- platform += '_rpm'
- elif platform == 'darwin':
- platform = 'osx'
+ os_type += '_rpm'
+ elif os_type == 'darwin':
+ os_type = 'osx'
- if platform.startswith('linux') and os.getuid() != 0:
+ if os_type.startswith('linux') and os.getuid() != 0:
print 'You must run this script as root.'
sys.exit(1)
- if platform.startswith('linux') and not is_supported_distro():
- print 'You are using an unsupported Linux distribution. Please visit:'
- ' https://compass.mongodb.com/community-supported-platforms to view'
- ' available community supported packages.'
+ if os_type.startswith('linux') and not is_supported_distro():
+ print 'You are using an unsupported Linux distribution.\n' \
+ 'Please visit: https://compass.mongodb.com/community-supported-os_types' \
+ ' to view available community supported packages.'
sys.exit(1)
if platform.machine() != 'x86_64':
- print 'Sorry, MongoDB Compass is only supported on 64 bit platforms.'
- ' If you believe you\'re seeing this message in error please open a'
+ print 'Sorry, MongoDB Compass is only supported on 64 bit platforms.' \
+ ' If you believe you\'re seeing this message in error please open a' \
' ticket on the SERVER project at https://jira.mongodb.org/'
- link = 'https://compass.mongodb.com/api/v2/download/latest/@compass_type@/stable/' + platform
- pkg = download_pkg(link)
+ link = 'https://compass.mongodb.com/api/v2/download/latest/@compass_type@/stable/' + os_type
+ pkg = download_pkg(link, pkg_format=pkg_format)
print 'Installing the package...'
- if platform == 'osx':
+ if os_type == 'osx':
install_mac(pkg)
- elif platform.startswith('linux'):
+ elif os_type.startswith('linux'):
install_linux(pkg_format, pkg)
else:
- print 'Unrecognized platform: %s' % platform
+ print 'Unrecognized os_type: %s' % os_type
print 'Cleaning up...'
os.remove(pkg)