2016-01-04 16:33:20 +01:00
|
|
|
#!/usr/bin/env python3
|
2012-09-24 15:04:58 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import time
|
2014-01-10 19:54:53 +01:00
|
|
|
import hashlib
|
2013-10-20 22:16:42 +02:00
|
|
|
from optparse import OptionParser
|
2013-05-31 08:48:39 +02:00
|
|
|
|
2014-05-07 16:13:22 +02:00
|
|
|
|
2013-05-31 08:48:39 +02:00
|
|
|
def vagrant(params, cwd=None, printout=False):
|
|
|
|
"""Run vagrant.
|
|
|
|
|
|
|
|
:param: list of parameters to pass to vagrant
|
|
|
|
:cwd: directory to run in, or None for current directory
|
|
|
|
:printout: True to print output in realtime, False to just
|
|
|
|
return it
|
|
|
|
:returns: (ret, out) where ret is the return code, and out
|
|
|
|
is the stdout (and stderr) from vagrant
|
|
|
|
"""
|
2012-09-24 15:04:58 +02:00
|
|
|
p = subprocess.Popen(['vagrant'] + params, cwd=cwd,
|
2014-05-07 16:13:22 +02:00
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
2013-05-31 08:48:39 +02:00
|
|
|
out = ''
|
|
|
|
if printout:
|
|
|
|
while True:
|
|
|
|
line = p.stdout.readline()
|
|
|
|
if len(line) == 0:
|
|
|
|
break
|
2016-01-04 17:24:57 +01:00
|
|
|
print(line)
|
2013-05-31 08:48:39 +02:00
|
|
|
out += line
|
|
|
|
p.wait()
|
|
|
|
else:
|
|
|
|
out = p.communicate()[0]
|
|
|
|
return (p.returncode, out)
|
2012-09-24 15:04:58 +02:00
|
|
|
|
|
|
|
boxfile = 'buildserver.box'
|
|
|
|
serverdir = 'buildserver'
|
|
|
|
|
2013-10-20 22:16:42 +02:00
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
2014-05-07 16:13:22 +02:00
|
|
|
help="Spew out even more information than normal")
|
2013-10-20 22:16:42 +02:00
|
|
|
parser.add_option("-c", "--clean", action="store_true", default=False,
|
2014-05-07 16:13:22 +02:00
|
|
|
help="Build from scratch, rather than attempting to update the existing server")
|
2013-10-20 22:16:42 +02:00
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
2016-01-20 21:00:16 +01:00
|
|
|
# set up default config
|
2016-01-22 13:33:14 +01:00
|
|
|
cachedir = os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver')
|
2016-01-20 21:00:16 +01:00
|
|
|
config = {
|
|
|
|
'arch64': False,
|
|
|
|
'basebox': 'jessie32',
|
2016-01-22 13:33:14 +01:00
|
|
|
# TODO in py3, convert this to pathlib.Path(absolute_path_string).as_uri()
|
|
|
|
'baseboxurl': [
|
|
|
|
'file://' + os.path.join(cachedir, 'jessie32.box'),
|
|
|
|
'https://f-droid.org/jessie32.box',
|
|
|
|
],
|
2016-01-26 13:33:53 +01:00
|
|
|
'debian_mirror': 'http://http.debian.net/debian/',
|
2016-01-26 11:21:21 +01:00
|
|
|
'apt_package_cache': False,
|
2016-01-26 17:35:25 +01:00
|
|
|
'boot_timeout': 600,
|
2016-01-22 13:33:14 +01:00
|
|
|
'cachedir': cachedir,
|
2016-01-20 21:00:16 +01:00
|
|
|
'cpus': 1,
|
2016-01-28 13:00:18 +01:00
|
|
|
'memory': 1024,
|
2016-01-20 21:00:16 +01:00
|
|
|
}
|
2016-01-20 20:38:18 +01:00
|
|
|
|
|
|
|
# load config file, if present
|
|
|
|
if os.path.exists('makebuildserver.config.py'):
|
2016-01-04 17:24:57 +01:00
|
|
|
exec(compile(open('makebuildserver.config.py').read(), 'makebuildserver.config.py', 'exec'), config)
|
2016-01-20 20:38:18 +01:00
|
|
|
elif os.path.exists('makebs.config.py'):
|
|
|
|
# this is the old name for the config file
|
2016-01-04 17:24:57 +01:00
|
|
|
exec(compile(open('makebs.config.py').read(), 'makebs.config.py', 'exec'), config)
|
2013-10-20 22:16:42 +02:00
|
|
|
|
2013-12-30 17:18:45 +01:00
|
|
|
if not os.path.exists('makebuildserver') or not os.path.exists(serverdir):
|
2016-01-04 17:24:57 +01:00
|
|
|
print('This must be run from the correct directory!')
|
2012-09-24 15:04:58 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if os.path.exists(boxfile):
|
|
|
|
os.remove(boxfile)
|
|
|
|
|
2013-10-20 22:16:42 +02:00
|
|
|
if options.clean:
|
|
|
|
vagrant(['destroy', '-f'], cwd=serverdir, printout=options.verbose)
|
2013-05-25 14:55:16 +02:00
|
|
|
|
|
|
|
# Update cached files.
|
2016-01-21 14:09:12 +01:00
|
|
|
cachedir = config['cachedir']
|
2013-05-25 14:55:16 +02:00
|
|
|
if not os.path.exists(cachedir):
|
2016-01-04 17:24:57 +01:00
|
|
|
os.makedirs(cachedir, 0o755)
|
2014-05-31 23:00:27 +02:00
|
|
|
|
2013-05-25 14:55:16 +02:00
|
|
|
cachefiles = [
|
2015-10-24 19:02:14 +02:00
|
|
|
('android-sdk_r24.4.1-linux.tgz',
|
|
|
|
'https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz',
|
|
|
|
'e16917ad685c1563ccbc5dd782930ee1a700a1b6a6fd3e44b83ac694650435e9'),
|
2015-11-20 15:43:47 +01:00
|
|
|
('android-platform-3.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-1.5_r04-linux.zip',
|
|
|
|
'85b6c8f9797e56aa415d3a282428bb640c96b0acb17c11d41621bb2a5302fe64'),
|
|
|
|
('android-platform-4.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-1.6_r03-linux.zip',
|
|
|
|
'a8c4e3b32269c6b04c2adeabd112fce42f292dab1a40ef3b08ea7d4212be0df4'),
|
|
|
|
('android-platform-5.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-2.0_r01-linux.zip',
|
|
|
|
'e70e2151b49613f23f40828c771ab85e241eed361cab037c6312df77f2612f0a'),
|
|
|
|
('android-platform-6.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-2.0.1_r01-linux.zip',
|
|
|
|
'f47b46177b17f6368461f85bc2a27d0d2c437929f588ea27105712bc3185f664'),
|
|
|
|
('android-platform-7.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-2.1_r03-linux.zip',
|
|
|
|
'b9cc140a9b879586181b22cfc7d4aa18b979251e16e9b17771c5d0acb71ba940'),
|
|
|
|
('android-platform-8.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-2.2_r03-linux.zip',
|
|
|
|
'7c9ea1bd7cb225504bd085d7c93ae27d52bd88d29b621d28108f82fef68177c0'),
|
|
|
|
('android-platform-9.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-2.3.1_r02-linux.zip',
|
|
|
|
'b2ab4896d0a4857e4f688f69eb08b0e1a8074709d4445a92a83ece7ec7cd198c'),
|
|
|
|
('android-platform-10.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-2.3.3_r02-linux.zip',
|
|
|
|
'54bdb0f1ca06ba5747061ddeea20f431af72c448334fd4d3d7f84ea2ccd29fea'),
|
|
|
|
('android-platform-11.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-3.0_r02-linux.zip',
|
|
|
|
'1cacae7b6e1b5a5d73c06f5d29d2ea92d16674df8fd5507681290e77d1647a1c'),
|
|
|
|
('android-platform-12.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-3.1_r03-linux.zip',
|
|
|
|
'7570c86a86488a146aa2141a65a24d81800959c1907ff4f1d2c13bbafab230c5'),
|
|
|
|
('android-platform-13.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-3.2_r01-linux.zip',
|
|
|
|
'ff6b26ad34d7060a72ba504b0314cef8ba3138005561705adec5ad470a073d9b'),
|
|
|
|
('android-platform-14.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-14_r04.zip',
|
|
|
|
'da1af15c77ba41d062eb6d0ef5921cc424ab6167587033b830609d65f04802b6'),
|
|
|
|
('android-platform-15.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-15_r05.zip',
|
|
|
|
'5bc1f93aae86b4336ffc4cae9eb8ec41a9a8fd677582dd86a9629798f019bed9'),
|
|
|
|
('android-platform-16.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-16_r05.zip',
|
|
|
|
'fd7f269a423d1f1d079eabf9f918ceab49108702a1c6bb2589d57c23393503d3'),
|
|
|
|
('android-platform-17.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-17_r03.zip',
|
|
|
|
'b66e73fb2639f8c916fde4369aa29012a5c531e156dbb205fe3788fe998fbbe8'),
|
|
|
|
('android-platform-18.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-18_r03.zip',
|
|
|
|
'166ae9cf299747a5faa8f04168f0ee47cd7466a975d8b44acaaa62a43e767568'),
|
|
|
|
('android-platform-19.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-19_r04.zip',
|
|
|
|
'5efc3a3a682c1d49128daddb6716c433edf16e63349f32959b6207524ac04039'),
|
|
|
|
('android-platform-20.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-20_r02.zip',
|
|
|
|
'ef08c453e16ab6e656cf5d9413ef61cb8c650607d33b24ee4ce08dafdfe965a7'),
|
|
|
|
('android-platform-21.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-21_r02.zip',
|
|
|
|
'a76cd7ad3080ac6ce9f037cb935b399a1bad396c0605d4ff42f693695f1dcefe'),
|
|
|
|
('android-platform-22.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-22_r02.zip',
|
|
|
|
'45eb581bbe53c9256f34c26b2cea919543c0079140897ac721cf88c0b9f6789e'),
|
|
|
|
('android-platform-23.zip',
|
|
|
|
'https://dl.google.com/android/repository/android-23_r01.zip',
|
|
|
|
'16e828bec35521f5529c998a6d312aaa6155cd4aabb5507d9eb2d4b3c9a1aff0'),
|
2015-11-20 21:14:08 +01:00
|
|
|
('build-tools-17.0.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r17-linux.zip',
|
|
|
|
'4c8444972343a19045236f6924bd7f12046287c70dace96ab88b2159c8ec0e74'),
|
|
|
|
('build-tools-18.0.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r18.0.1-linux.zip',
|
|
|
|
'a9b7b1bdfd864780fdd03fa1683f3fe712a4276cf200646833808cb9159bafc0'),
|
|
|
|
('build-tools-18.1.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r18.1-linux.zip',
|
|
|
|
'0753606738f31cc346426db1d46b7d021bc1bdaff63085f9ee9d278ee054d3c9'),
|
|
|
|
('build-tools-18.1.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r18.1.1-linux.zip',
|
|
|
|
'7e4ed326b53078f4f23276ddab52c400011f7593dfbb6508c0a6671954dba8b0'),
|
|
|
|
('build-tools-19.0.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r19-linux.zip',
|
|
|
|
'9442e1c5212ed594e344a231fa93e7a017a5ef8cc661117011f1d3142eca7acc'),
|
|
|
|
('build-tools-19.0.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r19.0.1-linux.zip',
|
|
|
|
'b068edaff05c3253a63e9c8f0e1786429799b7e4b01514a847a8b291beb9232e'),
|
|
|
|
('build-tools-19.0.2.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r19.0.2-linux.zip',
|
|
|
|
'06124fad0d4bde21191240d61df2059a8546c085064a9a57d024c36fa2c9bebb'),
|
|
|
|
('build-tools-19.0.3.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r19.0.3-linux.zip',
|
|
|
|
'bc9b3db0de4a3e233a170274293359051a758f1e3f0d0d852ff4ad6d90d0a794'),
|
|
|
|
('build-tools-19.1.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r19.1-linux.zip',
|
|
|
|
'3833b409f78c002a83244e220be380ea6fa44d604e0d47de4b7e5daefe7cd3f4'),
|
|
|
|
('build-tools-20.0.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r20-linux.zip',
|
|
|
|
'296e09d62095d80e6eaa06a64cfa4c6f9f317c2d67ad8da6514523ec66f5c871'),
|
|
|
|
('build-tools-21.0.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r21-linux.zip',
|
|
|
|
'12b818f38fe1b68091b94545988317438efbf41eb61fd36b72cd79f536044065'),
|
|
|
|
('build-tools-21.0.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r21.0.1-linux.zip',
|
|
|
|
'a8922e80d3dd0cf6df14b29a7862448fa111b48086c639168d4b18c92431f559'),
|
|
|
|
('build-tools-21.0.2.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r21.0.2-linux.zip',
|
|
|
|
'859b17a6b65d063dfd86c163489b736b12bdeecd9173fdddb3e9f32e0fe584b7'),
|
|
|
|
('build-tools-21.1.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r21.1-linux.zip',
|
|
|
|
'022a85b92360272379b2f04b8a4d727e754dbe7eb8ab5a9568190e33e480d8f1'),
|
|
|
|
('build-tools-21.1.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r21.1.1-linux.zip',
|
|
|
|
'29b612484de6b5cde0df6de655e413f7611b0557b440538397afa69b557e2f08'),
|
|
|
|
('build-tools-21.1.2.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r21.1.2-linux.zip',
|
|
|
|
'3f88efc2d5316fb73f547f35b472610eed5e6f3f56762750ddad1c7d1d81660d'),
|
|
|
|
('build-tools-22.0.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r22-linux.zip',
|
|
|
|
'061c021243f04c80c19568a6e3a027c00d8e269c9311d7bf07fced60fbde7bd5'),
|
|
|
|
('build-tools-22.0.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r22.0.1-linux.zip',
|
|
|
|
'91e5524bf227aad1135ddd10905518ac49f74797d33d48920dcf8364b9fde214'),
|
|
|
|
('build-tools-23.0.0.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r23-linux.zip',
|
|
|
|
'56bf4fc6c43638c55fef4a0937bad38281945725459841879b436c6922df786c'),
|
|
|
|
('build-tools-23.0.1.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r23.0.1-linux.zip',
|
|
|
|
'e56b3ef7b760ad06a7cee9b2d52ba7f43133dcecedfa5357f8845b3a80aeeecf'),
|
|
|
|
('build-tools-23.0.2.zip',
|
|
|
|
'https://dl.google.com/android/repository/build-tools_r23.0.2-linux.zip',
|
|
|
|
'82754f551a6e36eaf516fbdd00c95ff0ccd19f81d1e134125b6ac4916f7ed9b6'),
|
2016-01-20 20:38:18 +01:00
|
|
|
# the binaries that Google uses are here:
|
|
|
|
# https://android.googlesource.com/platform/tools/external/gradle/+/studio-1.5/
|
2014-01-09 15:44:58 +01:00
|
|
|
('gradle-1.4-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.4-bin.zip',
|
2014-01-09 15:44:58 +01:00
|
|
|
'cd99e85fbcd0ae8b99e81c9992a2f10cceb7b5f009c3720ef3a0078f4f92e94e'),
|
|
|
|
('gradle-1.6-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.6-bin.zip',
|
2014-01-09 15:44:58 +01:00
|
|
|
'de3e89d2113923dcc2e0def62d69be0947ceac910abd38b75ec333230183fac4'),
|
|
|
|
('gradle-1.7-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.7-bin.zip',
|
2014-01-09 15:44:58 +01:00
|
|
|
'360c97d51621b5a1ecf66748c718594e5f790ae4fbc1499543e0c006033c9d30'),
|
|
|
|
('gradle-1.8-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.8-bin.zip',
|
2014-01-09 15:44:58 +01:00
|
|
|
'a342bbfa15fd18e2482287da4959588f45a41b60910970a16e6d97959aea5703'),
|
2013-12-22 13:22:45 +01:00
|
|
|
('gradle-1.9-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.9-bin.zip',
|
2013-12-22 13:22:45 +01:00
|
|
|
'097ddc2bcbc9da2bb08cbf6bf8079585e35ad088bafd42e8716bc96405db98e9'),
|
2014-01-27 13:21:44 +01:00
|
|
|
('gradle-1.10-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.10-bin.zip',
|
2014-01-27 13:21:44 +01:00
|
|
|
'6e6db4fc595f27ceda059d23693b6f6848583950606112b37dfd0e97a0a0a4fe'),
|
2014-03-07 15:21:18 +01:00
|
|
|
('gradle-1.11-bin.zip',
|
2014-05-20 16:40:43 +02:00
|
|
|
'https://services.gradle.org/distributions/gradle-1.11-bin.zip',
|
2014-03-07 15:21:18 +01:00
|
|
|
'07e235df824964f0e19e73ea2327ce345c44bcd06d44a0123d29ab287fc34091'),
|
2014-05-20 16:40:43 +02:00
|
|
|
('gradle-1.12-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-1.12-bin.zip',
|
|
|
|
'8734b13a401f4311ee418173ed6ca8662d2b0a535be8ff2a43ecb1c13cd406ea'),
|
2014-10-07 16:36:10 +02:00
|
|
|
('gradle-2.1-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.1-bin.zip',
|
|
|
|
'3eee4f9ea2ab0221b89f8e4747a96d4554d00ae46d8d633f11cfda60988bf878'),
|
2014-12-12 12:29:16 +01:00
|
|
|
('gradle-2.2.1-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.2.1-bin.zip',
|
|
|
|
'420aa50738299327b611c10b8304b749e8d3a579407ee9e755b15921d95ff418'),
|
2015-04-09 16:02:35 +02:00
|
|
|
('gradle-2.3-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.3-bin.zip',
|
|
|
|
'010dd9f31849abc3d5644e282943b1c1c355f8e2635c5789833979ce590a3774'),
|
2015-06-18 16:57:00 +02:00
|
|
|
('gradle-2.4-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.4-bin.zip',
|
|
|
|
'c4eaecc621a81f567ded1aede4a5ddb281cc02a03a6a87c4f5502add8fc2f16f'),
|
2015-08-13 20:28:01 +02:00
|
|
|
('gradle-2.5-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.5-bin.zip',
|
|
|
|
'3f953e0cb14bb3f9ebbe11946e84071547bf5dfd575d90cfe9cc4e788da38555'),
|
2015-08-18 22:40:21 +02:00
|
|
|
('gradle-2.6-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.6-bin.zip',
|
|
|
|
'18a98c560af231dfa0d3f8e0802c20103ae986f12428bb0a6f5396e8f14e9c83'),
|
2015-10-05 23:40:19 +02:00
|
|
|
('gradle-2.7-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.7-bin.zip',
|
2015-10-08 15:16:16 +02:00
|
|
|
'cde43b90945b5304c43ee36e58aab4cc6fb3a3d5f9bd9449bb1709a68371cb06'),
|
2015-10-24 19:05:21 +02:00
|
|
|
('gradle-2.8-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.8-bin.zip',
|
2015-10-25 10:48:17 +01:00
|
|
|
'a88db9c2f104defdaa8011c58cf6cda6c114298ae3695ecfb8beb30da3a903cb'),
|
2015-11-20 21:24:07 +01:00
|
|
|
('gradle-2.9-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.9-bin.zip',
|
|
|
|
'c9159ec4362284c0a38d73237e224deae6139cbde0db4f0f44e1c7691dd3de2f'),
|
2016-01-05 09:15:54 +01:00
|
|
|
('gradle-2.10-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.10-bin.zip',
|
|
|
|
'66406247f745fc6f05ab382d3f8d3e120c339f34ef54b86f6dc5f6efc18fbb13'),
|
2016-02-15 12:44:07 +01:00
|
|
|
('gradle-2.11-bin.zip',
|
|
|
|
'https://services.gradle.org/distributions/gradle-2.11-bin.zip',
|
|
|
|
'8d7437082356c9fd6309a4479c8db307673965546daea445c6c72759cd6b1ed6'),
|
2013-11-24 23:11:02 +01:00
|
|
|
('Kivy-1.7.2.tar.gz',
|
2014-01-31 02:33:37 +01:00
|
|
|
'https://pypi.python.org/packages/source/K/Kivy/Kivy-1.7.2.tar.gz',
|
2014-10-07 16:36:10 +02:00
|
|
|
'0485e2ef97b5086df886eb01f8303cb542183d2d71a159466f99ad6c8a1d03f1'),
|
2014-12-31 16:42:26 +01:00
|
|
|
]
|
2014-05-31 23:00:27 +02:00
|
|
|
|
2013-11-04 10:22:22 +01:00
|
|
|
if config['arch64']:
|
2013-05-31 08:48:39 +02:00
|
|
|
cachefiles.extend([
|
2015-06-18 17:05:48 +02:00
|
|
|
('android-ndk-r10e-linux-x86_64.bin',
|
|
|
|
'https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin',
|
|
|
|
'102d6723f67ff1384330d12c45854315d6452d6510286f4e5891e00a5a8f1d5a'),
|
2014-05-31 23:00:27 +02:00
|
|
|
('android-ndk-r9b-linux-x86_64.tar.bz2',
|
|
|
|
'https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64.tar.bz2',
|
|
|
|
'8956e9efeea95f49425ded8bb697013b66e162b064b0f66b5c75628f76e0f532'),
|
|
|
|
('android-ndk-r9b-linux-x86_64-legacy-toolchains.tar.bz2',
|
|
|
|
'https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86_64-legacy-toolchains.tar.bz2',
|
|
|
|
'de93a394f7c8f3436db44568648f87738a8d09801a52f459dcad3fc047e045a1')])
|
2013-05-31 08:48:39 +02:00
|
|
|
else:
|
|
|
|
cachefiles.extend([
|
2015-06-18 17:05:48 +02:00
|
|
|
('android-ndk-r10e-linux-x86.bin',
|
|
|
|
'https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86.bin',
|
|
|
|
'92b07d25aaad9b341a7f2b2a62402d508e948bf2dea3ee7b65a6aeb18bca7df5'),
|
2014-05-31 23:00:27 +02:00
|
|
|
('android-ndk-r9b-linux-x86.tar.bz2',
|
|
|
|
'https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86.tar.bz2',
|
|
|
|
'748104b829dd12afb2fdb3044634963abb24cdb0aad3b26030abe2e9e65bfc81'),
|
|
|
|
('android-ndk-r9b-linux-x86-legacy-toolchains.tar.bz2',
|
|
|
|
'https://dl.google.com/android/ndk/android-ndk-r9b-linux-x86-legacy-toolchains.tar.bz2',
|
|
|
|
'606aadf815ae28cc7b0154996247c70d609f111b14e44bcbcd6cad4c87fefb6f')])
|
2013-05-25 14:55:16 +02:00
|
|
|
wanted = []
|
2014-01-10 19:54:53 +01:00
|
|
|
|
2014-05-07 16:13:22 +02:00
|
|
|
|
2014-01-10 19:54:53 +01:00
|
|
|
def sha256_for_file(path):
|
|
|
|
with open(path, 'r') as f:
|
|
|
|
s = hashlib.sha256()
|
|
|
|
while True:
|
|
|
|
data = f.read(4096)
|
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
s.update(data)
|
|
|
|
return s.hexdigest()
|
|
|
|
|
2013-08-09 20:37:13 +02:00
|
|
|
for f, src, shasum in cachefiles:
|
2014-01-10 19:54:53 +01:00
|
|
|
relpath = os.path.join(cachedir, f)
|
2016-01-21 15:41:26 +01:00
|
|
|
# if download fails to connect, it'll make a zero size file
|
|
|
|
if os.path.exists(relpath) and os.stat(relpath).st_size == 0:
|
|
|
|
os.remove(relpath)
|
2014-01-10 19:54:53 +01:00
|
|
|
if not os.path.exists(relpath):
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Downloading " + f + " to cache")
|
2015-11-20 15:43:47 +01:00
|
|
|
if subprocess.call(['wget', src, '-O', f], cwd=cachedir) != 0:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("...download of " + f + " failed.")
|
2013-05-25 14:55:16 +02:00
|
|
|
sys.exit(1)
|
2013-08-09 20:37:13 +02:00
|
|
|
if shasum:
|
2014-01-10 19:54:53 +01:00
|
|
|
v = sha256_for_file(relpath)
|
2013-08-09 20:37:13 +02:00
|
|
|
if v != shasum:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Invalid shasum of '" + v + "' detected for " + f)
|
2013-08-09 20:37:13 +02:00
|
|
|
sys.exit(1)
|
|
|
|
else:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("...shasum verified for " + f)
|
2013-08-09 20:37:13 +02:00
|
|
|
|
2013-05-25 14:55:16 +02:00
|
|
|
wanted.append(f)
|
|
|
|
|
2015-08-26 12:23:41 +02:00
|
|
|
# allow specifying a list/tuple that includes cached local copy
|
|
|
|
if type(config['baseboxurl']) in (list, tuple) or config['baseboxurl'][0] in ('(', '['):
|
|
|
|
baseboxurl = config['baseboxurl']
|
|
|
|
else:
|
|
|
|
baseboxurl = '"{0}"'.format(config['baseboxurl'])
|
2013-05-25 14:55:16 +02:00
|
|
|
|
2013-05-31 08:48:39 +02:00
|
|
|
# Generate an appropriate Vagrantfile for the buildserver, based on our
|
|
|
|
# settings...
|
|
|
|
vagrantfile = """
|
2014-08-27 16:35:31 +02:00
|
|
|
Vagrant.configure("2") do |config|
|
2013-05-31 08:48:39 +02:00
|
|
|
|
2014-08-27 16:40:36 +02:00
|
|
|
if Vagrant.has_plugin?("vagrant-cachier")
|
|
|
|
config.cache.scope = :box
|
2014-09-09 17:38:22 +02:00
|
|
|
config.cache.auto_detect = false
|
|
|
|
config.cache.enable :apt
|
|
|
|
config.cache.enable :chef
|
2014-08-27 16:40:36 +02:00
|
|
|
end
|
|
|
|
|
2013-05-31 08:48:39 +02:00
|
|
|
config.vm.box = "{0}"
|
2015-08-26 12:23:41 +02:00
|
|
|
config.vm.box_url = {1}
|
2013-05-31 08:48:39 +02:00
|
|
|
|
2014-08-27 16:35:31 +02:00
|
|
|
config.vm.provider "virtualbox" do |v|
|
|
|
|
v.customize ["modifyvm", :id, "--memory", "{2}"]
|
2015-02-01 10:00:04 +01:00
|
|
|
v.customize ["modifyvm", :id, "--cpus", "{3}"]
|
2014-08-27 16:35:31 +02:00
|
|
|
end
|
2013-05-31 08:48:39 +02:00
|
|
|
|
2016-01-26 17:35:25 +01:00
|
|
|
config.vm.boot_timeout = {4}
|
|
|
|
|
2013-05-31 08:48:39 +02:00
|
|
|
config.vm.provision :shell, :path => "fixpaths.sh"
|
2015-02-01 10:00:04 +01:00
|
|
|
""".format(config['basebox'],
|
2015-08-26 12:23:41 +02:00
|
|
|
baseboxurl,
|
2015-02-01 10:00:04 +01:00
|
|
|
config['memory'],
|
2016-01-26 17:35:25 +01:00
|
|
|
config.get('cpus', 1),
|
|
|
|
config['boot_timeout'])
|
2013-11-04 10:22:22 +01:00
|
|
|
if 'aptproxy' in config and config['aptproxy']:
|
2013-05-31 08:48:39 +02:00
|
|
|
vagrantfile += """
|
|
|
|
config.vm.provision :shell, :inline => 'sudo echo "Acquire::http {{ Proxy \\"{0}\\"; }};" > /etc/apt/apt.conf.d/02proxy && sudo apt-get update'
|
2013-11-04 10:22:22 +01:00
|
|
|
""".format(config['aptproxy'])
|
2015-08-26 13:26:22 +02:00
|
|
|
|
2016-01-26 22:06:10 +01:00
|
|
|
# buildserver/ is shared to the VM's /vagrant by default so the old default
|
|
|
|
# does not need a custom mount
|
|
|
|
if cachedir != 'buildserver/cache':
|
|
|
|
vagrantfile += """
|
|
|
|
config.vm.synced_folder '{0}', '/vagrant/cache'
|
|
|
|
""".format(cachedir)
|
|
|
|
|
2016-01-26 11:21:21 +01:00
|
|
|
# cache .deb packages on the host via a mount trick
|
|
|
|
if config['apt_package_cache']:
|
|
|
|
aptcachedir = cachedir + '/apt/archives'
|
|
|
|
vagrantfile += """
|
|
|
|
config.vm.synced_folder "{0}", "/var/cache/apt/archives",
|
|
|
|
owner: 'root', group: 'root', create: true
|
|
|
|
""".format(aptcachedir)
|
|
|
|
|
2013-05-31 08:48:39 +02:00
|
|
|
vagrantfile += """
|
|
|
|
config.vm.provision :chef_solo do |chef|
|
|
|
|
chef.cookbooks_path = "cookbooks"
|
2013-12-30 17:04:16 +01:00
|
|
|
chef.log_level = :debug
|
2013-05-31 08:48:39 +02:00
|
|
|
chef.json = {
|
|
|
|
:settings => {
|
|
|
|
:sdk_loc => "/home/vagrant/android-sdk",
|
|
|
|
:ndk_loc => "/home/vagrant/android-ndk",
|
2015-08-26 13:26:22 +02:00
|
|
|
:debian_mirror => "%s",
|
2016-02-04 08:42:53 +01:00
|
|
|
:ubuntu_trusty => "%s",
|
2013-05-31 08:48:39 +02:00
|
|
|
:user => "vagrant"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chef.add_recipe "fdroidbuild-general"
|
|
|
|
chef.add_recipe "android-sdk"
|
|
|
|
chef.add_recipe "android-ndk"
|
2014-01-09 18:30:35 +01:00
|
|
|
chef.add_recipe "gradle"
|
2013-11-24 23:11:02 +01:00
|
|
|
chef.add_recipe "kivy"
|
2013-05-31 08:48:39 +02:00
|
|
|
end
|
|
|
|
end
|
2016-02-04 08:42:53 +01:00
|
|
|
""" % (config['debian_mirror'],
|
|
|
|
str('14.04' in os.uname()[3]).lower())
|
2013-05-31 08:48:39 +02:00
|
|
|
|
|
|
|
# Check against the existing Vagrantfile, and if they differ, we need to
|
|
|
|
# create a new box:
|
|
|
|
vf = os.path.join(serverdir, 'Vagrantfile')
|
|
|
|
writevf = True
|
|
|
|
if os.path.exists(vf):
|
|
|
|
vagrant(['halt'], serverdir)
|
|
|
|
with open(vf, 'r') as f:
|
|
|
|
oldvf = f.read()
|
|
|
|
if oldvf != vagrantfile:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Server configuration has changed, rebuild from scratch is required")
|
2013-05-31 08:48:39 +02:00
|
|
|
vagrant(['destroy', '-f'], serverdir)
|
|
|
|
else:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Re-provisioning existing server")
|
2013-05-31 08:48:39 +02:00
|
|
|
writevf = False
|
|
|
|
else:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("No existing server - building from scratch")
|
2013-05-31 08:48:39 +02:00
|
|
|
if writevf:
|
|
|
|
with open(vf, 'w') as f:
|
|
|
|
f.write(vagrantfile)
|
|
|
|
|
|
|
|
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Configuring build server VM")
|
2015-08-27 12:12:22 +02:00
|
|
|
returncode, out = vagrant(['up', '--provision'], serverdir, printout=True)
|
2013-02-12 16:20:30 +01:00
|
|
|
with open(os.path.join(serverdir, 'up.log'), 'w') as log:
|
2013-05-31 08:48:39 +02:00
|
|
|
log.write(out)
|
2013-01-21 12:09:56 +01:00
|
|
|
if returncode != 0:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Failed to configure server")
|
2013-04-10 10:36:31 +02:00
|
|
|
sys.exit(1)
|
2013-11-09 12:51:39 +01:00
|
|
|
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Writing buildserver ID")
|
2013-11-09 12:51:39 +01:00
|
|
|
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
|
|
|
|
buildserverid = p.communicate()[0].strip()
|
2016-01-04 17:24:57 +01:00
|
|
|
print("...ID is " + buildserverid)
|
2013-11-09 12:51:39 +01:00
|
|
|
subprocess.call(
|
|
|
|
['vagrant', 'ssh', '-c', 'sh -c "echo {0} >/home/vagrant/buildserverid"'
|
2014-05-31 23:00:27 +02:00
|
|
|
.format(buildserverid)],
|
2013-11-09 12:51:39 +01:00
|
|
|
cwd=serverdir)
|
|
|
|
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Stopping build server VM")
|
2012-09-24 15:04:58 +02:00
|
|
|
vagrant(['halt'], serverdir)
|
|
|
|
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Waiting for build server VM to be finished")
|
2012-09-24 15:04:58 +02:00
|
|
|
ready = False
|
|
|
|
while not ready:
|
|
|
|
time.sleep(2)
|
2013-05-31 08:48:39 +02:00
|
|
|
returncode, out = vagrant(['status'], serverdir)
|
2012-09-24 15:04:58 +02:00
|
|
|
if returncode != 0:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Error while checking status")
|
2012-09-24 15:04:58 +02:00
|
|
|
sys.exit(1)
|
|
|
|
for line in out.splitlines():
|
|
|
|
if line.startswith("default"):
|
|
|
|
if line.find("poweroff") != -1:
|
|
|
|
ready = True
|
|
|
|
else:
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Status: " + line)
|
2012-09-24 15:04:58 +02:00
|
|
|
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Packaging")
|
2014-01-09 22:31:58 +01:00
|
|
|
vagrant(['package', '--output', os.path.join('..', boxfile)], serverdir,
|
|
|
|
printout=options.verbose)
|
2016-01-04 17:24:57 +01:00
|
|
|
print("Adding box")
|
2014-01-09 22:31:58 +01:00
|
|
|
vagrant(['box', 'add', 'buildserver', boxfile, '-f'],
|
|
|
|
printout=options.verbose)
|
2012-09-24 15:04:58 +02:00
|
|
|
|
2014-01-09 22:31:58 +01:00
|
|
|
os.remove(boxfile)
|