mirror of
				https://github.com/f-droid/fdroidserver.git
				synced 2025-11-04 06:30:27 +03:00 
			
		
		
		
	buildserver: hard code basebox name and version
This is not user-configurable, so it should not be setup to be. This process is only tested on the one basebox, and devs can just edit Vagrantfile directly to test other base boxes. # Conflicts: # makebuildserver
This commit is contained in:
		
							parent
							
								
									abdd02f33a
								
							
						
					
					
						commit
						e2fcd633fc
					
				
					 3 changed files with 14 additions and 52 deletions
				
			
		| 
						 | 
				
			
			@ -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),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue