chiark / gitweb /
lint: also check for trailing spaces in names
[fdroidserver.git] / makebuildserver
index 4fc9a28dbd8816584c658d9f426cc3226c4b43b9..aeb5ebbc60fad1fc59bd4c99f5a0e60c58dc8613 100755 (executable)
@@ -41,11 +41,24 @@ parser.add_option("-v", "--verbose", action="store_true", default=False,
                   help="Spew out even more information than normal")
 parser.add_option("-c", "--clean", action="store_true", default=False,
                   help="Build from scratch, rather than attempting to update the existing server")
-parser.add_option("--debian-mirror", default="http://http.debian.net/debian/",
-                  help="Use the specified Debian mirror in the box's /etc/apt/sources.list.")
 options, args = parser.parse_args()
 
-config = {}
+# set up default config
+cachedir = os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver')
+config = {
+    'arch64': False,
+    'basebox': 'jessie32',
+    # 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',
+    ],
+    'debian_mirror': 'http://http.debian.net/debian/',
+    'boot_timeout': 600,
+    'cachedir': cachedir,
+    'cpus': 1,
+    'memory': 3584,
+}
 
 # load config file, if present
 if os.path.exists('makebuildserver.config.py'):
@@ -65,9 +78,9 @@ if options.clean:
     vagrant(['destroy', '-f'], cwd=serverdir, printout=options.verbose)
 
 # Update cached files.
-cachedir = os.path.join('buildserver', 'cache')
+cachedir = config['cachedir']
 if not os.path.exists(cachedir):
-    os.mkdir(cachedir)
+    os.makedirs(cachedir, 0755)
 
 cachefiles = [
     ('android-sdk_r24.4.1-linux.tgz',
@@ -297,6 +310,9 @@ def sha256_for_file(path):
 
 for f, src, shasum in cachefiles:
     relpath = os.path.join(cachedir, f)
+    # 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)
     if not os.path.exists(relpath):
         print "Downloading " + f + " to cache"
         if subprocess.call(['wget', src, '-O', f], cwd=cachedir) != 0:
@@ -338,11 +354,14 @@ Vagrant.configure("2") do |config|
     v.customize ["modifyvm", :id, "--cpus", "{3}"]
   end
 
+  config.vm.boot_timeout = {4}
+
   config.vm.provision :shell, :path => "fixpaths.sh"
 """.format(config['basebox'],
            baseboxurl,
            config['memory'],
-           config.get('cpus', 1))
+           config.get('cpus', 1),
+           config['boot_timeout'])
 if 'aptproxy' in config and config['aptproxy']:
     vagrantfile += """
   config.vm.provision :shell, :inline => 'sudo echo "Acquire::http {{ Proxy \\"{0}\\"; }};" > /etc/apt/apt.conf.d/02proxy && sudo apt-get update'
@@ -367,7 +386,7 @@ vagrantfile += """
     chef.add_recipe "kivy"
   end
 end
-""" % (options.debian_mirror)
+""" % (config['debian_mirror'])
 
 # Check against the existing Vagrantfile, and if they differ, we need to
 # create a new box: