mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 14:32:28 +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
5
buildserver/Vagrantfile
vendored
5
buildserver/Vagrantfile
vendored
|
@ -19,10 +19,7 @@ Vagrant.configure("2") do |config|
|
||||||
config.cache.enable :chef
|
config.cache.enable :chef
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.box = configfile['basebox']
|
config.vm.box = "fdroid/bullseye64"
|
||||||
if configfile.has_key? "basebox_version"
|
|
||||||
config.vm.box_version = configfile['basebox_version']
|
|
||||||
end
|
|
||||||
|
|
||||||
if not configfile.has_key? "vm_provider" or configfile["vm_provider"] == "virtualbox"
|
if not configfile.has_key? "vm_provider" or configfile["vm_provider"] == "virtualbox"
|
||||||
# default to VirtualBox if not set
|
# default to VirtualBox if not set
|
||||||
|
|
|
@ -2,29 +2,6 @@
|
||||||
#
|
#
|
||||||
# You may want to alter these before running ./makebuildserver
|
# 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
|
# In the process of setting up the build server, many gigs of files
|
||||||
# are downloaded (Android SDK components, gradle, etc). These are
|
# are downloaded (Android SDK components, gradle, etc). These are
|
||||||
# cached so that they are not redownloaded each time. By default,
|
# cached so that they are not redownloaded each time. By default,
|
||||||
|
|
|
@ -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('-q', action='store_const', const=0, dest='verbosity')
|
||||||
parser.add_option("-c", "--clean", action="store_true", default=False,
|
parser.add_option("-c", "--clean", action="store_true", default=False,
|
||||||
help="Build from scratch, rather than attempting to update the existing server")
|
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,
|
parser.add_option('--skip-cache-update', action="store_true", default=False,
|
||||||
help="""Skip downloading and checking cache."""
|
help="""Skip downloading and checking cache."""
|
||||||
"""This assumes that the cache is already downloaded completely.""")
|
"""This assumes that the cache is already downloaded completely.""")
|
||||||
|
@ -77,7 +79,6 @@ BASEBOX_CHECKSUMS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'basebox': BASEBOX_DEFAULT,
|
|
||||||
'debian_mirror': 'https://deb.debian.org/debian/',
|
'debian_mirror': 'https://deb.debian.org/debian/',
|
||||||
'boot_timeout': 600,
|
'boot_timeout': 600,
|
||||||
'cachedir': os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver'),
|
'cachedir': os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver'),
|
||||||
|
@ -87,6 +88,13 @@ config = {
|
||||||
'vm_provider': 'virtualbox',
|
'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
|
# load config file, if present
|
||||||
if os.path.exists('makebuildserver.config.py'):
|
if os.path.exists('makebuildserver.config.py'):
|
||||||
exec(compile(open('makebuildserver.config.py').read(), 'makebuildserver.config.py', 'exec'), config)
|
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:
|
if '__builtins__' in config:
|
||||||
del config['__builtins__'] # added by compile/exec
|
del config['__builtins__'] # added by compile/exec
|
||||||
logging.debug("makebuildserver.config.py parsed -> %s", json.dumps(config, indent=4, sort_keys=True))
|
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.
|
# Update cached files.
|
||||||
if not os.path.exists(config['cachedir']):
|
if not os.path.exists(config['cachedir']):
|
||||||
|
@ -312,27 +312,15 @@ def main():
|
||||||
"virtualbox, libvirt)"
|
"virtualbox, libvirt)"
|
||||||
.format(vm_provider=config['cm_provider']))
|
.format(vm_provider=config['cm_provider']))
|
||||||
sys.exit(1)
|
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
|
# 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'])
|
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:
|
if buildserver_not_created or options.clean:
|
||||||
# make vagrant download and add basebox
|
# 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:
|
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'],
|
'--box-version=' + config['basebox_version'],
|
||||||
'--provider=' + config['vm_provider']]
|
'--provider=' + config['vm_provider']]
|
||||||
ret_val = subprocess.call(cmd)
|
ret_val = subprocess.call(cmd)
|
||||||
|
@ -353,7 +341,7 @@ def main():
|
||||||
for filename, sha256 in BASEBOX_CHECKSUMS[config['basebox_version']][config['vm_provider']].items():
|
for filename, sha256 in BASEBOX_CHECKSUMS[config['basebox_version']][config['vm_provider']].items():
|
||||||
verify_file_sha256(os.path.join(get_vagrant_home(),
|
verify_file_sha256(os.path.join(get_vagrant_home(),
|
||||||
'boxes',
|
'boxes',
|
||||||
BASEBOX_DEFAULT.replace('/', '-VAGRANTSLASH-'),
|
config['basebox'].replace('/', '-VAGRANTSLASH-'),
|
||||||
config['basebox_version'],
|
config['basebox_version'],
|
||||||
config['vm_provider'],
|
config['vm_provider'],
|
||||||
filename),
|
filename),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue