diff --git a/manifests/ndk.pp b/manifests/ndk.pp index 1f85e60..763e279 100644 --- a/manifests/ndk.pp +++ b/manifests/ndk.pp @@ -21,8 +21,9 @@ include android::params include wget - $base_path = "http://dl.google.com/android/ndk/${ndk_version}" - $ndk_installer = "${android::paths::installdir}/${ndk_version}" + $ndk_package = "android-ndk-${ndk_version}-linux-x86_64" + $base_path = "https://dl.google.com/android/repository/${ndk_package}.zip" + $ndk_installer = "${android::paths::installdir}/${ndk_package}" wget::fetch { 'download-androidndk': source => $base_path, destination => $ndk_installer, diff --git a/manifests/package.pp b/manifests/package.pp index 35f24cd..742c47f 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -24,41 +24,47 @@ $proxy_host = $android::proxy_host ? { undef => '', default => "--proxy-host ${android::proxy_host}" } $proxy_port = $android::proxy_port ? { undef => '', default => "--proxy-port ${android::proxy_port}" } + $cleaned_title = regsubst($title, ';', '-', 'G') case $type { 'platform-tools': { - $creates = "${android::paths::sdk_home}/platform-tools" + $create_path_suffix = 'platform-tools' + $package_name = $title } 'platform': { - $creates = "${android::paths::sdk_home}/platforms/${title}" + $create_path_suffix = "platforms/${title}" + $package_name = "platforms;${title}" } 'system-images': { - $title_parts = split($title, '-') - $creates = "${android::paths::sdk_home}/system-images/android-${title_parts[-1]}/default/${title_parts[2]}-${title_parts[3]}" + $title_parts = split($title, ';') + $create_path_suffix = "${type}/${title_parts[0]}/${title_parts[1]}/${title_parts[2]}" + $package_name = "${type};${title}" } 'addon': { - $creates = "${android::paths::sdk_home}/add-ons/${title}" + $create_path_suffix = "add-ons/${title}" + $package_name = "add-ons;${title}" } 'extra': { - $title_parts = split($title, '-') - $creates = "${android::paths::sdk_home}/extras/${title_parts[1]}/${title_parts[2]}" + $title_parts = split($title, ';') + $create_path_suffix = join(['extras', join($title_parts, '/')], '/') + $package_name = "extras;${title}" } 'build-tools': { - $title_parts = split($title, '-') - $creates = "${android::paths::sdk_home}/build-tools/${title_parts[2]}" + $create_path_suffix = "build-tools/${title}" + $package_name = "${type};${title}" } default: { fail("Unsupported package type: ${type}") } } - file { "${android::installdir}/expect-install-${title}": + file { "${android::installdir}/expect-install-${cleaned_title}": content => template('android/expect-script.erb'), mode => '0755', } -> - exec { "update-android-package-${title}": - command => "${android::installdir}/expect-install-${title}", - creates => $creates, + exec { "update-android-package-${cleaned_title}": + command => "${android::installdir}/expect-install-${cleaned_title}", + creates => "${android::paths::sdk_home}/${create_path_suffix}", timeout => 0, require => [Class['android::sdk']], } diff --git a/manifests/params.pp b/manifests/params.pp index f8cef6f..f8cb9c1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,12 +12,12 @@ # class android::params { - $version = '22.3' + $version = '4333796' $proxy_host = undef $proxy_port = undef $installdir = '/usr/local/android' - $ndk_version = 'android-ndk-r10d-linux-x86_64.bin' + $ndk_version = 'r18b' case $::kernel { 'Linux': { diff --git a/manifests/paths.pp b/manifests/paths.pp index b8772d3..d4d390a 100644 --- a/manifests/paths.pp +++ b/manifests/paths.pp @@ -19,17 +19,17 @@ case $::kernel { 'Linux': { $sdk_home = "${installdir}/android-sdk-linux" - $distrib_file = "android-sdk_r${version}-linux.tgz" + $distrib_file = "sdk-tools-linux-${version}.zip" } 'Darwin': { - $sdk_home = "${installdir}/android-sdk-macosx" - $distrib_file = "android-sdk_r${version}-macosx.zip" + $sdk_home = "${installdir}/android-sdk-darwin" + $distrib_file = "sdk-tools-darwin-${version}.zip" } default: { fail("Unsupported Kernel: ${::kernel} operatingsystem: ${::operatingsystem}") } } - $source = "http://dl.google.com/android/${distrib_file}" + $source = "https://dl.google.com/android/repository/${distrib_file}" $archive = "${installdir}/${distrib_file}" $toolsdir = "${sdk_home}/tools" diff --git a/manifests/sdk.pp b/manifests/sdk.pp index 4e4effd..0046045 100644 --- a/manifests/sdk.pp +++ b/manifests/sdk.pp @@ -19,31 +19,26 @@ Exec { user => $android::user } } - case $::kernel { - 'Linux': { - $unpack_command = "/bin/tar -xvf ${android::paths::archive} --no-same-owner --no-same-permissions && chmod -R a+rx ${android::paths::sdk_home}" - } - 'Darwin': { - $unpack_command = "/usr/bin/unzip ${android::paths::archive} && chmod -R a+rx ${android::paths::sdk_home}" - } - default: { - fail("Unsupported Kernel: ${::kernel} operatingsystem: ${::operatingsystem}") - } - } + $unpack_command = "/usr/bin/unzip -q -o ${android::paths::archive} && chmod -R a+rx ${android::paths::sdk_home}" file { $android::paths::installdir: ensure => directory, owner => $android::user, group => $android::group, } -> + file { $android::paths::sdk_home: + ensure => directory, + owner => $android::user, + group => $android::group, + } -> wget::fetch { 'download-androidsdk': source => $android::paths::source, destination => $android::paths::archive, } -> exec { 'unpack-androidsdk': command => $unpack_command, - creates => $android::paths::sdk_home, - cwd => $android::paths::installdir, + creates => $android::paths::toolsdir, + cwd => $android::paths::sdk_home, }-> file { 'android-executable': ensure => present, @@ -56,7 +51,7 @@ # For 64bit systems, we need to install some 32bit libraries for the SDK # to work. if ($::kernel == 'Linux') and ($::architecture == 'x86_64' or $::architecture == 'amd64') { - if $::lsbdistcodename == 'jessie' or $::lsbdistrelease == 14.04 { + if $::lsbdistcodename == 'jessie' or $::lsbdistcodename == 'stretch' or $::lsbdistrelease == 14.04 { ensure_packages(['libc6-i386', 'lib32stdc++6', 'lib32gcc1', 'lib32ncurses5', 'lib32z1']) } else { ensure_packages($::osfamily ? { diff --git a/metadata.json b/metadata.json index 42d275c..5f536e5 100644 --- a/metadata.json +++ b/metadata.json @@ -10,8 +10,8 @@ "description": "A Puppet module to install the Android SDK.", "dependencies": [ { - "name": "maestrodev/wget", - "version_requirement": ">=1.0.0" + "name": "puppet/wget", + "version_requirement": ">=2.0.0" }, { "name": "puppetlabs/stdlib", diff --git a/spec/classes/sdk_spec.rb b/spec/classes/sdk_spec.rb index caed826..9dd41e3 100644 --- a/spec/classes/sdk_spec.rb +++ b/spec/classes/sdk_spec.rb @@ -41,4 +41,42 @@ it { should contain_package('ia32-libs') } end + context '64bit Debian Jessie, x86_64 architecture', :compile do + let(:facts) { { + :operatingsystem => 'Debian', + :osfamily => 'Debian' + :lsbdistcodename => 'jessie' + } } + it { should_not contain_package('ia32-libs') } + end + + context '64bit Debian Jessie, amd64 architecture', :compile do + let(:facts) { { + :operatingsystem => 'Debian', + :osfamily => 'Debian', + :lsbdistcodename => 'jessie' + :architecture => 'amd64' + } } + it { should_not contain_package('ia32-libs') } + end + + context '64bit Ubuntu 14.04, x86_64 architecture', :compile do + let(:facts) { { + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian' + :lsbdistrelease => '14.04' + } } + it { should_not contain_package('ia32-libs') } + end + + context '64bit Ubuntu 14.04, amd64 architecture', :compile do + let(:facts) { { + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistrelease => '14.04' + :architecture => 'amd64' + } } + it { should_not contain_package('ia32-libs') } + end + end diff --git a/templates/expect-script.erb b/templates/expect-script.erb index e2b84f1..9e96117 100755 --- a/templates/expect-script.erb +++ b/templates/expect-script.erb @@ -1,27 +1,5 @@ -#!/usr/bin/env ruby +#!/usr/bin/env bash -require 'pty' -require 'expect' +yes | <%= scope.lookupvar('android::paths::sdk_home') %>/tools/bin/sdkmanager --install --include_obsolete '<%= @package_name %>' <%= @proxy_host %> <%= @proxy_port %> -command="<%= scope.lookupvar('android::paths::sdk_home') %>/tools/android update sdk -u --all -t <%= @title %> <%= @proxy_host %> <%= @proxy_port %>" -match=%r/^\s*Do you accept the license .* \[y\/n\]:\s*/ -response="y" - -puts command - -PTY.spawn(command) do |r,w,p| - - w.sync = true - - begin - while true do - r.expect(match) - sleep(0.1) - w.puts(response) - end - rescue Errno::EIO, PTY::ChildExited - end -end - -exit -# vim: set ts=2 sw=2 tw=0 et: +exit 0