Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Add package revision parameter, fix NDK install, check package exists #45

Closed
wants to merge 11 commits into from
110 changes: 74 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,128 @@
Puppet Module for Android SDK
=============================
Puppet Module for Android SDK and NDK
=====================================

[![Build Status](https://maestro.maestrodev.com/api/v1/projects/58/compositions/443/badge/icon)](https://maestro.maestrodev.com/projects/58/compositions/443)

This Puppet module is used to install the Android SDK and NDK,
along with platforms and other add-ons.
You may need to install Java separately.
This Puppet module is used to install the Android SDK and NDK, along with
add-ons, build-tools, extras, platforms, and system images. You may need to
install Java separately.

Supported platforms:

* Linux (RedHat, Debian families)
* Mac OS X
* OS X (requires `wget` to be installed)

Examples
--------

To install the Android SDK in the default location (/usr/local/android on both Linux
and Mac OS X) you simply include the android class like so.
To install the Android SDK and platform tools in the default location
(`/usr/local/android` on both Linux and OS X) you simply include the `android`
class like so:

class { 'java': } ->
class { 'android': }
```
class { 'java': } ->
class { 'android': }
```

You can also change the default parameters like so:

```
class { 'android':
user => 'someuser',
group => 'somegroup',
installdir => '/path/to/your/dir',
}
class { 'android':
user => 'someuser',
group => 'somegroup',
installdir => '/path/to/your/dir',
}
```

You can install the Android NDK like so:

```
class { 'android::ndk' :
class { 'android::ndk':
ndk_version => 'android-ndk-r10c-linux-x86_64.bin'
}
```

Note that the NDK is downloaded and executed, so only newer NDK versions are supported. The older tar archives will not work properly.
Note that the Android NDK is downloaded and executed, so only newer NDK
versions are supported. The older tar archives will not work properly.

To install an android platform, do it like so:
To install an Android Platform, do it like so:

```
android::platform { 'android-16': }
android::platform { 'android-16': }
```

You can also install add-ons:

```
android::addon { 'addon-google_apis-google-16': }
android::addon { 'addon-google_apis-google-16': }
```

Or extras:

```
android::extra { 'extra-google-play_billing': }
```

Or extra's:
Or system images:

```
android::extra { 'extra-google-play_billing': }
android::system_images { 'sys-img-armeabi-v7a-android-23': }
```

To install Android SDK Build-tools, revision 19.0.1
To install the Android SDK Build-tools, revision 19.0.1:

```
android::build_tools { 'build-tools-19.0.1': }
android::build_tools { 'build-tools-19.0.1': }
```

Tip: to get the appropriate name of the add-ons/extras run the following command:
For add-ons, extras, platforms, and system images, the revision number can be
specified using the optional `revision` parameter:

```
/usr/local/android/android-sdk-macosx/tools/android list sdk -u --all --extended|grep " or "
android::extra { 'extra-google-m2repository':
revision => '24',
}
```

The add-on, extra, platform, or system image will only be upgraded only if the
installed revision is not equal to the specified revision. For build-tools, the
revision number forms part of the name of the build-tool, hence there is no
`revision` parameter.

The `revision` parameter can also take the value `present` that initially
installs the latest version of the add-on, extra, platform, or system image, but
does not upgrade it when a new version becomes available, and the value `latest`
that always upgrades the add-on, extra, platform, or system image to the latest
version:

```
android::extra { 'extra-android-m2repository':
revision => latest,
}
```

Tip: To get the appropriate name of the add-on, extra, platform, or system
image, run the following command:

```
android list sdk --all --extended --no-ui | grep " or "
```

License
-------

```
Copyright 2012-2014 MaestroDev
Copyright 2012-2016 MaestroDev

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
20 changes: 16 additions & 4 deletions manifests/addon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
#
# Installs an Android SDK add-on package.
#
# === Examples
#
# To install an add-on package:
# android::addon { 'addon-google_apis-google-16': }
#
# === Parameters
#
# [*revision*] The revision number of the specified add-on package or a value of
# 'latest' or 'present'
#
# === Authors
#
# Etienne Pelletier <[email protected]>
Expand All @@ -10,10 +20,12 @@
#
# Copyright 2012 MaestroDev, unless otherwise noted.
#
define android::addon() {
define android::addon(
$revision = 'present',
) {

android::package{ $title:
type => 'addon',
android::package { $title:
revision => $revision,
type => 'addon',
}

}
14 changes: 9 additions & 5 deletions manifests/build_tools.pp
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# == Class: android::build_tools
# == Define: android::build_tools
#
# Installs the Android SDK build-tools.
# Installs an Android SDK build-tools package.
#
# === Examples
#
# To install a build-tools package:
# android::build_tools { 'build-tools-19.0.1': }
#
# === Authors
#
# Philip Schiffer <[email protected]>
#
# === Copyright
#
# Copyright 2013 Philip Schiffer
# Copyright 2013 Philip Schiffer.
#
define android::build_tools() {

android::package{ $title:
android::package { $title:
type => 'build-tools',
}

}
22 changes: 17 additions & 5 deletions manifests/extra.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# == Define: android::extra
#
# Installs an Android SDK "extra's" package.
# Installs an Android SDK extra package.
#
# === Examples
#
# To install an extra package:
# android::extra { 'extra-google-play_billing': }
#
# === Parameters
#
# [*revision*] The revision number of the specified extra package or a value of
# 'latest' or 'present'
#
# === Authors
#
Expand All @@ -10,10 +20,12 @@
#
# Copyright 2012 MaestroDev, unless otherwise noted.
#
define android::extra() {
define android::extra(
$revision = 'present',
) {

android::package{ $title:
type => 'extra',
android::package { $title:
revision => $revision,
type => 'extra',
}

}
42 changes: 33 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# == Class: android
#
# This class is used to install the android SDK and platform tools
# This class is used to install the Android SDK and platform tools.
#
# === Parameters:
# === Examples
#
# [*version*] the SDK version
# [*user*] used to set the file ownership of the installed SDK
# [*group*] used to set the file ownership of the installed SDK
# [*installdir*] the install directory.
# [*proxy_host*] the proxy server host name (used by the android tool)
# [*proxy_port*] the proxy server port (used by the android tool)
# To install the Android SDK:
# class { 'java': } ->
# class { 'android':
# user => 'someuser',
# group => 'somegroup',
# installdir => '/path/to/your/dir',
# }
#
# === Parameters
#
# [*version*] The SDK version
# [*user*] Used to set the file ownership of the installed SDK
# [*group*] Used to set the file ownership of the installed SDK
# [*installdir*] The install directory
# [*proxy_host*] The proxy server host name (used by the 'android' tool)
# [*proxy_port*] The proxy server port (used by the 'android' tool)
#
# === Authors
#
Expand All @@ -25,7 +35,21 @@
$group = $android::params::group,
$installdir = $android::params::installdir,
$proxy_host = $android::params::proxy_host,
$proxy_port = $android::params::proxy_port) inherits android::params {
$proxy_port = $android::params::proxy_port,
) inherits android::params {

validate_re($version, '^\d+(?:\.\d+)*$', "Invalid version: ${version}")
validate_string($user)
validate_string($group)
validate_absolute_path($installdir)

if ($proxy_host != undef) {
validate_string($proxy_host, '^\d+$')
}

if ($proxy_port != undef) {
validate_re($proxy_port, '^\d+$', "Invalid proxy port: ${proxy_port}")
}

anchor { 'android::begin': } ->
class { 'android::paths': } ->
Expand Down
35 changes: 27 additions & 8 deletions manifests/ndk.pp
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# == Class: android::ndk
#
# This downloads and unpacks the Android NDK from Google's download
# sever, or another specified server.
# server, or another specified server.
#
# Note that the NDK is expected to be a self extracting, so the
# older .tar.gz packages that are simply extracted will not be supported.
# Note that the NDK is expected to be a self extracting, so the older '.tar.gz'
# packages that are simply extracted will not be supported.
#
# === Examples
#
# To install the Android NDK r10c-linux-x86_64:
# class { 'android::ndk':
# ndk_version => 'android-ndk-r10c-linux-x86_64.bin'
# }
#
# === Parameters
#
# [*ndk_version*] The NDK version and architecture to install
#
# === Authors
#
Expand All @@ -15,28 +26,36 @@
# Copyright 2015 Sam Kerr, unless otherwise noted.
#
class android::ndk(
$ndk_version = $android::params::ndk_version
)
{
$ndk_version = $android::params::ndk_version,
) {

validate_re($ndk_version, '\.bin$')

include android::paths
include android::params
include wget

if ( $::id == 'root' ) {
Exec { user => $android::user }
}

$base_path = "http://dl.google.com/android/ndk/${ndk_version}"
$ndk_installer = "${android::paths::installdir}/${ndk_version}"

wget::fetch { 'download-androidndk':
source => $base_path,
destination => $ndk_installer,
} ->
file { 'android-ndkexecutable':
ensure => present,
ensure => file,
path => $ndk_installer,
owner => $android::user,
group => $android::group,
mode => '0755',
} ->
exec { 'run-androidndk':
command => "${ndk_installer} -y",
creates => regsubst($ndk_installer, '^(.*)\.bin$','\1'),
cwd => $android::params::installdir,
}

}
Loading