android-sdk-installer 1.0.0 → 1.1.0
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 +133 -123
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d78fe80520b48d8ffd35c83d80051d33db5f9b
|
4
|
+
data.tar.gz: 3d292a66c5d94caf6552e4c63423cc09faf70a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a78346da1787fca484eed509a89dc3387480b04dd814d16ad569e62ad22cb6d29451ac4b75a049eaaa417d8a4d0553a61564814389620799d3a15cf75a2db76d
|
7
|
+
data.tar.gz: fa05d50a5b54eaf6804ca7b8ef63e4eb6de094a8ea51fcbf59b4759686aa993a252d99327311214aa922858441e32bf0eb50cecc955d14c30b53b0feb11a450b
|
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(ARGV)
|
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,123 +1,133 @@
|
|
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
|
-
DEFAULT_PLATFORM = 'linux'
|
18
|
-
DEFAULT_VERSION = '3859397'
|
19
|
-
|
20
|
-
def initialize(arguments)
|
21
|
-
@logger = Logger.new(STDOUT)
|
22
|
-
@logger.level = Logger::WARN
|
23
|
-
|
24
|
-
@ignore_existing = false
|
25
|
-
@platform = DEFAULT_PLATFORM
|
26
|
-
@version = DEFAULT_VERSION
|
27
|
-
create_options_parser(arguments)
|
28
|
-
end
|
29
|
-
|
30
|
-
def create_options_parser(args)
|
31
|
-
args.options do |opts|
|
32
|
-
opts.banner = 'Usage: android-sdk-installer [OPTIONS]'
|
33
|
-
opts.separator ''
|
34
|
-
opts.separator 'Options'
|
35
|
-
opts.on('-i', '--ignore', 'Ignore existing Android SDK, denoted by the existence of the ANDROID_HOME env variable') do
|
36
|
-
@ignore_existing = true
|
37
|
-
end
|
38
|
-
opts.on('-p PLATFORM', '--platform PLATFORM', 'Set the platform. Must be one of linux or darwin') do |platform|
|
39
|
-
@platform = platform
|
40
|
-
end
|
41
|
-
opts.on('-v VERSION', 'Set the version of the sdk to install') do |version|
|
42
|
-
@version = version
|
43
|
-
end
|
44
|
-
opts.on('-h', '--help', 'Displays help') do
|
45
|
-
puts opts.help
|
46
|
-
exit
|
47
|
-
end
|
48
|
-
opts.parse!
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def install_command_line_sdk(platform, version)
|
53
|
-
sdk_path = SDK_PATH
|
54
|
-
sdk_path[KEY_SDK_TOOLS] = version
|
55
|
-
sdk_path[KEY_PLATFORM] = platform
|
56
|
-
url = SDK_URL + sdk_path
|
57
|
-
@logger.debug('Downloading version ' + version + ' for platform ' + platform + ' with url ' + url)
|
58
|
-
`wget --quiet --output-document=android-sdk.zip #{url}`
|
59
|
-
unless File.file?('android-sdk.zip')
|
60
|
-
puts "\nAndroid SDK not found at url #{url}. Make sure you have the right values in your #{CONFIG_FILE}\n"
|
61
|
-
exit(1)
|
62
|
-
end
|
63
|
-
@logger.debug('Unzipping android-sdk.zip')
|
64
|
-
`unzip -q -o android-sdk.zip -d $PWD/android-sdk`
|
65
|
-
`rm android-sdk.zip`
|
66
|
-
`export ANDROID_HOME=$PWD/android-sdk`
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
@logger.
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
if
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
+
DEFAULT_PLATFORM = 'linux'
|
18
|
+
DEFAULT_VERSION = '3859397'
|
19
|
+
|
20
|
+
def initialize(arguments)
|
21
|
+
@logger = Logger.new(STDOUT)
|
22
|
+
@logger.level = Logger::WARN
|
23
|
+
|
24
|
+
@ignore_existing = false
|
25
|
+
@platform = DEFAULT_PLATFORM
|
26
|
+
@version = DEFAULT_VERSION
|
27
|
+
create_options_parser(arguments)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_options_parser(args)
|
31
|
+
args.options do |opts|
|
32
|
+
opts.banner = 'Usage: android-sdk-installer [OPTIONS]'
|
33
|
+
opts.separator ''
|
34
|
+
opts.separator 'Options'
|
35
|
+
opts.on('-i', '--ignore', 'Ignore existing Android SDK, denoted by the existence of the ANDROID_HOME env variable') do
|
36
|
+
@ignore_existing = true
|
37
|
+
end
|
38
|
+
opts.on('-p PLATFORM', '--platform PLATFORM', 'Set the platform. Must be one of linux or darwin') do |platform|
|
39
|
+
@platform = platform
|
40
|
+
end
|
41
|
+
opts.on('-v VERSION', 'Set the version of the sdk to install') do |version|
|
42
|
+
@version = version
|
43
|
+
end
|
44
|
+
opts.on('-h', '--help', 'Displays help') do
|
45
|
+
puts opts.help
|
46
|
+
exit
|
47
|
+
end
|
48
|
+
opts.parse!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def install_command_line_sdk(platform, version)
|
53
|
+
sdk_path = SDK_PATH
|
54
|
+
sdk_path[KEY_SDK_TOOLS] = version
|
55
|
+
sdk_path[KEY_PLATFORM] = platform
|
56
|
+
url = SDK_URL + sdk_path
|
57
|
+
@logger.debug('Downloading version ' + version + ' for platform ' + platform + ' with url ' + url)
|
58
|
+
`wget --quiet --output-document=android-sdk.zip #{url}`
|
59
|
+
unless File.file?('android-sdk.zip')
|
60
|
+
puts "\nAndroid SDK not found at url #{url}. Make sure you have the right values in your #{CONFIG_FILE}\n"
|
61
|
+
exit(1)
|
62
|
+
end
|
63
|
+
@logger.debug('Unzipping android-sdk.zip')
|
64
|
+
`unzip -q -o android-sdk.zip -d $PWD/android-sdk`
|
65
|
+
`rm android-sdk.zip`
|
66
|
+
`export ANDROID_HOME=$PWD/android-sdk`
|
67
|
+
create_dummy_cfg
|
68
|
+
add_license_acceptance
|
69
|
+
@logger.debug('SDK base installed to ' + Dir.pwd + '/android-sdk')
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_dummy_cfg
|
73
|
+
# Gets rid of a warning
|
74
|
+
# https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded
|
75
|
+
unless Dir.exist?(ANDROID_DIR)
|
76
|
+
`mkdir #{ANDROID_DIR}`
|
77
|
+
end
|
78
|
+
unless File.file?(REPOSITORIES_CONFIG_FILE)
|
79
|
+
`touch #{REPOSITORIES_CONFIG_FILE}`
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_license_acceptance
|
84
|
+
`mkdir "$ANDROID_HOME/licenses" || true`
|
85
|
+
`echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"`
|
86
|
+
end
|
87
|
+
|
88
|
+
def install
|
89
|
+
# Validation
|
90
|
+
if File.file?(CONFIG_FILE)
|
91
|
+
config = Psych.load_file CONFIG_FILE
|
92
|
+
else
|
93
|
+
config = Psych.load("foo: true\nbar: false")
|
94
|
+
end
|
95
|
+
if config.has_key?('version')
|
96
|
+
@version = config['version']
|
97
|
+
end
|
98
|
+
if config['debug']
|
99
|
+
@logger.level = Logger::DEBUG
|
100
|
+
@logger.debug('We are in debug mode')
|
101
|
+
end
|
102
|
+
|
103
|
+
if config.has_key?('platform')
|
104
|
+
@platform = config['platform']
|
105
|
+
end
|
106
|
+
|
107
|
+
if config.has_key?('ignore_existing')
|
108
|
+
@ignore_existing = config['ignore_existing']
|
109
|
+
@logger.debug("Ignore existing set to #{@ignore_existing}")
|
110
|
+
end
|
111
|
+
|
112
|
+
should_install = ENV['ANDROID_HOME'].nil? || @ignore_existing
|
113
|
+
if should_install
|
114
|
+
install_command_line_sdk(@platform, @version)
|
115
|
+
else
|
116
|
+
@logger.debug('ANDROID_HOME already set. Skipping command line tools install')
|
117
|
+
end
|
118
|
+
|
119
|
+
components = config['components']
|
120
|
+
if components != nil
|
121
|
+
components.each do |component|
|
122
|
+
@logger.debug('Installing component ' + component)
|
123
|
+
output = `echo y | $ANDROID_HOME/tools/bin/sdkmanager "#{component}"`
|
124
|
+
@logger.debug(output)
|
125
|
+
if output.include? 'Warning'
|
126
|
+
puts "\nError installing component " + component + "\n"
|
127
|
+
puts output
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: android-sdk-installer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Commit 451
|
@@ -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.8
|
45
45
|
signing_key:
|
46
46
|
specification_version: 4
|
47
47
|
summary: Android SDK installer
|