android-sdk-installer 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1eba68eb1cab830def8a6eae35945af1d5714b97
4
- data.tar.gz: e2359275e7f4718b102f801772fc6ebfe2b1d07a
3
+ metadata.gz: a0d78fe80520b48d8ffd35c83d80051d33db5f9b
4
+ data.tar.gz: 3d292a66c5d94caf6552e4c63423cc09faf70a38
5
5
  SHA512:
6
- metadata.gz: d8945a448fcaed362c01ea70c692ced0c8566757fe56a70ef072abd1743fdea054f8143238ab1b25d7133bccf5ec098a2c375dcbe68bbafc8985e005c995940f
7
- data.tar.gz: b0075cdf29a289874461335f396ddf05f9f15389b91791d8e12508d0e8011dc532ad710a4086bb450154eac54f57ab75103d0d64620d3dc6209f7b7b0b603a26
6
+ metadata.gz: a78346da1787fca484eed509a89dc3387480b04dd814d16ad569e62ad22cb6d29451ac4b75a049eaaa417d8a4d0553a61564814389620799d3a15cf75a2db76d
7
+ data.tar.gz: fa05d50a5b54eaf6804ca7b8ef63e4eb6de094a8ea51fcbf59b4759686aa993a252d99327311214aa922858441e32bf0eb50cecc955d14c30b53b0feb11a450b
@@ -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
- # Gets rid of a warning
68
- # https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded
69
- unless Dir.exist?(ANDROID_DIR)
70
- `mkdir #{ANDROID_DIR}`
71
- end
72
- unless File.file?(REPOSITORIES_CONFIG_FILE)
73
- `touch #{REPOSITORIES_CONFIG_FILE}`
74
- end
75
- @logger.debug('SDK base installed to ' + Dir.pwd + '/android-sdk')
76
- end
77
-
78
- def install
79
- # Validation
80
- if File.file?(CONFIG_FILE)
81
- config = Psych.load_file CONFIG_FILE
82
- else
83
- config = Psych.load("foo: true\nbar: false")
84
- end
85
- if config.has_key?('version')
86
- @version = config['version']
87
- end
88
- if config['debug']
89
- @logger.level = Logger::DEBUG
90
- @logger.debug('We are in debug mode')
91
- end
92
-
93
- if config.has_key?('platform')
94
- @platform = config['platform']
95
- end
96
-
97
- if config.has_key?('ignore_existing')
98
- @ignore_existing = config['ignore_existing']
99
- @logger.debug("Ignore existing set to #{@ignore_existing}")
100
- end
101
-
102
- should_install = ENV['ANDROID_HOME'].nil? || @ignore_existing
103
- if should_install
104
- install_command_line_sdk(@platform, @version)
105
- else
106
- @logger.debug('ANDROID_HOME already set. Skipping command line tools install')
107
- end
108
-
109
- components = config['components']
110
- if components != nil
111
- components.each do |component|
112
- @logger.debug('Installing component ' + component)
113
- output = `echo y | $ANDROID_HOME/tools/bin/sdkmanager "#{component}"`
114
- @logger.debug(output)
115
- if output.include? 'Warning'
116
- puts "\nError installing component " + component + "\n"
117
- puts output
118
- end
119
- end
120
- end
121
- end
122
- end
123
- end
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.0.0
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.11
44
+ rubygems_version: 2.6.8
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: Android SDK installer