lib/ruboto/util/setup.rb in ruboto-1.4.1 vs lib/ruboto/util/setup.rb in ruboto-1.5.0
- old
+ new
@@ -5,12 +5,12 @@
module Util
module Setup
include Ruboto::Util::Verify
REPOSITORY_BASE = 'http://dl-ssl.google.com/android/repository'
REPOSITORY_URL = "#{REPOSITORY_BASE}/repository-10.xml"
- SDK_DOWNLOAD_PAGE = 'http://developer.android.com/sdk/index.html?hl=sk'
ADDONS_URL = "#{REPOSITORY_BASE}/extras/intel/addon.xml"
+ SDK_DOWNLOAD_PAGE = 'https://developer.android.com/studio/index.html'
RUBOTO_GEM_ROOT = File.expand_path '../../../..', __FILE__
WINDOWS_ELEVATE_CMD = "#{RUBOTO_GEM_ROOT}/bin/elevate_32.exe -c -w"
#########################################
@@ -108,27 +108,31 @@
## Error
nil
end
end
- def get_tools_version(type='tool', repo_url = REPOSITORY_URL)
+ def get_tools_version(type='tool', repo_url = REPOSITORY_URL, host_os = nil)
require 'rexml/document'
require 'open-uri'
doc = REXML::Document.new(open(repo_url))
- doc.root.elements.to_a("sdk:#{type}/sdk:revision").map do |t|
- major = t.elements['sdk:major']
- minor = t.elements['sdk:minor']
- micro = t.elements['sdk:micro']
- prev = t.elements['sdk:preview']
+ doc.root.elements.to_a("sdk:#{type}").map do |t|
+ r = t.elements['sdk:revision']
+ major = r.elements['sdk:major']
+ minor = r.elements['sdk:minor']
+ micro = r.elements['sdk:micro']
+ prev = r.elements['sdk:preview']
next if prev
+ url = t.elements['sdk:archives/sdk:archive/sdk:url'].text
+ pkg_host_os = t.elements['sdk:archives/sdk:archive/sdk:host-os'].text
+ next if host_os && pkg_host_os != host_os
version = major.text
version += ".#{minor.text}" if minor
version += ".#{micro.text}" if micro
version += "_rc#{prev.text}" if prev
- version
- end.compact.sort_by { |v| Gem::Version.new(v.gsub('_', '.')) }.last
+ [version, url]
+ end.compact.sort_by { |v| Gem::Version.new(v[0].gsub('_', '.')) }.last
end
def get_android_sdk_version
require 'net/http'
require 'uri'
@@ -611,42 +615,36 @@
print 'Would you like to download and install them? (Y/n): '
a = STDIN.gets.chomp.upcase
end
if accept_all || a == 'Y' || a.empty?
android_cmd = windows? ? 'android.bat' : 'android'
- update_cmd = "#{android_cmd} --silent update sdk --no-ui --filter build-tools-#{get_tools_version('build-tool')},extra-intel-Hardware_Accelerated_Execution_Manager,platform-tool,tool"
+ update_cmd = "#{android_cmd} --silent update sdk --no-ui --filter build-tools-#{get_tools_version('build-tool')},extra-intel-Hardware_Accelerated_Execution_Manager,platform-tool,tool -a"
update_sdk(update_cmd, accept_all)
check_for_build_tools
check_for_platform_tools
check_for_emulator
check_for_haxm
end
end
end
def get_new_haxm_filename
- version = get_tools_version('extra', ADDONS_URL)
- zip_version = version.gsub(/\./, '_')
- haxm_file_name = ''
-
case android_package_os_id
- when MAC_OS_X
- haxm_file_name = "haxm-macosx_v#{zip_version}.zip"
- when WINDOWS
- haxm_file_name = "haxm-windows_v#{zip_version}.zip"
+ when MAC_OS_X, WINDOWS
+ version, file_name = get_tools_version('extra', ADDONS_URL, android_package_os_id)
when LINUX
puts 'HAXM installation on Linux is not supported, yet.'
- version = ''
+ file_name = version = ''
else
raise "Unknown host os: #{RbConfig::CONFIG['host_os']}"
end
- return haxm_file_name, version
+
+ return file_name, version
end
def download_haxm(accept_all, haxm_file_name)
- uri = 'https://software.intel.com/sites/default/files/managed/dd/21'
- download_third_party(haxm_file_name, uri)
+ download_third_party(haxm_file_name, ADDONS_URL)
unzip(accept_all, "#{android_haxm_directory}/#{haxm_file_name}", "#{android_haxm_directory}")
FileUtils.rm_f "#{android_haxm_directory}/#{haxm_file_name}"
end
def download_and_upgrade_haxm(accept_all)
@@ -789,10 +787,10 @@
system "touch #{config_file_name}"
end
old_config = File.read(config_file_name)
new_config = old_config.dup
- new_config.gsub! /\n*# BEGIN Ruboto setup\n.*?\n# END Ruboto setup\n*/m, ''
+ new_config.gsub! /\n*# BEGIN Ruboto setup\n.*?\n# END Ruboto setup\n*/m, "\n\n"
new_config << "\n\n# BEGIN Ruboto setup\n"
new_config << "source #{rubotorc}\n"
new_config << "# END Ruboto setup\n\n"
File.open(config_file_name, 'wb') { |f| f << new_config }
puts "Updated #{config_file_name} to load the #{rubotorc} config file."