def buildvm(name): """ Build a virtual machine. Eg.: buildvm ubuntu """ build_dir = path('target/%s-docker-image' % name) if exists(build_dir): rmtree(build_dir) src_root = 'src/build/docker' available_vms = set(listdir(_defaults.path(src_root))) if exists(path(src_root)): available_vms.update(listdir(path(src_root))) if name not in available_vms: raise FbsError('Could not find %s. Available VMs are:%s' % (name, ''.join(['\n * ' + vm for vm in available_vms]))) src_dir = src_root + '/' + name for path_fn in _defaults.path, path: _copy(path_fn, src_dir, build_dir) settings = SETTINGS['docker_images'].get(name, {}) for path_fn in _defaults.path, path: for p in settings.get('build_files', []): _copy(path_fn, p, build_dir) args = ['build', '--pull', '-t', _get_docker_id(name), build_dir] for arg, value in settings.get('build_args', {}).items(): args.extend(['--build-arg', '%s=%s' % (arg, value)]) try: _run_docker(args, check=True, stdout=PIPE, universal_newlines=True) except CalledProcessError as e: raise FbsError(e.stdout) _LOG.info('Done. You can now execute:\n fbs runvm ' + name)
def freeze_windows(debug=False): args = [] if not (debug or SETTINGS['show_console_window']): # The --windowed flag below prevents us from seeing any console output. # We therefore only add it when we're not debugging. args.append('--windowed') args.extend(['--icon', path('src/main/icons/Icon.ico')]) for path_fn in default_path, path: _copy(path_fn, 'src/freeze/windows/version_info.py', path('target/PyInstaller')) args.extend(['--version-file', path('target/PyInstaller/version_info.py')]) run_pyinstaller(args, debug) _restore_corrupted_python_dlls() _generate_resources() copy(path('src/main/icons/Icon.ico'), path('${freeze_dir}')) _add_missing_dlls()
def _generate_resources(): """ Copy the data files from src/main/resources to ${freeze_dir}. Automatically filters files mentioned in the setting resources_to_filter: Placeholders such as ${app_name} are automatically replaced by the corresponding setting in files on that list. """ freeze_dir = path('${freeze_dir}') if is_mac(): resources_dest_dir = join(freeze_dir, 'Contents', 'Resources') else: resources_dest_dir = freeze_dir for path_fn in _defaults.path, path: for profile in LOADED_PROFILES: _copy(path_fn, 'src/main/resources/' + profile, resources_dest_dir) _copy(path_fn, 'src/freeze/' + profile, freeze_dir)
def buildvm(name): """ Build a Linux VM. Eg.: buildvm ubuntu """ require_existing_project() build_dir = path('target/%s-docker-image' % name) if exists(build_dir): rmtree(build_dir) src_root = 'src/build/docker' available_vms = set(listdir(default_path(src_root))) if exists(path(src_root)): available_vms.update(listdir(path(src_root))) if name not in available_vms: raise FbsError('Could not find %s. Available VMs are:%s' % (name, ''.join(['\n * ' + vm for vm in available_vms]))) src_dir = src_root + '/' + name for path_fn in default_path, path: _copy(path_fn, src_dir, build_dir) settings = SETTINGS['docker_images'].get(name, {}) for path_fn in default_path, path: for p in settings.get('build_files', []): _copy(path_fn, p, build_dir) args = ['build', '--pull', '-t', _get_docker_id(name), build_dir] for arg, value in settings.get('build_args', {}).items(): args.extend(['--build-arg', '%s=%s' % (arg, value)]) try: _run_docker(args, check=True, stdout=PIPE, stderr=PIPE, universal_newlines=True) except CalledProcessError as e: if '/private-key.gpg: no such file or directory' in e.stderr: message = 'Could not find private-key.gpg. Maybe you want to ' \ 'run:\n fbs gengpgkey' else: message = e.stdout + '\n' + e.stderr raise FbsError(message) _LOG.info('Done. You can now execute:\n fbs runvm ' + name)
def _generate_installer_resources(): for path_fn in _defaults.path, path: for profile in LOADED_PROFILES: _copy(path_fn, 'src/installer/' + profile, path('target/installer'))