summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/package_test/recipes/install_mongodb.rb13
-rw-r--r--buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb14
-rw-r--r--src/mongo/SConscript2
-rwxr-xr-xsrc/mongo/installer/compass/install_compass.in60
4 files changed, 64 insertions, 25 deletions
diff --git a/buildscripts/package_test/recipes/install_mongodb.rb b/buildscripts/package_test/recipes/install_mongodb.rb
index dcf7499289e..d8ea9041b70 100644
--- a/buildscripts/package_test/recipes/install_mongodb.rb
+++ b/buildscripts/package_test/recipes/install_mongodb.rb
@@ -42,6 +42,13 @@ if platform_family? 'debian'
returns [0, 1]
end
+ # install the tools so we can test install_compass
+ execute 'install mongo tools' do
+ command 'dpkg -i `find . -name "*tools*.deb"`'
+ cwd homedir
+ returns [0, 1]
+ end
+
# yum and zypper fetch dependencies automatically, but dpkg does not.
# Installing the dependencies explicitly is fragile, so we reply on apt-get
# to install dependencies after the fact.
@@ -61,6 +68,12 @@ if platform_family? 'rhel'
cwd homedir
end
+ # install the tools so we can test install_compass
+ execute 'install mongo tools' do
+ command 'yum install -y `find . -name "*tools*.rpm"`'
+ cwd homedir
+ end
+
execute 'install mongo shell' do
command 'yum install -y `find . -name "*shell*.rpm"`'
cwd homedir
diff --git a/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb b/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb
index c8fc8e270e1..8d78d714bcb 100644
--- a/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb
+++ b/buildscripts/package_test/test/recipes/service/install_mongodb_spec.rb
@@ -35,6 +35,20 @@ describe service('mongod') do
it { should be_running }
end
+
+if os[:arch] == 'x86_64' and
+ (os[:name] == 'ubuntu' and
+ (os[:release][0...5] == '14.04' or os[:release][0...5] == '16.04')) or
+ (os[:family] == 'redhat' and os[:release][0] == '7')
+ describe command("install_compass") do
+ its('exit_status') { should eq 0 }
+ end
+else
+ describe command("install_compass") do
+ its('exit_status') { should_not eq 0 }
+ end
+end
+
# wait to make sure mongod is ready
describe command("/inspec_wait.sh") do
its('exit_status') { should eq 0 }
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)