chiark / gitweb /
Cache main sdk/ndk downloads
authorCiaran Gultnieks <ciaran@ciarang.com>
Sat, 25 May 2013 12:55:16 +0000 (13:55 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Sat, 25 May 2013 12:55:16 +0000 (13:55 +0100)
buildserver/cookbooks/android-ndk/recipes/default.rb
buildserver/cookbooks/android-sdk/recipes/default.rb
makebuildserver.py

index 8fdb65a72043793033814c4b0acb591103647e57..42f1de1d7560977222713d2fb78eb4795a8695dc 100644 (file)
@@ -7,8 +7,7 @@ script "setup-android-ndk" do
   user node[:settings][:user]
   cwd "/tmp"
   code "
-    wget http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2
-    tar jxvf android-ndk-r8e-linux-x86.tar.bz2
+    tar jxvf /vagrant/cache/android-ndk-r8e-linux-x64.tar.bz2
     mv android-ndk-r8e #{ndk_loc}
   "
   not_if do
index 735ce6f2e90c70123d102b3f0088205993efe394..a89f2b1f1adbf1b150a731a5642f61e775133ad2 100644 (file)
@@ -13,10 +13,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_r21.0.1-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
   "
index 09ef8ef45503ceb666fde38be94485f840bd964f..cfaa39ebeeb29ba8142215da1c51255eb9d1d461 100755 (executable)
@@ -21,6 +21,36 @@ if not os.path.exists('makebuildserver.py') or not os.path.exists(serverdir):
 if os.path.exists(boxfile):
     os.remove(boxfile)
 
+
+# Update cached files.
+cachedir = os.path.join('buildserver', 'cache')
+if not os.path.exists(cachedir):
+    os.mkdir(cachedir)
+cachefiles = [
+    ('android-sdk_r21.0.1-linux.tgz',
+     'http://dl.google.com/android/android-sdk_r21.0.1-linux.tgz',
+     'cookbooks/recipes/android-sdk/default.rb'),
+    ('android-ndk-r8e-linux-x64.tar.bz2',
+     'http://dl.google.com/android/ndk/android-ndk-r8e-linux-x64.tar.bz2',
+     'cookbooks/recipes/android-ndk/default.rb')
+    ]
+wanted = []
+for f, src, check in cachefiles:
+    if subprocess.call('grep ' + f + ' ' + check) != 0:
+        print "Cache mismatch - " + f + " is not mentioned in " + check
+        sys.exit(1)
+    if not os.path.exists(os.path.join(cachedir, f)):
+        print "Downloading " + f + " to cache"
+        if subprocess.call('wget ' + src, cwd=cachedir) != 0:
+            print "...download of " + f + " failed."
+            sys.exit(1)
+    wanted.append(f)
+for f in os.listdir(cachedir):
+    if not f in wanted:
+        print "Removing unwanted cache file " + f
+        os.remove(os.path.join(cachedir, f))
+
+
 vagrant(['halt'], serverdir)
 print "Configuring build server VM"
 returncode, out, err = vagrant(['up'], serverdir)