Changeset View
Changeset View
Standalone View
Standalone View
lilybuild/podman-helper
| Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
| def export_volume(alias, local_dir, vol_mount_dir): | def export_volume(alias, local_dir, vol_mount_dir): | ||||
| verbose_run([ | verbose_run([ | ||||
| 'rsync', '-a', '--delete', | 'rsync', '-a', '--delete', | ||||
| '--rsh', ssh_command, | '--rsh', ssh_command, | ||||
| f'helper@{alias}:{vol_mount_dir}/', | f'helper@{alias}:{vol_mount_dir}/', | ||||
| local_dir, | local_dir, | ||||
| ], check=True) | ], check=True) | ||||
| def image_to_podman_args(image): | |||||
| name = image['name'] | |||||
| args = [] | |||||
| if 'entrypoint' in image: | |||||
| # ci.json requires that the entrypoint is an array of strings | |||||
| ep = json.dumps(image['entrypoint']) | |||||
| args += ['--entrypoint', ep] | |||||
| args += [name] | |||||
| return args | |||||
| def run_in_container(image, work_volname, script_volname): | def run_in_container(image, work_volname, script_volname): | ||||
| timeout = 60 * 60 * 2 # 2 hours by default | timeout = 60 * 60 * 2 # 2 hours by default | ||||
| p = verbose_run([ | p = verbose_run([ | ||||
| 'podman', 'run', '--rm', | 'podman', 'run', '--rm', | ||||
| f'--mount=type=volume,source={work_volname},destination={work_vol_mount_dir}', | f'--mount=type=volume,source={work_volname},destination={work_vol_mount_dir}', | ||||
| f'--mount=type=volume,source={script_volname},destination={script_vol_mount_dir}', | f'--mount=type=volume,source={script_volname},destination={script_vol_mount_dir}', | ||||
| image, | ] + image_to_podman_args(image) + [ | ||||
| script_name, | script_name, | ||||
| ], timeout=timeout) | ], timeout=timeout) | ||||
| return p | return p | ||||
| def main(): | def main(): | ||||
| image = sys.argv[1] | image = json.loads(sys.argv[1]) | ||||
| work_dir = sys.argv[2] | work_dir = sys.argv[2] | ||||
| script_dir = sys.argv[3] | script_dir = sys.argv[3] | ||||
| result_dir = sys.argv[4] | result_dir = sys.argv[4] | ||||
| pinfo('Creating volumes...') | pinfo('Creating volumes...') | ||||
| work_vol = create_volume('work') | work_vol = create_volume('work') | ||||
| script_vol = create_volume('script') | script_vol = create_volume('script') | ||||
| psuccess('Created.') | psuccess('Created.') | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||