Exemple #1
0
    def load_part(self, part_name, plugin_name, part_properties):
        # Some legacy parts can have a '/' in them to separate the main project
        # part with the subparts. This is rather unfortunate as it affects the
        # the layout of parts inside the parts directory causing collisions
        # between the main project part and its subparts.
        part_name = part_name.replace('/', '\N{BIG SOLIDUS}')

        plugin = pluginhandler.load_plugin(
            plugin_name=plugin_name,
            part_name=part_name,
            properties=part_properties,
            project_options=self._project_options,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema)

        logger.debug('Setting up part {!r} with plugin {!r} and '
                     'properties {!r}.'.format(part_name, plugin_name,
                                               part_properties))

        sources = getattr(plugin, 'PLUGIN_STAGE_SOURCES', None)
        stage_packages_repo = repo.Repo(plugin.osrepodir,
                                        sources=sources,
                                        project_options=self._project_options)

        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=part_properties,
            project_options=self._project_options,
            repo=stage_packages_repo)

        part = pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=part_properties,
            project_options=self._project_options,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
            stage_packages_repo=stage_packages_repo,
            grammar_processor=grammar_processor,
            snap_base_path=path.join('/', 'snap', self._snap_name, 'current'),
            confinement=self._confinement,
            soname_cache=self._soname_cache)

        self.build_snaps |= grammar_processor.get_build_snaps()
        self.build_tools |= grammar_processor.get_build_packages()

        # TODO: this should not pass in command but the required package,
        #       where the required package is to be determined by the
        #       source handler.
        if part.source_handler and part.source_handler.command:
            # TODO get_packages_for_source_type should not be a thing.
            self.build_tools |= repo.Repo.get_packages_for_source_type(
                part.source_handler.command)
        self.all_parts.append(part)

        return part
    def load_part(self, part_name, plugin_name, part_properties):
        plugin = pluginhandler.load_plugin(
            plugin_name=plugin_name,
            part_name=part_name,
            properties=part_properties,
            project_options=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
        )

        logger.debug("Setting up part {!r} with plugin {!r} and "
                     "properties {!r}.".format(part_name, plugin_name,
                                               part_properties))

        sources = getattr(plugin, "PLUGIN_STAGE_SOURCES", None)
        stage_packages_repo = repo.Repo(plugin.osrepodir,
                                        sources=sources,
                                        project_options=self._project)

        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=part_properties,
            project=self._project,
            repo=stage_packages_repo,
        )

        part = pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=part_properties,
            project_options=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
            stage_packages_repo=stage_packages_repo,
            grammar_processor=grammar_processor,
            snap_base_path=path.join("/", "snap", self._snap_name, "current"),
            base=self._base,
            confinement=self._confinement,
            snap_type=self._snap_type,
            soname_cache=self._soname_cache,
        )

        self.build_snaps |= grammar_processor.get_build_snaps()
        self.build_tools |= grammar_processor.get_build_packages()

        # TODO: this should not pass in command but the required package,
        #       where the required package is to be determined by the
        #       source handler.
        if part.source_handler and part.source_handler.command:
            # TODO get_packages_for_source_type should not be a thing.
            self.build_tools |= repo.Repo.get_packages_for_source_type(
                part.source_handler.command)
        self.all_parts.append(part)

        return part
Exemple #3
0
    def load_part(self, part_name, plugin_name, part_properties):
        # Some legacy parts can have a '/' in them to separate the main project
        # part with the subparts. This is rather unfortunate as it affects the
        # the layout of parts inside the parts directory causing collisions
        # between the main project part and its subparts.
        part_name = part_name.replace('/', '\N{BIG SOLIDUS}')

        plugin = pluginhandler.load_plugin(
            plugin_name=plugin_name,
            part_name=part_name,
            properties=part_properties,
            project_options=self._project_options,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema)

        logger.debug('Setting up part {!r} with plugin {!r} and '
                     'properties {!r}.'.format(part_name,
                                               plugin_name,
                                               part_properties))

        sources = getattr(plugin, 'PLUGIN_STAGE_SOURCES', None)
        stage_packages_repo = repo.Repo(
            plugin.osrepodir, sources=sources,
            project_options=self._project_options)

        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=part_properties,
            project_options=self._project_options,
            repo=stage_packages_repo)

        part = pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=part_properties,
            project_options=self._project_options,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
            stage_packages_repo=stage_packages_repo,
            grammar_processor=grammar_processor)

        self.build_snaps |= grammar_processor.get_build_snaps()
        self.build_tools |= grammar_processor.get_build_packages()

        if part.source_handler and part.source_handler.command:
            self.build_tools |= repo.Repo.get_packages_for_source_type(
                part.source_handler.command)
        self.all_parts.append(part)

        return part
