chiark / gitweb /
makebuildserver: explicitly set debian_mirror by default
[fdroidserver.git] / makebuildserver
index f745b0a3bb9861b5c8711cf353a08fed952ec9b8..d876a004a1db8d602226d8e71b2c498afd79902f 100755 (executable)
@@ -41,16 +41,20 @@ 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()
 
 # set up default config
+cachedir = os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver')
 config = {
     'arch64': False,
     'basebox': 'jessie32',
-    'baseboxurl': 'https://f-droid.org/jessie32.box',
-    'cachedir': os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver'),
+    # 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/',
+    'cachedir': cachedir,
     'cpus': 1,
     'memory': 3584,
 }
@@ -305,6 +309,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:
@@ -375,7 +382,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: