From 62bd8ce2a8261c9393285e7c03e50386c73168a7 Mon Sep 17 00:00:00 2001 From: Mathew Robinson Date: Fri, 27 Oct 2017 15:17:35 -0400 Subject: SERVER-31781 Rename variable to not conflict with module name --- src/mongo/SConscript | 2 + src/mongo/installer/compass/install_compass.in | 60 +++++++++++++++----------- 2 files changed, 37 insertions(+), 25 deletions(-) (limited to 'src/mongo') diff --git a/src/mongo/SConscript b/src/mongo/SConscript index 8c87dd8d3bc..e47f75afd66 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -644,10 +644,12 @@ compass_installer = env.Substfile('#/src/mongo/installer/compass/' + compass_scr ('@compass_type@', compass_type) ]) distBinaries.append(compass_installer) + compass_script_installer = env.Install("$INSTALL_DIR/bin", compass_installer) if env.TargetOSIs('posix'): env.AddPostAction( compass_script_installer, 'chmod 755 $TARGET' ) + env.AddPostAction( compass_installer, 'chmod 755 $TARGET' ) # "dist" target is valid only when --use-new-tools is specified # Attempts to build release artifacts without tools must fail 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) -- cgit v1.2.1