From f922e82bb50ced1f1900b936b8d78e50729a3d23 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:30:38 +0100 Subject: [PATCH 01/10] Add new specs for Debian Jessie and Ubuntu 14.04. --- spec/classes/sdk_spec.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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 From 668545717e4376c8b2ff660e37f0ec4c5cd06802 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:30:42 +0100 Subject: [PATCH 02/10] Change the way NDK is downloaded. --- manifests/ndk.pp | 5 +++-- manifests/params.pp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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/params.pp b/manifests/params.pp index f8cef6f..165c7a7 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,7 +17,7 @@ $proxy_port = undef $installdir = '/usr/local/android' - $ndk_version = 'android-ndk-r10d-linux-x86_64.bin' + $ndk_version = 'r18b' case $::kernel { 'Linux': { From 2fa28100d369a6b71931289e68c9e67ac97ffcc1 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:30:46 +0100 Subject: [PATCH 03/10] Change the way the sdk package is downloaded from google. --- manifests/params.pp | 2 +- manifests/paths.pp | 8 ++++---- manifests/sdk.pp | 21 ++++++++------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 165c7a7..f8cb9c1 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -12,7 +12,7 @@ # class android::params { - $version = '22.3' + $version = '4333796' $proxy_host = undef $proxy_port = undef $installdir = '/usr/local/android' 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..31962ab 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, From f7aac22df7a3b42ef36893175658155a46b8fa7a Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:30:49 +0100 Subject: [PATCH 04/10] Use dedicated variable to prevent duplicating package name type in resource title. --- manifests/package.pp | 6 ++++++ templates/expect-script.erb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index 35f24cd..99a4a65 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -28,24 +28,30 @@ case $type { 'platform-tools': { $creates = "${android::paths::sdk_home}/platform-tools" + $package_name = $title } 'platform': { $creates = "${android::paths::sdk_home}/platforms/${title}" + $package_name = $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]}" + $package_name = "${type};${title}" } 'addon': { $creates = "${android::paths::sdk_home}/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]}" + $package_name = "extras;${title}" } 'build-tools': { $title_parts = split($title, '-') $creates = "${android::paths::sdk_home}/build-tools/${title_parts[2]}" + $package_name = "${type};${title}" } default: { fail("Unsupported package type: ${type}") diff --git a/templates/expect-script.erb b/templates/expect-script.erb index e2b84f1..7c99394 100755 --- a/templates/expect-script.erb +++ b/templates/expect-script.erb @@ -3,7 +3,7 @@ require 'pty' require 'expect' -command="<%= scope.lookupvar('android::paths::sdk_home') %>/tools/android update sdk -u --all -t <%= @title %> <%= @proxy_host %> <%= @proxy_port %>" +command="<%= scope.lookupvar('android::paths::sdk_home') %>/tools/android update sdk -u --all -t <%= @package_name %> <%= @proxy_host %> <%= @proxy_port %>" match=%r/^\s*Do you accept the license .* \[y\/n\]:\s*/ response="y" From 5fc6112a2b822c44536d25797b00944055067595 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:30:53 +0100 Subject: [PATCH 05/10] Use sdkmanager command in command template. --- templates/expect-script.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/expect-script.erb b/templates/expect-script.erb index 7c99394..0d55e2a 100755 --- a/templates/expect-script.erb +++ b/templates/expect-script.erb @@ -3,8 +3,8 @@ require 'pty' require 'expect' -command="<%= scope.lookupvar('android::paths::sdk_home') %>/tools/android update sdk -u --all -t <%= @package_name %> <%= @proxy_host %> <%= @proxy_port %>" -match=%r/^\s*Do you accept the license .* \[y\/n\]:\s*/ +command="<%= scope.lookupvar('android::paths::sdk_home') %>/tools/bin/sdkmanager --update -u --include_obsolete -t <%= @package_name %> <%= @proxy_host %> <%= @proxy_port %>" +match=%r/^\s*Accept? .* \(y\/N\):\s*/ response="y" puts command From d95a2b057e1d629ba5785f2ee4fc633db4e41521 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:30:57 +0100 Subject: [PATCH 06/10] Update the way package installations are handled. --- manifests/package.pp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/manifests/package.pp b/manifests/package.pp index 99a4a65..742c47f 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -24,33 +24,33 @@ $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}" - $package_name = $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: { @@ -58,13 +58,13 @@ } } - 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']], } From c38c4d2f36bc4d31e7206e5cf0e749dee3c5412a Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 17:31:00 +0100 Subject: [PATCH 07/10] Change sdkmanager installation script to work with bash and the 'yes' command. --- templates/expect-script.erb | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/templates/expect-script.erb b/templates/expect-script.erb index 0d55e2a..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/bin/sdkmanager --update -u --include_obsolete -t <%= @package_name %> <%= @proxy_host %> <%= @proxy_port %>" -match=%r/^\s*Accept? .* \(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 From 964968f02420ca766aee32391bd1921514b80fd9 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 18:55:06 +0100 Subject: [PATCH 08/10] Do not install deprecated packages for Debian stretch. --- manifests/sdk.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/sdk.pp b/manifests/sdk.pp index 31962ab..ddae3ea 100644 --- a/manifests/sdk.pp +++ b/manifests/sdk.pp @@ -51,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 $::lsbdistrelease == 'jessie' or $::lsbdistrelease == 'stretch' or $::lsbdistrelease == 14.04 { ensure_packages(['libc6-i386', 'lib32stdc++6', 'lib32gcc1', 'lib32ncurses5', 'lib32z1']) } else { ensure_packages($::osfamily ? { From 6e8367f6728fc933282885d5ad36ce52c6e56791 Mon Sep 17 00:00:00 2001 From: func0der Date: Thu, 6 Dec 2018 18:57:27 +0100 Subject: [PATCH 09/10] Fix wrong usage of lsbdistrelease. --- manifests/sdk.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/sdk.pp b/manifests/sdk.pp index ddae3ea..0046045 100644 --- a/manifests/sdk.pp +++ b/manifests/sdk.pp @@ -51,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 $::lsbdistrelease == 'jessie' or $::lsbdistrelease == 'stretch' 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 ? { From 4ebfa498e69e4a90cd5f02527d28206f81f13483 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 7 Feb 2019 18:06:39 +0100 Subject: [PATCH 10/10] Change dependency to puppet/wget --- metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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",