mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-26 12:46:08 +00:00
container: Add option to skip install
Fixes #2561 - Running functional tests against the container works. ``` ./container start --skip-install ./container run-tests --pytest-args --include-functional -m syncthing ``` Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Ran yapf] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org
This commit is contained in:
parent
9169ef89d9
commit
2307f5fbf2
31
container
31
container
@ -484,6 +484,9 @@ def parse_arguments() -> argparse.Namespace:
|
|||||||
help='Disk image size to resize to after download')
|
help='Disk image size to resize to after download')
|
||||||
subparser.add_argument('--hkp-client', choices=('gpg', 'wget'),
|
subparser.add_argument('--hkp-client', choices=('gpg', 'wget'),
|
||||||
default='gpg', help='Client for key retrieval')
|
default='gpg', help='Client for key retrieval')
|
||||||
|
subparser.add_argument(
|
||||||
|
'--skip-install', action='store_true',
|
||||||
|
help='Skip running make provision-dev in the container')
|
||||||
|
|
||||||
# Print IP address
|
# Print IP address
|
||||||
subparser = subparsers.add_parser(
|
subparser = subparsers.add_parser(
|
||||||
@ -946,7 +949,7 @@ def _setup_ssh(image_file: pathlib.Path):
|
|||||||
_runc(image_file, ['chown', 'fbx:fbx', '/home/fbx/.ssh/authorized_keys'])
|
_runc(image_file, ['chown', 'fbx:fbx', '/home/fbx/.ssh/authorized_keys'])
|
||||||
|
|
||||||
|
|
||||||
def _setup_image(image_file: pathlib.Path):
|
def _setup_image(image_file: pathlib.Path, skip_install: bool = False):
|
||||||
"""Prepare the image for execution."""
|
"""Prepare the image for execution."""
|
||||||
setup_file = image_file.with_suffix(image_file.suffix + '.setup')
|
setup_file = image_file.with_suffix(image_file.suffix + '.setup')
|
||||||
if setup_file.exists():
|
if setup_file.exists():
|
||||||
@ -958,9 +961,10 @@ def _setup_image(image_file: pathlib.Path):
|
|||||||
_runc(image_file, ['tee', '/etc/apt/apt.conf.d/20auto-upgrades'],
|
_runc(image_file, ['tee', '/etc/apt/apt.conf.d/20auto-upgrades'],
|
||||||
input=contents.encode())
|
input=contents.encode())
|
||||||
|
|
||||||
logger.info('In image: Disabling FreedomBox service')
|
if not skip_install:
|
||||||
_runc(image_file, ['systemctl', 'disable', 'plinth'],
|
logger.info('In image: Disabling FreedomBox service')
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
_runc(image_file, ['systemctl', 'disable', 'plinth'],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
logger.info('In image: Creating virtiofs mount at /freedombox')
|
logger.info('In image: Creating virtiofs mount at /freedombox')
|
||||||
mount = '''[Unit]
|
mount = '''[Unit]
|
||||||
@ -1018,15 +1022,19 @@ def _is_provisioned(distribution: str) -> bool:
|
|||||||
return provision_file.exists()
|
return provision_file.exists()
|
||||||
|
|
||||||
|
|
||||||
def _provision(image_file: pathlib.Path, machine_type: str, distribution: str):
|
def _provision(image_file: pathlib.Path, machine_type: str, distribution: str,
|
||||||
|
skip_install: bool = False):
|
||||||
"""Run app setup inside the container."""
|
"""Run app setup inside the container."""
|
||||||
if _is_provisioned(distribution):
|
if _is_provisioned(distribution):
|
||||||
return
|
return
|
||||||
|
|
||||||
machine = Machine.get_instance(machine_type, distribution)
|
if skip_install:
|
||||||
ssh_command = machine.get_ssh_command()
|
logger.info('Skipping provision step (--skip-install)')
|
||||||
subprocess.run(ssh_command + ['bash'], check=True,
|
else:
|
||||||
input=PROVISION_SCRIPT.encode())
|
machine = Machine.get_instance(machine_type, distribution)
|
||||||
|
ssh_command = machine.get_ssh_command()
|
||||||
|
subprocess.run(ssh_command + ['bash'], check=True,
|
||||||
|
input=PROVISION_SCRIPT.encode())
|
||||||
|
|
||||||
provision_file = image_file.with_suffix(image_file.suffix + '.provisioned')
|
provision_file = image_file.with_suffix(image_file.suffix + '.provisioned')
|
||||||
provision_file.touch()
|
provision_file.touch()
|
||||||
@ -1476,10 +1484,11 @@ def subcommand_start(arguments: argparse.Namespace):
|
|||||||
arguments.hkp_client)
|
arguments.hkp_client)
|
||||||
_resize_disk_image(image_file, arguments.image_size,
|
_resize_disk_image(image_file, arguments.image_size,
|
||||||
arguments.distribution)
|
arguments.distribution)
|
||||||
_setup_image(image_file)
|
_setup_image(image_file, arguments.skip_install)
|
||||||
machine.setup()
|
machine.setup()
|
||||||
machine.launch()
|
machine.launch()
|
||||||
_provision(image_file, arguments.machine_type, arguments.distribution)
|
_provision(image_file, arguments.machine_type, arguments.distribution,
|
||||||
|
arguments.skip_install)
|
||||||
_print_banner(arguments.machine_type, arguments.distribution)
|
_print_banner(arguments.machine_type, arguments.distribution)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user