android-sdk-installer 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/android-sdk-installer +6 -6
- data/lib/android-sdk-installer.rb +115 -89
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cda68cb222bbab1fec842df4c573eccfa361934
|
4
|
+
data.tar.gz: 85478a9635602e49dc2c62e40a32b8862cfc02a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b75ee4e1d09fa1a4c0a4ce598361c9ea0ff9ff5c47c6b788527cf0d6d09a77a7bbf5cd246eb6ccc9ceaaf37941ad9034cbeca76e300c68177840c9240abed35f
|
7
|
+
data.tar.gz: 551bac066b8e8af57012b5f26bc9fe078ab320433a5423ffeb2a7f8ba80a8b5a7b76384f6a3c796e709a21df7b0d03a537e82489cfa0dbf2ced15530ce52abdc
|
data/bin/android-sdk-installer
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'android-sdk-installer'
|
4
|
-
|
5
|
-
installer = AndroidInstaller::Installer.new
|
6
|
-
installer.install
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'android-sdk-installer'
|
4
|
+
|
5
|
+
installer = AndroidInstaller::Installer.new(ARGV)
|
6
|
+
installer.install
|
@@ -1,89 +1,115 @@
|
|
1
|
-
require 'psych'
|
2
|
-
require 'logger'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
1
|
+
require 'psych'
|
2
|
+
require 'logger'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module AndroidInstaller
|
6
|
+
# Installs components for building Android projects
|
7
|
+
# noinspection RubyClassVariableUsageInspection
|
8
|
+
class Installer
|
9
|
+
|
10
|
+
KEY_SDK_TOOLS = '{ANDROID_SDK_TOOLS}'
|
11
|
+
KEY_PLATFORM = '{PLATFORM}'
|
12
|
+
SDK_URL = 'https://dl.google.com'
|
13
|
+
SDK_PATH = '/android/repository/sdk-tools-' + KEY_PLATFORM + '-' + KEY_SDK_TOOLS + '.zip'
|
14
|
+
CONFIG_FILE = 'android-sdk-installer.yml'
|
15
|
+
REPOSITORIES_CONFIG_FILE = '~/.android/repositories.cfg'
|
16
|
+
ANDROID_DIR = '~/.android'
|
17
|
+
|
18
|
+
def initialize(arguments)
|
19
|
+
@logger = Logger.new(STDOUT)
|
20
|
+
@logger.level = Logger::WARN
|
21
|
+
|
22
|
+
@ignore_existing = false
|
23
|
+
create_options_parser(arguments)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_options_parser(args)
|
27
|
+
args.options do |opts|
|
28
|
+
opts.banner = 'Usage: android-sdk-installer [OPTIONS]'
|
29
|
+
opts.separator ''
|
30
|
+
opts.separator 'Options'
|
31
|
+
opts.on('-i', '--ignore', 'Ignore existing Android SDK, denoted by the existence of the ANDROID_HOME env variable') do
|
32
|
+
@ignore_existing = true
|
33
|
+
end
|
34
|
+
opts.on('-h', '--help', 'Displays help') do
|
35
|
+
puts opts.help
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
opts.parse!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def install_command_line_sdk(platform, version)
|
43
|
+
sdk_path = SDK_PATH
|
44
|
+
sdk_path[KEY_SDK_TOOLS] = version
|
45
|
+
sdk_path[KEY_PLATFORM] = platform
|
46
|
+
url = SDK_URL + sdk_path
|
47
|
+
@logger.debug('Downloading version ' + version + ' for platform ' + platform + ' with url ' + url)
|
48
|
+
`wget --quiet --output-document=android-sdk.zip #{url}`
|
49
|
+
unless File.file?('android-sdk.zip')
|
50
|
+
puts "\nAndroid SDK not found at url #{url}. Make sure you have the right values in your #{CONFIG_FILE}\n"
|
51
|
+
exit(1)
|
52
|
+
end
|
53
|
+
@logger.debug('Unzipping android-sdk.zip')
|
54
|
+
`unzip -q -o android-sdk.zip -d $PWD/android-sdk`
|
55
|
+
`rm android-sdk.zip`
|
56
|
+
`export ANDROID_HOME=$PWD/android-sdk`
|
57
|
+
# Gets rid of a warning
|
58
|
+
# https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded
|
59
|
+
unless Dir.exist?(ANDROID_DIR)
|
60
|
+
`mkdir #{ANDROID_DIR}`
|
61
|
+
end
|
62
|
+
unless File.file?(REPOSITORIES_CONFIG_FILE)
|
63
|
+
`touch #{REPOSITORIES_CONFIG_FILE}`
|
64
|
+
end
|
65
|
+
@logger.debug('SDK base installed to ' + Dir.pwd + '/android-sdk')
|
66
|
+
end
|
67
|
+
|
68
|
+
def install
|
69
|
+
# Validation
|
70
|
+
if File.file?(CONFIG_FILE)
|
71
|
+
config = Psych.load_file CONFIG_FILE
|
72
|
+
else
|
73
|
+
config = Psych.load("foo: true\nbar: false")
|
74
|
+
end
|
75
|
+
version = '3859397'
|
76
|
+
if config.has_key?('version')
|
77
|
+
version = config['version']
|
78
|
+
end
|
79
|
+
if config['debug']
|
80
|
+
@logger.level = Logger::DEBUG
|
81
|
+
@logger.debug('We are in debug mode')
|
82
|
+
end
|
83
|
+
|
84
|
+
platform = 'linux'
|
85
|
+
if config.has_key?('platform')
|
86
|
+
platform = config['platform']
|
87
|
+
end
|
88
|
+
|
89
|
+
if config.has_key?('ignore_existing')
|
90
|
+
@ignore_existing = config['ignore_existing']
|
91
|
+
@logger.debug("Ignore existing set to #{@ignore_existing}")
|
92
|
+
end
|
93
|
+
|
94
|
+
should_install = ENV['ANDROID_HOME'].nil? || @ignore_existing
|
95
|
+
if should_install
|
96
|
+
install_command_line_sdk(platform, version)
|
97
|
+
else
|
98
|
+
@logger.debug('ANDROID_HOME already set. Skipping command line tools install')
|
99
|
+
end
|
100
|
+
|
101
|
+
components = config['components']
|
102
|
+
if components != nil
|
103
|
+
components.each do |component|
|
104
|
+
@logger.debug('Installing component ' + component)
|
105
|
+
output = `echo y | $ANDROID_HOME/tools/bin/sdkmanager "#{component}"`
|
106
|
+
@logger.debug(output)
|
107
|
+
if output.include? 'Warning'
|
108
|
+
puts "\nError installing component " + component + "\n"
|
109
|
+
puts output
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: android-sdk-installer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Commit 451
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
43
|
rubyforge_project:
|
44
|
-
rubygems_version: 2.6.
|
44
|
+
rubygems_version: 2.6.11
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: Android SDK installer
|