android-sdk-installer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/android-sdk-installer.rb +52 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f5d87a5a604492d69f91929b62b0503dc607ca7
|
4
|
+
data.tar.gz: 4cca1af8013343f49bf9ed8609cbf442972abc98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32d95334a68b81625f7ae32a054ab8bf1cc914cd4b1bfca2b198f237fbef324f012ec3bd3e202f19fc8b1fb9b87f81cb50de887e10096c74731cb53118724aed
|
7
|
+
data.tar.gz: 3151b64ea06f0572bc918789d779bddfe91459063de320fd218850c7e34148ad0cf57076929f5d8e38a1a95a96f7e2fa15ef4842085bfbcf29b40fb219d18608
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'psych'
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
module AndroidInstaller
|
@@ -6,23 +6,42 @@ module AndroidInstaller
|
|
6
6
|
# noinspection RubyClassVariableUsageInspection
|
7
7
|
class Installer
|
8
8
|
|
9
|
+
KEY_SDK_TOOLS = '{ANDROID_SDK_TOOLS}'
|
10
|
+
KEY_PLATFORM = '{PLATFORM}'
|
11
|
+
SDK_URL = 'https://dl.google.com'
|
12
|
+
SDK_PATH = '/android/repository/sdk-tools-' + KEY_PLATFORM + '-' + KEY_SDK_TOOLS + '.zip'
|
13
|
+
CONFIG_FILE = 'android-sdk-installer.yml'
|
14
|
+
|
9
15
|
def initialize
|
10
16
|
@@logger = Logger.new(STDOUT)
|
11
17
|
@@logger.level = Logger::WARN
|
12
18
|
end
|
13
19
|
|
20
|
+
def install_command_line_sdk(platform, version)
|
21
|
+
sdk_path = SDK_PATH
|
22
|
+
sdk_path[KEY_SDK_TOOLS] = version
|
23
|
+
sdk_path[KEY_PLATFORM] = platform
|
24
|
+
url = SDK_URL + sdk_path
|
25
|
+
@@logger.debug('Downloading version ' + version + ' for platform ' + platform + ' with url ' + url)
|
26
|
+
`wget --quiet --output-document=android-sdk.zip #{url}`
|
27
|
+
# TODO: error out here if file not found
|
28
|
+
unless File.file?('android-sdk.zip')
|
29
|
+
puts "\nAndroid SDK not found at url #{url}. Make sure you have the right values in your #{CONFIG_FILE}\n"
|
30
|
+
exit(1)
|
31
|
+
end
|
32
|
+
@@logger.debug('Unzipping android-sdk.zip')
|
33
|
+
`unzip -q android-sdk.zip -d $PWD/android-sdk`
|
34
|
+
`rm android-sdk.zip`
|
35
|
+
`export ANDROID_HOME=$PWD/android-sdk`
|
36
|
+
end
|
37
|
+
|
14
38
|
def install
|
15
|
-
# Why is it formatted like this?
|
16
|
-
key_sdk_tools = '{ANDROID_SDK_TOOLS}'
|
17
|
-
key_platform = '{PLATFORM}'
|
18
|
-
sdk_url = 'https://dl.google.com'
|
19
|
-
sdk_path = '/android/repository/sdk-tools-' + key_platform + '-' + key_sdk_tools + '.zip'
|
20
39
|
# Validation
|
21
|
-
|
22
|
-
|
23
|
-
|
40
|
+
if File.file?('android-sdk.zip')
|
41
|
+
config = Psych.load_file CONFIG_FILE
|
42
|
+
else
|
43
|
+
config = Psych.load("foo: true\nbar: false")
|
24
44
|
end
|
25
|
-
config = YAML.load_file('android-sdk-installer.yml')
|
26
45
|
version = '3859397'
|
27
46
|
if config.has_key?('version')
|
28
47
|
version = config['version']
|
@@ -36,23 +55,30 @@ module AndroidInstaller
|
|
36
55
|
if config.has_key?('platform')
|
37
56
|
platform = config['platform']
|
38
57
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
|
59
|
+
ignore_existing = false
|
60
|
+
if config.has_key?('ignore_existing')
|
61
|
+
ignore_existing = config['ignore_existing']
|
62
|
+
@@logger.debug("Ignore existing set to #{ignore_existing}")
|
63
|
+
end
|
64
|
+
|
65
|
+
should_install = ENV['ANDROID_HOME'].nil? || ignore_existing
|
66
|
+
if should_install
|
67
|
+
install_command_line_sdk(platform, version)
|
68
|
+
else
|
69
|
+
@@logger.debug('ANDROID_HOME already set. Skipping command line tools install')
|
70
|
+
end
|
71
|
+
|
48
72
|
components = config['components']
|
49
|
-
components
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
73
|
+
if components != nil
|
74
|
+
components.each do |component|
|
75
|
+
@@logger.debug('Installing component ' + component)
|
76
|
+
output = `echo y | $ANDROID_HOME/tools/bin/sdkmanager "#{component}"`
|
77
|
+
@@logger.debug(output)
|
78
|
+
if output.include? 'Warning'
|
79
|
+
puts "\nError installing component " + component + "\n"
|
80
|
+
puts output
|
81
|
+
end
|
56
82
|
end
|
57
83
|
end
|
58
84
|
end
|