Exemple #1
0
    def _print_apps_list(self):
        img_build_dir = self.source_path(CONSTANTS['repos']['images']['build'])
        app_templates = get_app_templates(img_build_dir)
        if not app_templates:
            apps_json_path = os.path.join(img_build_dir, 'apps.json')
            raise CommandError('No apps available to build. Make sure that '
                               f'{apps_json_path} exists and is valid')

        print('Available applications:')
        for app_template, desc in sorted(app_templates.items()):
            for base_image in desc['base_images']:
                print(f' * {base_image}/{app_template} - {desc["name"]}')
Exemple #2
0
    def _print_apps_list(self):
        img_build_dir = self.source_path(CONSTANTS['repos']['images']['build'])
        app_templates = get_app_templates(img_build_dir)
        if not app_templates:
            raise CommandError('No apps available to build. Make sure that '
                               '%s exists and is valid' %
                               os.path.join(img_build_dir, 'apps.json'))

        print('Available applications:')
        for app_template, desc in sorted(app_templates.items()):
            for base_image in desc['base_images']:
                print(' * %s/%s - %s' % (base_image, app_template, desc['name']))
Exemple #3
0
    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

        self._num_cores = options['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'])
            return

        image_names = options['name']
        templates = get_image_templates(img_build_dir)
        app_templates = get_app_templates(img_build_dir)
        images, image_groups, image_descriptors = get_all_images(templates, app_templates)

        if not image_names:
            self._print_image_list(images, image_groups, image_descriptors)
            print('\nRun ``s2e image_build <name>`` to build an image. '
                  'Note that you must run ``s2e build`` **before** building '
                  'an image')
            return

        image_names = translate_image_name(images, image_groups, image_names)
        logger.info('The following images will be built:')
        for image in image_names:
            logger.info(' * %s', image)

        if options['download']:
            _download_images(self.image_path(), image_names, templates)
            return

        rule_names = image_names

        if options['archive']:
            rule_names = _get_archive_rules(self.image_path(), image_names)

        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(image_descriptors, image_names)
        _check_iso(templates, app_templates, iso_dir, image_names)

        if self._use_kvm:
            _check_kvm()
            _check_groups_kvm()

        _check_groups_docker()
        _check_vmlinux()

        self._has_cow = _check_cow(self.image_path())

        if self._use_kvm:
            _check_virtualbox()
            _check_vmware()

        if not _is_port_available(options['ftp_port']):
            raise CommandError(f'localhost:{options["ftp_port"]} is not available. Check that the port is free or '
                               'specify a port with --ftp-port')

        # Clone kernel if needed.
        # This is necessary if the s2e env has been initialized with -b flag.
        self._clone_kernel()

        server = _start_ftp_server(self.image_path(), options['ftp_port'])

        self._invoke_make(img_build_dir, rule_names, options['ftp_port'], iso_dir)

        logger.success('Built image(s) \'%s\'', ' '.join(image_names))

        server.close_all()
Exemple #4
0
 def _initialize_images(self):
     img_build_dir = self.source_path(CONSTANTS['repos']['images']['build'])
     self._img_templates = get_image_templates(img_build_dir)
     app_templates = get_app_templates(img_build_dir)
     self._images, self._image_groups, self._image_descriptors = get_all_images(
         self._img_templates, app_templates)