diff --git a/buildserver/Vagrantfile b/buildserver/Vagrantfile index 2a170bdf..3b65e61a 100644 --- a/buildserver/Vagrantfile +++ b/buildserver/Vagrantfile @@ -19,10 +19,7 @@ Vagrant.configure("2") do |config| config.cache.enable :chef end - config.vm.box = configfile['basebox'] - if configfile.has_key? "basebox_version" - config.vm.box_version = configfile['basebox_version'] - end + config.vm.box = "fdroid/bullseye64" if not configfile.has_key? "vm_provider" or configfile["vm_provider"] == "virtualbox" # default to VirtualBox if not set diff --git a/examples/makebuildserver.config.py b/examples/makebuildserver.config.py index ff668a63..96e0c9ec 100644 --- a/examples/makebuildserver.config.py +++ b/examples/makebuildserver.config.py @@ -2,29 +2,6 @@ # # You may want to alter these before running ./makebuildserver -# Name of the Vagrant basebox to use, by default it will be downloaded -# from Vagrant Cloud. For release builds setup, generate the basebox -# locally using https://gitlab.com/fdroid/basebox, add it to Vagrant, -# then set this to the local basebox name. -# This defaults to "fdroid/basebox-stretch64" which will download a -# prebuilt basebox from https://app.vagrantup.com/fdroid. -# -# (If you change this value you have to supply the `--clean` option on -# your next `makebuildserver` run.) -# -# basebox = "basebox-stretch64" - -# This allows you to pin your basebox to a specific versions. It defaults -# the most recent basebox version which can be aumotaically verifyed by -# `makebuildserver`. -# Please note that vagrant does not support versioning of locally added -# boxes, so we can't support that either. -# -# (If you change this value you have to supply the `--clean` option on -# your next `makebuildserver` run.) -# -# basebox_version = "0.1" - # In the process of setting up the build server, many gigs of files # are downloaded (Android SDK components, gradle, etc). These are # cached so that they are not redownloaded each time. By default, diff --git a/makebuildserver b/makebuildserver index b90e8ba9..9d18c954 100755 --- a/makebuildserver +++ b/makebuildserver @@ -24,6 +24,8 @@ parser.add_option('-v', '--verbose', action="count", dest='verbosity', default=1 parser.add_option('-q', action='store_const', const=0, dest='verbosity') 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('--skip-box-verification', action="store_true", default=False, + help="""Skip verifying the downloaded base box.""") parser.add_option('--skip-cache-update', action="store_true", default=False, help="""Skip downloading and checking cache.""" """This assumes that the cache is already downloaded completely.""") @@ -77,7 +79,6 @@ BASEBOX_CHECKSUMS = { } config = { - 'basebox': BASEBOX_DEFAULT, 'debian_mirror': 'https://deb.debian.org/debian/', 'boot_timeout': 600, 'cachedir': os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver'), @@ -87,6 +88,13 @@ config = { 'vm_provider': 'virtualbox', } +with open('buildserver/Vagrantfile') as fp: + m = re.search(r"""\.vm\.box\s*=\s*["'](.*)["']""", fp.read()) + if not m: + logging.error('Cannot find box name in buildserver/Vagrantfile!') + exit(1) + config['basebox'] = m.group(1) +config['basebox_version'] = BASEBOX_VERSION_DEFAULT # load config file, if present if os.path.exists('makebuildserver.config.py'): exec(compile(open('makebuildserver.config.py').read(), 'makebuildserver.config.py', 'exec'), config) @@ -96,14 +104,6 @@ elif os.path.exists('makebs.config.py'): if '__builtins__' in config: del config['__builtins__'] # added by compile/exec logging.debug("makebuildserver.config.py parsed -> %s", json.dumps(config, indent=4, sort_keys=True)) -if config['basebox'] == BASEBOX_DEFAULT and 'basebox_version' not in config: - config['basebox_version'] = BASEBOX_VERSION_DEFAULT -# note: vagrant allows putting '/' into the name of a local box, -# so this check is not completely reliable, but better than nothing -if 'basebox_version' in config and 'basebox' in config and '/' not in config['basebox']: - logging.critical("Can not get version '{version}' for basebox '{box}', " - "vagrant does not support versioning for locally added boxes." - .format(box=config['basebox'], version=config['basebox_version'])) # Update cached files. if not os.path.exists(config['cachedir']): @@ -312,27 +312,15 @@ def main(): "virtualbox, libvirt)" .format(vm_provider=config['cm_provider'])) sys.exit(1) - # Check if selected Vagrant box is available - available_boxes_by_provider = [x.name for x in v.box_list() if x.provider == config['vm_provider']] - if '/' not in config['basebox'] and config['basebox'] not in available_boxes_by_provider: - logging.critical("Vagrant box '{basebox}' not available " - "for '{vm_provider}' VM provider. " - "Please make sure it's added to vagrant. " - "(If you need a basebox to begin with, " - "here is how we're bootstrapping it: " - "https://gitlab.com/fdroid/basebox)" - .format(vm_provider=config['vm_provider'], - basebox=config['basebox'])) - sys.exit(1) # Download and verify pre-built Vagrant boxes - if config['basebox'] == BASEBOX_DEFAULT: + if not options.skip_box_verification: buildserver_not_created = any([True for x in v.status() if x.state == 'not_created' and x.name == 'default']) if buildserver_not_created or options.clean: # make vagrant download and add basebox - target_basebox_installed = any([x for x in v.box_list() if x.name == BASEBOX_DEFAULT and x.provider == config['vm_provider'] and x.version == config['basebox_version']]) + target_basebox_installed = any([x for x in v.box_list() if x.name == config['basebox'] and x.provider == config['vm_provider'] and x.version == config['basebox_version']]) if not target_basebox_installed: - cmd = [shutil.which('vagrant'), 'box', 'add', BASEBOX_DEFAULT, + cmd = [shutil.which('vagrant'), 'box', 'add', config['basebox'], '--box-version=' + config['basebox_version'], '--provider=' + config['vm_provider']] ret_val = subprocess.call(cmd) @@ -353,7 +341,7 @@ def main(): for filename, sha256 in BASEBOX_CHECKSUMS[config['basebox_version']][config['vm_provider']].items(): verify_file_sha256(os.path.join(get_vagrant_home(), 'boxes', - BASEBOX_DEFAULT.replace('/', '-VAGRANTSLASH-'), + config['basebox'].replace('/', '-VAGRANTSLASH-'), config['basebox_version'], config['vm_provider'], filename),