Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to sdkmanager and support latest SDK #992

Open
wants to merge 1 commit into
base: trusty-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions community-cookbooks/android-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGELOG for Android-SDK cookbook
==================================

v0.2.3 (2018-08-10)
-------------------

- Migrate to `sdkmanager` command to install/update components
- Updated initial Android SDK download to version 26.1.1
- Support for Android SDK 28
- Use new emulator (added to $PATH)

v0.2.2 (2017-05-28)
-------------------

Expand Down
23 changes: 14 additions & 9 deletions community-cookbooks/android-sdk/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
default['android-sdk']['with_symlink'] = true # use ark's :install action when true; use ark's :put action when false
default['android-sdk']['set_environment_variables'] = true

default['android-sdk']['version'] = '25.2.3'
default['android-sdk']['checksum'] = '1b35bcb94e9a686dff6460c8bca903aa0281c6696001067f34ec00093145b560'
default['android-sdk']['download_url'] = "https://dl.google.com/android/repository/tools_r#{node['android-sdk']['version']}-linux.zip"
default['android-sdk']['version'] = '26.1.1'
default['android-sdk']['checksum'] = '92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9'
default['android-sdk']['download_url'] = "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"

# Use JDK 8
default['java']['jdk_version'] = '8'

#
# List of Android SDK components to preinstall:
Expand All @@ -21,12 +24,14 @@
# Note that it will require (waste) some extra download effort.
#
default['android-sdk']['components'] = %w( platform-tools
build-tools-25.0.2
android-25
extra-android-support
extra-google-google_play_services
extra-google-m2repository
extra-android-m2repository )
emulator
build-tools;25.0.3
build-tools;28.0.1
platforms;android-28
platforms;android-25
extras;google;google_play_services
extras;google;m2repository
extras;android;m2repository )

default['android-sdk']['license']['white_list'] = %w(.+)
default['android-sdk']['license']['black_list'] = [] # e.g. ['intel-.+', 'mips-.+', 'android-wear-sdk-license-.+']
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion community-cookbooks/android-sdk/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"android-sdk","version":"0.2.2","description":"Installs Google Android SDK","long_description":"","maintainer":"Gilles Cornu","maintainer_email":"foss@gilles.cornu.name","license":"Apache 2.0","platforms":{"ubuntu":">= 12.04","centos":">= 6.6"},"dependencies":{"java":">= 0.0.0","ark":">= 0.0.0"},"recommendations":{"maven":">= 0.0.0"},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"android-sdk::default":"Install and update Google Android SDK","android-sdk::maven_rescue":"Install missing dependencies with Maven Android SDK Deployer"},"source_url":"https://github.com/gildegoma/chef-android-sdk","issues_url":"https://github.com/gildegoma/chef-android-sdk/issues","chef_version":{},"ohai_version":{}}
{"name":"android-sdk","version":"0.2.3","description":"Installs Google Android SDK","long_description":"","maintainer":"Gilles Cornu","maintainer_email":"foss@gilles.cornu.name","license":"Apache 2.0","platforms":{"ubuntu":">= 12.04","centos":">= 6.6"},"dependencies":{"java":">= 0.0.0","ark":">= 0.0.0"},"recommendations":{"maven":">= 0.0.0"},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"android-sdk::default":"Install and update Google Android SDK","android-sdk::maven_rescue":"Install missing dependencies with Maven Android SDK Deployer"},"source_url":"https://github.com/gildegoma/chef-android-sdk","issues_url":"https://github.com/gildegoma/chef-android-sdk/issues","chef_version":{},"ohai_version":{}}
72 changes: 27 additions & 45 deletions community-cookbooks/android-sdk/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup_root = node['android-sdk']['setup_root'].to_s.empty? ? node['ark']['prefix_home'] : node['android-sdk']['setup_root']
android_home = File.join(setup_root, node['android-sdk']['name'])
android_bin = File.join(android_home, 'tools', 'android')
sdkmanager_bin = File.join(android_home, 'tools', 'bin', 'sdkmanager')

