def __init__(self, project: project.Project) -> None: self.build_snaps = set() # type: Set[str] self.project = project # raw_snapcraft_yaml is read only, create a new copy snapcraft_yaml = apply_extensions(project.info.get_raw_snapcraft()) self.validator = Validator(snapcraft_yaml) self.validator.validate() snapcraft_yaml = self._expand_filesets(snapcraft_yaml) self.data = self._expand_env(snapcraft_yaml) self._ensure_no_duplicate_app_aliases() grammar_processor = grammar_processing.GlobalGrammarProcessor( properties=self.data, project=project) self.build_tools = grammar_processor.get_build_packages() self.build_tools |= set(project.additional_build_packages) # If version: git is used we want to add "git" to build-packages if self.data.get("version") == "git": self.build_tools.add("git") # Always add the base for building for non os and base snaps if project.info.base is not None and project.info.type not in ("base", "os"): # If the base is already installed by other means, skip its installation. # But, we should always add it when in a docker environment so # the creator of said docker image is aware that it is required. if common.is_docker_instance( ) or not repo.snaps.SnapPackage.is_snap_installed( project.info.base): self.build_snaps.add(project.info.base) elif project.info.type not in ("base", "os"): # This exception is here to help with porting issues with bases. In normal # executions, when no base is set, the legacy snapcraft will be executed. raise RuntimeError("A base is required for {!r} snaps.".format( project.info.type)) self.parts = PartsConfig( parts=self.data, project=project, validator=self.validator, build_snaps=self.build_snaps, build_tools=self.build_tools, ) self.data["architectures"] = _process_architectures( self.data.get("architectures"), project.deb_arch) conduct_environment_sanity_check(self.project, self.data, self.validator.schema)
def test_command_chain_with_full_adapter(self): project = snapcraft.project.Project() yaml_data = { "apps": { "test-app": {"command-chain": ["test-command-chain"], "adapter": "full"} } } try: conduct_environment_sanity_check( project, yaml_data, _schema.Validator().schema ) except Exception: self.fail("No exception was expected")