def _download_images(image_path, image_names, templates): if _has_app_image(image_names): raise CommandError('Downloading of app images is not supported yet') image_downloader = ImageDownloader(templates) image_downloader.download_images(image_names, image_path) logger.info('Successfully downloaded images: %s', ', '.join(image_names))
def _get_or_download_image(self, templates, image, do_download=True): img_path = self.image_path(image) try: return get_image_descriptor(img_path) except CommandError: if not do_download: raise logger.info('Image %s missing, attempting to download...', image) image_downloader = ImageDownloader(templates) image_downloader.download_images([image], self.image_path()) return get_image_descriptor(img_path)
def handle(self, *args, **options): # If DISPLAY is missing, don't use headless mode if options['gui']: self._headless = False # If KVM has been explicitly disabled, don't use it during the build if options['no_kvm']: self._use_kvm = False num_cores = options['cores'] _check_core_num(num_cores) # The path could have been deleted by a previous clean if not os.path.exists(self.image_path()): os.makedirs(self.image_path()) img_build_dir = self.source_path(CONSTANTS['repos']['images']['build']) if options['clean']: self._invoke_make(img_build_dir, ['clean'], num_cores) return image_name = options['name'] if not image_name: self._print_image_list() return templates = get_image_templates(img_build_dir) image_names = _translate_image_name(templates, image_name) logger.info('The following images will be built:') for image in image_names: logger.info(' * %s', image) if options['download']: image_downloader = ImageDownloader(templates) image_downloader.download_images(image_names, self.image_path()) logger.info('Successfully downloaded images: %s', ', '.join(image_names)) return rule_names = image_names if options['archive']: archive_rules = [] for r in rule_names: archive_rules.append( os.path.join(self.image_path(), '%s.tar.xz' % r)) rule_names = archive_rules logger.info('The following archives will be built:') for a in archive_rules: logger.info(' * %s', a) iso_dir = os.path.abspath( options['iso_dir']) if options['iso_dir'] else None # Check for optional product keys and iso directories. # These may or may not be required, depending on the set of images. _check_product_keys(templates, image_names) _check_iso(templates, iso_dir, image_names) if self._use_kvm: _check_kvm() _check_groups_kvm() _check_groups_docker() _check_vmlinux() _check_virtualbox() # Clone kernel if needed. # This is necessary if the s2e env has been initialized with -b flag. self._clone_kernel() self._invoke_make(img_build_dir, rule_names, num_cores, iso_dir) logger.success('Built image \'%s\'', image_name)