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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e65bcb4daf01baabce3b792658917bd78c996bb
4
- data.tar.gz: d98fefd2f7f53042f5a7e08e980f6f9c7b1bd24d
3
+ metadata.gz: 9cda68cb222bbab1fec842df4c573eccfa361934
4
+ data.tar.gz: 85478a9635602e49dc2c62e40a32b8862cfc02a6
5
5
  SHA512:
6
- metadata.gz: 8e77c0dc738ec2f96839f78564cc65dfe6545e1dc97b470835879f510b808129aa15edc2d792635e498455238e2baed02eddf72e4b389d44ad4fe1f2c2884e6d
7
- data.tar.gz: a6578b55af64f8a76fbf49bd3cf8aa0185424187252d28143d88c7806ad66950cd7e9738cebe1214eb33372d95c8d0d5c87368d189e4bd2377e6a5dc97467d81
6
+ metadata.gz: b75ee4e1d09fa1a4c0a4ce598361c9ea0ff9ff5c47c6b788527cf0d6d09a77a7bbf5cd246eb6ccc9ceaaf37941ad9034cbeca76e300c68177840c9240abed35f
7
+ data.tar.gz: 551bac066b8e8af57012b5f26bc9fe078ab320433a5423ffeb2a7f8ba80a8b5a7b76384f6a3c796e709a21df7b0d03a537e82489cfa0dbf2ced15530ce52abdc
@@ -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
- module AndroidInstaller
5
- # Installs components for building Android projects
6
- # noinspection RubyClassVariableUsageInspection
7
- class Installer
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
-
15
- def initialize
16
- @@logger = Logger.new(STDOUT)
17
- @@logger.level = Logger::WARN
18
- end
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
- unless File.file?('android-sdk.zip')
28
- puts "\nAndroid SDK not found at url #{url}. Make sure you have the right values in your #{CONFIG_FILE}\n"
29
- exit(1)
30
- end
31
- @@logger.debug('Unzipping android-sdk.zip')
32
- `unzip -q android-sdk.zip -d $PWD/android-sdk`
33
- `rm android-sdk.zip`
34
- `export ANDROID_HOME=$PWD/android-sdk`
35
- # Gets rid of a warning
36
- # https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded
37
- `touch ~/.android/repositories.cfg`
38
- @@logger.debug('SDK base installed to ' + Dir.pwd + 'android-sdk')
39
- end
40
-
41
- def install
42
- # Validation
43
- if File.file?(CONFIG_FILE)
44
- config = Psych.load_file CONFIG_FILE
45
- else
46
- config = Psych.load("foo: true\nbar: false")
47
- end
48
- version = '3859397'
49
- if config.has_key?('version')
50
- version = config['version']
51
- end
52
- if config['debug']
53
- @@logger.level = Logger::DEBUG
54
- @@logger.debug('We are in debug mode')
55
- end
56
-
57
- platform = 'linux'
58
- if config.has_key?('platform')
59
- platform = config['platform']
60
- end
61
-
62
- ignore_existing = false
63
- if config.has_key?('ignore_existing')
64
- ignore_existing = config['ignore_existing']
65
- @@logger.debug("Ignore existing set to #{ignore_existing}")
66
- end
67
-
68
- should_install = ENV['ANDROID_HOME'].nil? || ignore_existing
69
- if should_install
70
- install_command_line_sdk(platform, version)
71
- else
72
- @@logger.debug('ANDROID_HOME already set. Skipping command line tools install')
73
- end
74
-
75
- components = config['components']
76
- if components != nil
77
- components.each do |component|
78
- @@logger.debug('Installing component ' + component)
79
- output = `echo y | $ANDROID_HOME/tools/bin/sdkmanager "#{component}"`
80
- @@logger.debug(output)
81
- if output.include? 'Warning'
82
- puts "\nError installing component " + component + "\n"
83
- puts output
84
- end
85
- end
86
- end
87
- end
88
- end
89
- 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
+
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.6
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-05-29 00:00:00.000000000 Z
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.8
44
+ rubygems_version: 2.6.11
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: Android SDK installer