Exemple #4
0
    def load_part(self, part_name, plugin_name, part_properties):
        plugin = pluginhandler.load_plugin(
            plugin_name=plugin_name,
            part_name=part_name,
            properties=part_properties,
            project=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
        )

        logger.debug("Setting up part {!r} with plugin {!r} and "
                     "properties {!r}.".format(part_name, plugin_name,
                                               part_properties))

        if isinstance(plugin, plugins.v1.PluginV1):
            keys_path = self._project._get_keys_path()

            if any([
                    package_repo.install(keys_path=keys_path) for package_repo
                    in plugin.get_required_package_repositories()
            ]):
                repo.Repo.refresh_build_packages()

        stage_packages_repo = repo.Repo

        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=part_properties,
            project=self._project,
            repo=stage_packages_repo,
        )

        part = pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=part_properties,
            project=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
            stage_packages_repo=stage_packages_repo,
            grammar_processor=grammar_processor,
            snap_base_path=path.join("/", "snap", self._project.info.name,
                                     "current"),
            soname_cache=self._soname_cache,
        )

        self.all_parts.append(part)

        return part
Exemple #5
0
    def load_part(self, part_name, plugin_name, part_properties):
        plugin = pluginhandler.load_plugin(
            plugin_name=plugin_name,
            part_name=part_name,
            properties=part_properties,
            project=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
        )

        logger.debug(
            "Setting up part {!r} with plugin {!r} and "
            "properties {!r}.".format(part_name, plugin_name, part_properties)
        )

        stage_packages_repo = repo.Repo

        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=part_properties,
            project=self._project,
            repo=stage_packages_repo,
        )

        part = pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=part_properties,
            project=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
            stage_packages_repo=stage_packages_repo,
            grammar_processor=grammar_processor,
            snap_base_path=path.join("/", "snap", self._project.info.name, "current"),
            soname_cache=self._soname_cache,
        )

        self.all_parts.append(part)

        return part
Exemple #6
0
def load_part(
    part_name,
    plugin_name=None,
    part_properties=None,
    project=None,
    stage_packages_repo=None,
    snap_name="test-snap",
    base="core18",
    build_base=None,
    confinement="strict",
    snap_type="app",
):
    if not plugin_name:
        plugin_name = "nil"
    properties = {"plugin": plugin_name}
    if part_properties:
        properties.update(part_properties)
    if "build-environment" not in properties:
        properties["build-environment"] = list()
    if not project:
        project = Project()

    project._snap_meta.name = snap_name
    project._snap_meta.version = "1.0"
    project._snap_meta.grade = "devel"
    project._snap_meta.type = snap_type
    project._snap_meta.confinement = confinement
    project._snap_meta.base = base
    if build_base is not None:
        project._snap_meta.build_base = build_base

    validator = _schema.Validator()
    schema = validator.part_schema
    definitions_schema = validator.definitions_schema
    plugin = pluginhandler.load_plugin(
        part_name=part_name,
        plugin_name=plugin_name,
        properties=properties,
        project=project,
        part_schema=schema,
        definitions_schema=definitions_schema,
    )

    if not stage_packages_repo:
        stage_packages_repo = mock.Mock()
    grammar_processor = grammar_processing.PartGrammarProcessor(
        plugin=plugin,
        properties=properties,
        project=project,
        repo=stage_packages_repo)

    return pluginhandler.PluginHandler(
        plugin=plugin,
        part_properties=properties,
        project=project,
        part_schema=schema,
        definitions_schema=definitions_schema,
        grammar_processor=grammar_processor,
        stage_packages_repo=stage_packages_repo,
        snap_base_path="/snap/fake-name/current",
        soname_cache=elf.SonameCache(),
    )
Exemple #7
0
    def load_part(self, part_name, plugin_name, part_properties):
        plugin = pluginhandler.load_plugin(
            plugin_name=plugin_name,
            part_name=part_name,
            properties=part_properties,
            project=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
        )

        logger.debug("Setting up part {!r} with plugin {!r} and "
                     "properties {!r}.".format(part_name, plugin_name,
                                               part_properties))

        if isinstance(plugin, plugins.v1.PluginV1):
            sources = plugin.get_required_repo_sources()
            keys = plugin.get_required_repo_gpg_keys()

            for key in keys:
                repo.Repo.install_gpg_key(key)

            for source in sources:
                repo.Repo.install_source(source)

        stage_packages_repo = repo.Repo

        grammar_processor = grammar_processing.PartGrammarProcessor(
            plugin=plugin,
            properties=part_properties,
            project=self._project,
            repo=stage_packages_repo,
        )

        part = pluginhandler.PluginHandler(
            plugin=plugin,
            part_properties=part_properties,
            project=self._project,
            part_schema=self._validator.part_schema,
            definitions_schema=self._validator.definitions_schema,
            stage_packages_repo=stage_packages_repo,
            grammar_processor=grammar_processor,
            snap_base_path=path.join("/", "snap", self._project.info.name,
                                     "current"),
            soname_cache=self._soname_cache,
        )

        self.build_snaps |= grammar_processor.get_build_snaps()
        self.build_tools |= grammar_processor.get_build_packages()

        if not isinstance(part.plugin, plugins.v1.PluginV1):
            self.build_tools |= part.plugin.get_build_packages()

        # TODO: this should not pass in command but the required package,
        #       where the required package is to be determined by the
        #       source handler.
        if part.source_handler and part.source_handler.command:
            # TODO get_packages_for_source_type should not be a thing.
            self.build_tools |= repo.Repo.get_packages_for_source_type(
                part.source_handler.command)
        self.all_parts.append(part)

        return part