spec/shared/lib/mrss/server_version_registry.rb in mongoid-8.1.2 vs spec/shared/lib/mrss/server_version_registry.rb in mongoid-8.1.3
- old
+ new
@@ -22,10 +22,25 @@
@desired_version, @arch = desired_version, arch
end
attr_reader :desired_version, :arch
+ def target_arch
+ # can't use RbConfig::CONFIG["arch"] because JRuby doesn't
+ # return anything meaningful there.
+ #
+ # also, need to use `uname -a` instead of (e.g.) `uname -p`
+ # because debian (at least) does not return anything meaningful
+ # for `uname -p`.
+ uname = `uname -a`.strip
+ @target_arch ||= case uname
+ when /aarch/ then "aarch64"
+ when /x86/ then "x86_64"
+ else raise "unsupported architecture #{uname.inspect}"
+ end
+ end
+
def download_url
@download_url ||= begin
version, version_ok = detect_version(current_catalog)
if version.nil?
version, full_version_ok = detect_version(full_catalog)
@@ -38,37 +53,15 @@
raise UnknownVersion, "No version #{desired_version}"
end
end
dl = version['downloads'].detect do |dl|
dl['archive']['url'].index("enterprise-#{arch}") &&
- dl['arch'] == 'x86_64'
+ dl['arch'] == target_arch
end
unless dl
raise MissingDownloadUrl, "No download for #{arch} for #{version['version']}"
end
url = dl['archive']['url']
- end
- rescue MissingDownloadUrl
- if %w(2.6 3.0).include?(desired_version) && arch == 'ubuntu1604'
- # 2.6 and 3.0 are only available for ubuntu1204 and ubuntu1404.
- # Those ubuntus have ancient Pythons that don't work due to not
- # implementing recent TLS protocols.
- # Because of this we test on ubuntu1604 which has a newer Python.
- # But we still need to retrieve ubuntu1404-targeting builds.
- url = self.class.new('3.2', arch).download_url
- unless url.include?('3.2.')
- raise 'URL not in expected format'
- end
- url = case desired_version
- when '2.6'
- url.sub(/\b3\.2\.\d+/, '2.6.12')
- when '3.0'
- url.sub(/\b3\.2\.\d+/, '3.0.15')
- else
- raise NotImplementedError
- end.sub('ubuntu1604', 'ubuntu1404')
- else
- raise
end
end
private