chiark / gitweb /
Set up SDK and NDK env vars from python
[fdroidserver.git] / buildserver / cookbooks / android-sdk / recipes / default.rb
index 735ce6f2e90c70123d102b3f0088205993efe394..3d6ff562d8ffa8882b5cd47e93b0603e101763ef 100644 (file)
@@ -1,8 +1,3 @@
-%w{openjdk-6-jdk}.each do |pkg|
-  package pkg do
-    action :install
-  end
-end
 
 sdk_loc = node[:settings][:sdk_loc]
 user = node[:settings][:user]
@@ -13,10 +8,8 @@ script "setup-android-sdk" do
   user user
   cwd "/tmp"
   code "
-    wget http://dl.google.com/android/android-sdk_r21.0.1-linux.tgz
-    tar zxvf android-sdk_r21.0.1-linux.tgz
+    tar zxvf /vagrant/cache/android-sdk_r23-linux.tgz
     mv android-sdk-linux #{sdk_loc}
-    rm android-sdk_r21.0.1-linux.tgz
     #{sdk_loc}/tools/android update sdk --no-ui -t platform-tool
     #{sdk_loc}/tools/android update sdk --no-ui -t tool
   "
@@ -26,40 +19,74 @@ end
 execute "add-android-sdk-path" do
   user user
   path = "#{sdk_loc}/tools:#{sdk_loc}/platform-tools"
-  command "echo \"export PATH=\\$PATH:#{path}\" >> /home/#{user}/.bashrc"
-  not_if "grep #{sdk_loc} /home/#{user}/.bashrc"
+  command "echo \"export PATH=\\$PATH:#{path} #PATH-SDK\" >> /home/#{user}/.bsenv"
+  not_if "grep PATH-SDK /home/#{user}/.bsenv"
 end
 
-%w{android-3 android-4 android-7 android-8 android-10 android-11
-   android-12 android-13 android-14 android-15 android-16 android-17
-   extra-android-support}.each do |sdk|
+script "add_build_tools" do
+  interpreter "bash"
+  user user
+  ver = "20.0.0"
+  cwd "/tmp"
+  code "
+    if [ -f /vagrant/cache/build-tools/#{ver}.tar.gz ] ; then
+      echo Installing from cache
+      mkdir #{sdk_loc}/build-tools
+      tar -C #{sdk_loc}/build-tools -z -x -f /vagrant/cache/build-tools/#{ver}.tar.gz
+    else
+      #{sdk_loc}/tools/android update sdk --no-ui -a -t build-tools-#{ver} <<X
+y
 
-  script "add_sdk_#{sdk}" do
-    interpreter "bash"
-    user user
-    cwd "/tmp"
-    code "
-      #{sdk_loc}/tools/android update sdk --no-ui -a -t #{sdk}
-    "
-    not_if "test -d #{sdk_loc}/platforms/#{sdk}"
-  end
+X
+    fi
+       sed -i '/BTPATH/d' /home/#{user}/.bsenv
+       echo \"export PATH=\\$PATH:#{sdk_loc}/build-tools/#{ver} #BTPATH\" >> /home/#{user}/.bsenv
+  "
+  not_if "test -d #{sdk_loc}/build-tools/#{ver}"
+end
+
+script "add_platform_tools" do
+  interpreter "bash"
+  user user
+  cwd "/tmp"
+  code "
+    if [ -f /vagrant/cache/platform-tools.tar.gz ] ; then
+      echo Installing from cache
+      mkdir #{sdk_loc}/platform-tools
+      tar -C #{sdk_loc}/platform-tools -z -x -f /vagrant/cache/platform-tools.tar.gz
+    else
+      #{sdk_loc}/tools/android update sdk --no-ui -a -t platform-tools <<X
+y
 
+X
+    fi
+  "
+  not_if "test -d #{sdk_loc}/platform-tools"
 end
 
-%w{addon-google_apis-google-7 addon-google_apis-google-10 addon-google_apis-google-15 addon-google_apis-google-16 addon-google_apis-google-17}.each do |sdk|
+%w{android-3 android-4 android-5 android-6 android-7 android-8 android-9
+   android-10 android-11 android-12 android-13 android-14 android-15
+   android-16 android-17 android-18 android-19
+   extra-android-support extra-android-m2repository}.each do |sdk|
 
-  script "add_addon_#{sdk}" do
+  script "add_sdk_#{sdk}" do
     interpreter "bash"
     user user
     cwd "/tmp"
     code "
-      #{sdk_loc}/tools/android update sdk --no-ui -a -t #{sdk}
-    "
-
-    not_if "test -d #{sdk_loc}/add-ons/#{sdk}"
+      if [ -f /vagrant/cache/platforms/#{sdk}.tar.gz ] ; then
+        echo Installing from cache
+        tar -C #{sdk_loc}/platforms -z -x -f /vagrant/cache/platforms/#{sdk}.tar.gz
+      else
+        echo Installing via 'android'
+        #{sdk_loc}/tools/android update sdk --no-ui -a -t #{sdk} <<X
+y
 
+X
+      fi
+    "
+    not_if "test -d #{sdk_loc}/platforms/#{sdk}"
   end
 
 end
 
-