#
# Install required libraries
Expand Down Expand Up @@ -69,7 +69,7 @@
#
# Fix non-friendly 0750 permissions in order to make android-sdk available to all system users
#
directory File.join(android_home, 'tools') do
directory File.join(android_home, 'tools/bin') do
mode 0755
user node['android-sdk']['owner']
group node['android-sdk']['group']
Expand Down Expand Up @@ -103,66 +103,48 @@
package 'expect'

#
# Install, Update (a.k.a. re-install) Android components
# Install & Update SDK components
#

# KISS: use a basic idempotent guard, waiting for https://github.com/gildegoma/chef-android-sdk/issues/12
unless File.exist?("#{setup_root}/#{node['android-sdk']['name']}/temp")

# With "--filter node['android-sdk']['components'].join(,)" pattern,
# some system-images were not installed as expected.
# The easiest way I could find to fix this problem consists
# in executing a dedicated 'android sdk update' command for each component to be installed.
node['android-sdk']['components'].each do |sdk_component|
node['android-sdk']['components'].each do |sdk_component|
script "Install Android SDK component #{sdk_component}" do
interpreter 'expect'
environment 'ANDROID_HOME' => android_home
user node['android-sdk']['owner']
group node['android-sdk']['group']
# TODO: use --force or not?
code <<-EOF
spawn #{android_bin} update sdk --no-ui --all --filter #{sdk_component}
set timeout 1800
expect {
-regexp "Do you accept the license '(#{node['android-sdk']['license']['white_list'].join('|')})'.*" {
exp_send "y\r"
exp_continue
}
-regexp "Do you accept the license '(#{node['android-sdk']['license']['black_list'].join('|')})'.*" {
exp_send "n\r"
exp_continue
}
"Do you accept the license '*-license-*'*" {
exp_send "#{node['android-sdk']['license']['default_answer']}\r"
exp_continue
}
eof
interpreter 'expect'
environment 'ANDROID_HOME' => android_home
user node['android-sdk']['owner']
group node['android-sdk']['group']
code <<-EOF
spawn #{sdkmanager_bin} "#{sdk_component}"
set timeout 1800
expect {
-regexp "License (#{node['android-sdk']['license']['white_list'].join('|')}).*" {
exp_send "y\r"
exp_continue
}
EOF
end
-regexp "License (#{node['android-sdk']['license']['black_list'].join('|')}).*" {
exp_send "n\r"
exp_continue
}
-regexp "Accept (y/N):.*" {
exp_send "#{node['android-sdk']['license']['default_answer']}\r"
exp_continue
}
eof
}
EOF
end
end

#
# Deploy additional scripts, preferably outside Android-SDK own directories to
# avoid unwanted removal when updating android sdk components later.
#
%w(android-accept-licenses android-wait-for-emulator).each do |android_helper_script|
%w(android-wait-for-emulator).each do |android_helper_script|
cookbook_file File.join(node['android-sdk']['scripts']['path'], android_helper_script) do
source android_helper_script
owner node['android-sdk']['scripts']['owner']
group node['android-sdk']['scripts']['group']
mode 0755
end
end
%w(android-update-sdk).each do |android_helper_script|
template File.join(node['android-sdk']['scripts']['path'], android_helper_script) do
source "#{android_helper_script}.erb"
owner node['android-sdk']['scripts']['owner']
group node['android-sdk']['scripts']['group']
mode 0755
end
end

#
# Install Maven Android SDK Deployer toolkit to populate local Maven repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# this work around.

export ANDROID_HOME=<%= @android_home %>/
export PATH="${PATH}:${ANDROID_HOME}tools:${ANDROID_HOME}platform-tools"
export PATH="${PATH}:${ANDROID_HOME}emulator:${ANDROID_HOME}tools:${ANDROID_HOME}platform-tools"

This file was deleted.