mobo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mobo/android.rb +44 -23
- data/lib/mobo/system_check.rb +19 -11
- data/lib/mobo/system_setup.rb +1 -20
- data/lib/mobo.rb +3 -3
- metadata +2 -3
- data/mobo.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f77e20cff1a1e98f80bf8f37403cea15cffcbc5
|
4
|
+
data.tar.gz: b25b6714a1b911f45d20461c8472777fa34d5b8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d55e7bf129fbec48f552aa2613072b9e49db8de1ad4defa88747914cd4d0b37499dfb3c20bb3b1ce84cda0bcc4957d6b4453ebc7d213c9986243be753aa9cef2
|
7
|
+
data.tar.gz: b1ee9d312f2b2b32247c3cbd27228a379e7156d3bb3e5ecbed1eaad10c90a879444a2267de3dbbafc97f342c6d7d87a460390c41bc17611936a669ebf064c4f0
|
data/lib/mobo/android.rb
CHANGED
@@ -4,33 +4,49 @@ module Mobo
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
def exists?
|
7
|
-
|
8
|
-
|
7
|
+
if Mobo.cmd("which android")
|
8
|
+
return true
|
9
|
+
# if exists? isn't true straight away, check if ANDROID_HOME is set, and try and
|
10
|
+
# fix the issue
|
11
|
+
elsif ENV['ANDROID_HOME'] and File.exists?(ENV['ANDROID_HOME'] + '/tools/android')
|
12
|
+
add_to_path(ENV['ANDROID_HOME'])
|
13
|
+
Mobo.cmd("which android")
|
14
|
+
end
|
9
15
|
end
|
10
16
|
|
11
17
|
def install
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
if SystemCheck.ubuntu?
|
19
|
+
Mobo.cmd("curl -O http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz")
|
20
|
+
Mobo.cmd("sudo tar -xf android-sdk_r24.3.4-linux.tgz -C /usr/local/")
|
21
|
+
Mobo.cmd("sudo chown -R $(whoami) /usr/local/android-sdk-linux")
|
22
|
+
add_to_path("/usr/local/android-sdk-linux")
|
23
|
+
elsif SystemCheck.osx?
|
24
|
+
Mobo.cmd("curl -O http://dl.google.com/android/android-sdk_r24.3.4-macosx.zip")
|
25
|
+
Mobo.cmd("sudo unzip android-sdk_r24.3.4-macosx.zip -d /usr/local/")
|
26
|
+
Mobo.cmd("sudo chown -R $(whoami) /usr/local/android-sdk-macosx")
|
27
|
+
add_to_path("/usr/local/android-sdk-macosx")
|
28
|
+
else
|
29
|
+
Mobo.log.error("Platform not yet supported! Please raise a request with the project to support it.")
|
30
|
+
end
|
16
31
|
end
|
17
32
|
|
18
33
|
# setting env variables in the bash profile and trying to reload them isn't easy,
|
19
34
|
# as the variables are only set in the sub process the bash_profile is executed in
|
20
35
|
# so we can set env variables, which take effect here, and also set them in bash_profile
|
21
36
|
# for the user to use later on
|
22
|
-
def add_to_path
|
23
|
-
|
24
|
-
|
25
|
-
if !ENV['PATH'].match(/#{android_home}/)
|
37
|
+
def add_to_path(android_home)
|
38
|
+
android_tools = android_home + '/tools'
|
39
|
+
unless ENV['PATH'].match(/#{android_home}/)
|
26
40
|
ENV['ANDROID_HOME'] = android_home
|
27
|
-
ENV['PATH'] += ":#{
|
28
|
-
|
29
|
-
|
41
|
+
ENV['PATH'] += ":#{android_tools}"
|
42
|
+
end
|
43
|
+
unless Mobo.cmd("grep -i ANDROID_HOME ~/.bash_profile")
|
44
|
+
Mobo.cmd("echo 'export ANDROID_HOME=#{android_home}' >> ~/.bash_profile")
|
45
|
+
Mobo.cmd("echo 'export PATH=\$PATH:#{android_tools}' >> ~/.bash_profile")
|
30
46
|
Mobo.log.info("ANDROID_HOME and PATH env variables have been updated.
|
31
47
|
Start a new terminal session for them to take effect")
|
32
|
-
raise "Setting ANDROID_HOME and PATH failed" unless self.exists?
|
33
48
|
end
|
49
|
+
raise "Setting ANDROID_HOME and PATH failed" unless self.exists?
|
34
50
|
end
|
35
51
|
|
36
52
|
def package_exists?(package)
|
@@ -74,7 +90,7 @@ module Mobo
|
|
74
90
|
module Avd
|
75
91
|
class << self
|
76
92
|
def create(device)
|
77
|
-
SystemCheck.target_exists(device["target"])
|
93
|
+
SystemCheck.target_exists?(device["target"])
|
78
94
|
SystemCheck.abi_exists?(device["target"], device["abi"])
|
79
95
|
SystemCheck.skin_exists?(device["target"], device["skin"])
|
80
96
|
emulator_cmd =
|
@@ -97,7 +113,7 @@ module Mobo
|
|
97
113
|
def add_to_path
|
98
114
|
if !ENV['PATH'].match(/platform-tools/)
|
99
115
|
ENV['PATH'] += ":#{ENV['ANDROID_HOME']}/platform-tools"
|
100
|
-
Mobo.cmd("echo
|
116
|
+
Mobo.cmd("echo 'export PATH=\$PATH:#{ENV['ANDROID_HOME']}/platform-tools' >> ~/.bash_profile")
|
101
117
|
Mobo.log.debug("ENV['PATH'] set to #{ENV['PATH']}")
|
102
118
|
Mobo.log.info("PATH env variables has been updated.
|
103
119
|
Start a new terminal session for it to take effect")
|
@@ -105,7 +121,6 @@ module Mobo
|
|
105
121
|
end
|
106
122
|
|
107
123
|
def exists?
|
108
|
-
add_to_path
|
109
124
|
Mobo.cmd("which adb")
|
110
125
|
end
|
111
126
|
|
@@ -171,6 +186,7 @@ module Mobo
|
|
171
186
|
Mobo.cmd(cmd)
|
172
187
|
Mobo.log.info("Emulator #{@device["name"]} has stopped")
|
173
188
|
}
|
189
|
+
Process.detach(pid)
|
174
190
|
|
175
191
|
@device["pid"] = pid
|
176
192
|
@device["id"] = "emulator-#{@device["port"]}"
|
@@ -186,8 +202,12 @@ module Mobo
|
|
186
202
|
elsif !running?
|
187
203
|
Mobo.log.error("Emulator #{@device["name"]} has stopped")
|
188
204
|
break
|
205
|
+
elsif booting?
|
206
|
+
Mobo.log.info("waiting for #{@device["id"]} to boot...")
|
207
|
+
sleep(BOOT_SLEEP)
|
189
208
|
else
|
190
|
-
|
209
|
+
# adb does not always recgnoise new emulators booted up, so it needs to be restarted
|
210
|
+
Mobo.cmd('adb kill-server')
|
191
211
|
sleep(BOOT_SLEEP)
|
192
212
|
end
|
193
213
|
end
|
@@ -209,11 +229,12 @@ module Mobo
|
|
209
229
|
|
210
230
|
def booted?
|
211
231
|
bootanim = Mobo.cmd_out("adb -s #{@device["id"]} shell 'getprop init.svc.bootanim'")
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
232
|
+
bootanim.match(/stopped/)
|
233
|
+
end
|
234
|
+
|
235
|
+
def booting?
|
236
|
+
bootanim = Mobo.cmd_out("adb -s #{@device["id"]} shell 'getprop init.svc.bootanim'")
|
237
|
+
bootanim.match(/running/)
|
217
238
|
end
|
218
239
|
|
219
240
|
def unlock
|
data/lib/mobo/system_check.rb
CHANGED
@@ -7,19 +7,25 @@ module Mobo
|
|
7
7
|
raise error unless $?.success?
|
8
8
|
end
|
9
9
|
|
10
|
-
def android
|
11
|
-
Android.exists?
|
10
|
+
def android?
|
11
|
+
Android.install unless Android.exists?
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def adb?
|
15
|
+
Android::Adb.install unless Android::Adb.exists?
|
16
|
+
end
|
17
|
+
|
18
|
+
def target_exists?(target)
|
15
19
|
unless Android::Targets.exists?(target)
|
16
|
-
|
20
|
+
Android.install_package(target) if Android.package_exists?(target)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def abi_exists?(target, abi)
|
21
25
|
unless Android::Targets.has_abi?(target, abi)
|
22
|
-
|
26
|
+
package_name = Android::Targets.abi_package(target, abi)
|
27
|
+
Android.install_package(package_name) if Android.package_exists?(package_name)
|
28
|
+
raise "Cannot install abi: #{abi} for #{target}" unless $?.success?
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
@@ -27,15 +33,17 @@ module Mobo
|
|
27
33
|
Android::Targets.has_skin?(target, abi)
|
28
34
|
end
|
29
35
|
|
30
|
-
def adb
|
31
|
-
unless Android::Adb.exists?
|
32
|
-
SystemSetup.install_adb
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
36
|
def device_file_exists?(filename)
|
37
37
|
File.exists?(filename)
|
38
38
|
end
|
39
|
+
|
40
|
+
def ubuntu?
|
41
|
+
RUBY_PLATFORM.match(/linux/) and Mobo.cmd("which apt-get")
|
42
|
+
end
|
43
|
+
|
44
|
+
def osx?
|
45
|
+
RUBY_PLATFORM.match(/darwin/)
|
46
|
+
end
|
39
47
|
end
|
40
48
|
end
|
41
49
|
end
|
data/lib/mobo/system_setup.rb
CHANGED
@@ -3,30 +3,11 @@ module Mobo
|
|
3
3
|
class << self
|
4
4
|
|
5
5
|
def base_libraries
|
6
|
-
|
7
|
-
if(Mobo.cmd("which apt-get"))
|
6
|
+
if SystemCheck.ubuntu?
|
8
7
|
Mobo.cmd("sudo apt-get install -y libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1")
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
|
-
def install_android
|
13
|
-
Android.install
|
14
|
-
end
|
15
|
-
|
16
|
-
def install_target(target)
|
17
|
-
Android.install_package(target) if Android.package_exists?(target)
|
18
|
-
raise "Cannot install target: #{target}" unless $?.success?
|
19
|
-
end
|
20
|
-
|
21
|
-
def install_abi(target, abi)
|
22
|
-
package_name = Android::Targets.abi_package(target, abi)
|
23
|
-
Android.install_package(package_name) if Android.package_exists?(package_name)
|
24
|
-
raise "Cannot install abi: #{abi} for #{target}" unless $?.success?
|
25
|
-
end
|
26
|
-
|
27
|
-
def install_adb
|
28
|
-
Android::Adb.install unless Android::Adb.exists?
|
29
|
-
end
|
30
11
|
end
|
31
12
|
end
|
32
13
|
end
|
data/lib/mobo.rb
CHANGED
@@ -60,8 +60,8 @@ module Mobo
|
|
60
60
|
|
61
61
|
def system_checks
|
62
62
|
SystemSetup.base_libraries
|
63
|
-
SystemCheck.android
|
64
|
-
SystemCheck.adb
|
63
|
+
SystemCheck.android?
|
64
|
+
SystemCheck.adb?
|
65
65
|
end
|
66
66
|
|
67
67
|
def up(filename)
|
@@ -83,7 +83,7 @@ module Mobo
|
|
83
83
|
File.open(MOBO_DEVICES_CACHE_FILE, "w") do |file|
|
84
84
|
file.write Mobo.devices.to_yaml
|
85
85
|
end
|
86
|
-
Process.
|
86
|
+
Process.wait
|
87
87
|
end
|
88
88
|
|
89
89
|
def status(filename)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark O'Shea
|
@@ -17,7 +17,6 @@ executables:
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- mobo.rb
|
21
20
|
- lib/mobo/android.rb
|
22
21
|
- lib/mobo/system_check.rb
|
23
22
|
- lib/mobo/system_setup.rb
|
@@ -43,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
42
|
version: '0'
|
44
43
|
requirements: []
|
45
44
|
rubyforge_project:
|
46
|
-
rubygems_version: 2.0.
|
45
|
+
rubygems_version: 2.0.14
|
47
46
|
signing_key:
|
48
47
|
specification_version: 4
|
49
48
|
summary: Mobo - android emulator abstraction
|
data/mobo.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'yaml'
|
3
|
-
require 'pp'
|
4
|
-
require 'logger'
|
5
|
-
require_relative 'lib/mobo/android'
|
6
|
-
require_relative 'lib/mobo/system_check'
|
7
|
-
|
8
|
-
module Mobo
|
9
|
-
class << self
|
10
|
-
attr_accessor :log, :data, :devices
|
11
|
-
|
12
|
-
def log
|
13
|
-
@log || @log = Logger.new(STDOUT)
|
14
|
-
end
|
15
|
-
|
16
|
-
def cmd(command)
|
17
|
-
log.debug(command)
|
18
|
-
system(command)
|
19
|
-
end
|
20
|
-
|
21
|
-
def cmd_out(command)
|
22
|
-
log.debug(command)
|
23
|
-
`#{command}`
|
24
|
-
end
|
25
|
-
|
26
|
-
def start_process(cmd)
|
27
|
-
pid = Process.spawn(cmd)
|
28
|
-
Process.detach(pid)
|
29
|
-
pid
|
30
|
-
end
|
31
|
-
|
32
|
-
def devices
|
33
|
-
@devices = @devices.nil? ? {} : @devices
|
34
|
-
end
|
35
|
-
|
36
|
-
def device_config(device)
|
37
|
-
defaults = {
|
38
|
-
"name" => "default",
|
39
|
-
"target" => "android-22",
|
40
|
-
"abi" => "default/x86_64",
|
41
|
-
"height" => "1200",
|
42
|
-
"width" => "720",
|
43
|
-
"sdcard_size" => "20M" }
|
44
|
-
defaults.merge(device)
|
45
|
-
end
|
46
|
-
|
47
|
-
def up
|
48
|
-
# retrive settings for one of each device
|
49
|
-
Mobo.data["devices"].each do |device|
|
50
|
-
device = device_config(device)
|
51
|
-
Mobo.devices[device["name"]] = device
|
52
|
-
end
|
53
|
-
|
54
|
-
# build and boot devices
|
55
|
-
Mobo.devices.each_pair do |name, device|
|
56
|
-
Mobo::Android::Avd.create(device)
|
57
|
-
emulator = Android::Emulator.new(device)
|
58
|
-
emulator.start
|
59
|
-
emulator.unlock_when_booted
|
60
|
-
end
|
61
|
-
File.open(MOBO_DEVICES_FILE, "w") do |file|
|
62
|
-
file.write Mobo.devices.to_yaml
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def status
|
67
|
-
Mobo.data.each_pair do |name, device|
|
68
|
-
Mobo::Android::Emulator.new(device).status
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def destroy
|
73
|
-
Mobo.data.each_pair do |name, device|
|
74
|
-
Mobo::Android::Emulator.new(device).destroy
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|